How to programmatically ajax-update specific component in backing bean

后端 未结 1 1520
忘了有多久
忘了有多久 2021-02-08 15:01

Is there a way to ajax-update a specific component such as a in backing bean?

I tried the following using RequestContext#execute(),



        
相关标签:
1条回答
  • 2021-02-08 15:12

    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:

    • How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"
    0 讨论(0)
提交回复
热议问题