简体   繁体   English

使用f:ajax渲染多个组件

[英]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. 我要做的是单击commandButton ,我想刷新这两个图表。 But now I used two <ajax> tags, of which the second doesn't work. 但是现在我使用了两个<ajax>标签,其中第二个不起作用。

So how can I use ajax to render two charts? 那么如何使用Ajax渲染两个图表呢?

You can render multiple components with single f:ajax . 您可以使用单个f:ajax渲染多个组件。 Just make sure all individual components you want to update have an id . 只需确保要更新的所有单个组件都具有一个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 ). ID仅需由空格分隔,例如linear1 linear2而不能像linear1, linear2和linear2一样linear1, linear2 (仅在p:ajax )。

See also: 也可以看看:

对于a4j jsf,请使用',': <a4j:support event="onchange" reRender="parent,child1,child2" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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