使用 f:ajax 渲染多个组件 [英] Render multiple components with f:ajax
问题描述
错误的代码是:
<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>
我想要做的是当我点击 commandButton
时,我想刷新这两个图表.但是现在我使用了两个 <ajax>
标签,其中第二个不起作用.
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.
那么如何使用ajax来渲染两个图表呢?
So how can I use ajax to render two charts?
推荐答案
您可以使用单个 f:ajax
渲染多个组件.只需确保您要更新的所有单个组件都具有 id
.在您的示例中,它类似于:
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"/>
ID 需要像 linear1 linear2
这样的空格分隔,而不是像 linear1, linear2
那样用逗号分隔(仅适用于 p:ajax
代码>).
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
).
另见:
这篇关于使用 f:ajax 渲染多个组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!