Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

jsf - Render multiple components with f:ajax

The wrong codes are:

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

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

So how can I use ajax to render two charts?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...