Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax Update All components with JSF

Tags:

ajax

jsf

Is there a way to update all components or do I have to manually select each id? I have an ajax html5 detection script and dont want have to update every component via the id.

Thanks

like image 542
DD. Avatar asked Dec 05 '22 21:12

DD.


2 Answers

Just use the ID of the common parent component.

<h:panelGroup id="someParent">
    <h:someComponentToUpdate ... />
    ...
    <h:someComponentToUpdate ... />
    ...
    <h:someComponentToUpdate ... />
    ...
</h:panelGroup>
...
<f:ajax render="someParent" />

Or use @all to refresh the entire page.

<f:ajax render="@all" />
like image 80
BalusC Avatar answered Jan 01 '23 00:01

BalusC


If you need to invoke an update base on an event, I would recommend you use PrimeFaces. Check out their showcase at http://www.primefaces.org/showcase-labs/ui/home.jsf. Below show how to use update components when a button is click

<p:commandButton value="Test" update="container" actionListener="#{myBean.process}"/>

Then have a wrapper container wrap around all components that you want to update like BalusC shows above.

<h:panelGroup id="container">
     ...
     // All components you want to update here. 
</h:panelGroup>
like image 27
Thang Pham Avatar answered Jan 01 '23 01:01

Thang Pham