Cacheing Cacheing - 1 year ago 154
Ajax Question

Render multiple components with f:ajax

The wrong codes are:

<h:form id="search_form">
<h:commandButton class="button" value="View" action="#{}">
<f:ajax execute="search_form" render="linear1"></f:ajax>
<f:ajax execute="search_form" render="linear2"></f:ajax>
<p:lineChart id="linear1" value="#{InfoBean.linearModel1}" legendPosition="e"/>
<p:lineChart id="linear2" value="#{InfoBean.linearModel2}" legendPosition="e"/>

What I want to do is when I click on the
, I want to refresh those two charts. But now I used two
tags, of which the second doesn't work.

So how can I use ajax to render two charts?

Answer Source

You can render multiple components with single f:ajax. Just make sure all individual components you want to update have an id. In your sample it would be something like:

<f:ajax execute="search_form" render="linear1 linear2"/>

Where the IDs need to be separated by just whitespace like linear1 linear2 and not commaseparated like linear1, linear2 (that works only in p:ajax).

See also:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download