简体   繁体   中英

How to programmatically ajax-update specific component in backing bean

Is there a way to ajax-update a specific component such as a <h:form> in backing bean?

I tried the following using RequestContext#execute() ,

RequestContext context = RequestContext.getCurrentInstance();
context.execute("monitorVehicleForm.update()");

however that didn't seem to have any effect.

The RequestContext#execute() only executes arbitrary JavaScript code which is been passed-in as argument. It does not ajax-update the client representation of the components.

You need RequestContext#update() instead wherein you just pass the client ID of the to-be-updated component.

context.update("monitorVehicleForm");

This has exactly the same effect as <p:commandXxx ... update="monitorVehicleForm"> . This works provided you've a

<h:form id="monitorVehicleForm">

without any NamingContainer parent and thus have a

<form id="monitorVehicleForm" name="monitorVehicleForm" ...> 

in the generated HTML.

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM