使用f:ajax渲染多个组件

Cac*_*ing 25 ajax jsf jsf-2 commandbutton

错误的代码是:

<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>
Run Code Online (Sandbox Code Playgroud)

我想要做的是当我点击它时commandButton,我想刷新这两个图表.但现在我使用了两个<ajax>标签,其中第二个标签不起作用.

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

par*_*lov 53

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

<f:ajax execute="search_form" render="linear1 linear2"/>
Run Code Online (Sandbox Code Playgroud)

其中ID需要用空格分隔,linear1 linear2而不是像逗号分隔的那样linear1, linear2(仅适用于p:ajax).

也可以看看: