几个要素由ID的JSF(Primefaces)AJAX更新 [英] JSF(Primefaces) ajax update of several elements by ID's

查看:349
本文介绍了几个要素由ID的JSF(Primefaces)AJAX更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关JSF.Particularly,Primefaces一个问题。
有以下的问题与ID的元素在同一时间的AJAX更新。 如果页面上的元素去一个接一个,那ajax的更新进行确定:

One more question concerning JSF.Particularly, Primefaces.
Have following problem with ajax update of elements by id's at same time. If elements on page goes one by one ,that ajax update performs ok:

<ui:repeat value="#{showProducts.inCart}" var="cart">
 <td><p:spinner min="0" value="#{cart.count}" immediate="true">
 <p:ajax process="@this" update="count,subTotal"/></p:spinner></td>         
 <td><h:outputText value="#{cart.totalPrice}" id="count"/></td>
 <h:outputText value="#{showProducts.subTotal}" id="subTotal"/>      
</ui:repeat>

ID为伯爵在这里元素先走,然后ID为小计的元素去第二次。 在的情况下,页面上的元素不是严格一个接一个,与该第二元件小计ID未更新:

Here element with id "count" goes first,then element with id "subtotal" goes second. In case,elements on page are not strictly one by one,that second element with "subtotal" id is not updated:

    <ui:repeat value="#{showProducts.inCart}" var="cart">
      <td><p:spinner min="0" value="#{cart.count}" immediate="true">
<p:ajax process="@this" update="count,subTotal"/></p:spinner></td>         
      <td><h:outputText value="#{cart.totalPrice}" id="count"/></td>
      <td><h:outputText value="#{cart.place}" /></td>
    </ui:repeat>
    <h:outputText value="#{showProducts.subTotal}" id="subTotal"/> 

这是正常的行为还是我错过了一些参数?

Is it normal behaviour or I miss some parameters?

推荐答案

如果要被更新的组件是不一样的 NamingContainer 组件( UI:重复 H:形式 H:dataTable中,等等),那么你需要指定绝对客户端ID。 preFIX与(默认 NamingContainer 分隔符),以从根本入手。

If the to-be-updated component is not inside the same NamingContainer component (ui:repeat, h:form, h:dataTable, etc), then you need to specify the "absolute" client ID. Prefix with : (the default NamingContainer separator character) to start from root.

<p:ajax process="@this" update="count :subTotal"/>

可以肯定的,检查小计的客户端ID 组件生成的HTML实际值。如果它里面例如 H:。形式为好,那么它的pfixed与它的客户ID和$ P $,你也需要相应地解决这个问题。

To be sure, check the client ID of the subTotal component in the generated HTML for the actual value. If it's inside for example a h:form as well, then it's prefixed with its client ID as well and you would need to fix it accordingly.

<p:ajax process="@this" update="count :formId:subTotal"/>

空间ID的分离是比较推荐的&LT; F:。AJAX&GT; 不支持逗号分隔和起动器,否则弄糊涂

Space separation of IDs is more recommended as <f:ajax> doesn't support comma separation and starters would otherwise get confused.

这篇关于几个要素由ID的JSF(Primefaces)AJAX更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆