加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用f:ajax渲染多个组件

发布时间:2020-12-16 03:11:27 所属栏目:百科 来源:网络整理
导读:错误的代码是: 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:commandButtonp:lineCh
错误的代码是:
<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来渲染两个图表?

您可以使用单个f:ajax渲染多个组件。只需确保要更新的所有单个组件都有一个ID。在你的样品中,它将像:
<f:ajax execute="search_form" render="linear1 linear2"/>

其中ID需要通过像linear1 linear2这样的空格分隔,而不是像linear1,linear2(只在p:ajax中有效)。

也可以看看:

> Understanding process and update attributes of PrimeFaces
> How to find out client ID of component for ajax update/render? Cannot find component with expression “foo” referenced from “bar”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读