小编典典

使用f:ajax渲染多个组件

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>标签,其中第二个不起作用。

那么如何使用Ajax渲染两个图表呢?


阅读 287

收藏
2020-07-26

共1个答案

小编典典

您可以使用单个渲染多个组件f:ajax。只需确保要更新的所有单个组件都有一个id。在您的示例中,它将类似于:

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

这些ID仅需用空格分隔linear1 linear2,而不能用逗号分隔linear1, linear2(仅适用于p:ajax)。

2020-07-26