使用 f:ajax 渲染多个组件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16597542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Render multiple components with f:ajax
提问by Cacheing
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.
我想要做的是当我点击 时commandButton,我想刷新这两个图表。但是现在我使用了两个<ajax>标签,其中第二个不起作用。
So how can I use ajax to render two charts?
那么如何使用ajax来渲染两个图表呢?
回答by partlov
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. 只需确保您要更新的所有单个组件都具有id. 在您的示例中,它将类似于:
<f:ajax execute="search_form" render="linear1 linear2"/>
Where the IDs need to be separated by just whitespace like linear1 linear2and not commaseparated like linear1, linear2(that works only in p:ajax).
ID 需要仅由空格分隔linear1 linear2而不是逗号分隔linear1, linear2(仅适用于p:ajax)。
See also:
也可以看看:
回答by Chinmoy
For a4j jsf use ',':
<a4j:support event="onchange" reRender="parent,child1,child2" />
对于 a4j jsf 使用 ',':
<a4j:support event="onchange" reRender="parent,child1,child2" />

