【问题标题】:How to update p:outputabel value dynamically in Prime Faces如何在 Primefaces 中动态更新 p:outputlabel 值
【发布时间】:2019-08-02 20:21:45
【问题描述】:

我正在我的一个 jsf 项目中实现动态货币。我从后端获取货币的价值,并使用 p:outputlabel 在前端进行设置。有一个命令按钮,一旦单击它将更新特定字段中的所有数据。它目前工作完美,当我单击“确定”按钮时,它会更新所有输入字段,但不会更新输出标签。我尝试将其更改为 h:outputText 但没有奏效,即使我尝试为标签创建一个 id 并更新 p:commandbutton 中的 id,但没有奏效。下面是示例代码:

<p:commandButton id="okInfoAlert" value="Ok" rendered="#{bean.okId ne '' and bean.okId ne null}"
action="#{searchDetailsForNgIdService.setDataInokInfo}"
styleClass="button" onclick="closeAllAccordion()" 
update="custInfoPanelGridId, okInfoPanelGridId,okInfoService_ok_link_PanelGridID,okInfoPanelGrid" >

单击此命令按钮后,我们在后端调用了一个存储过程,该过程在 fetchcurrencyBean 类(如下所示)下设置选定货币值中的货币值。

输出标签:

<p:outputLabel value="#{fetchcurrencyBean.selectedcurrency}"></p:outputLabel>

在这里,我尝试在单击命令按钮后立即动态更新输出标签值。它在页面重新加载后工作,但不会动态更改标签

【问题讨论】:

标签: jsf primefaces


【解决方案1】:
  1. 为 p:outputLabel 提供 id。
  2. 将此 id 添加到 p:commandButton 更新。
  3. 确保您已为所选货币创建了 getter 和 setter
  4. 确保选择的货币不为空。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-17
    • 2019-10-29
    • 2015-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    相关资源
    最近更新 更多