如何在Primefaces中动态更新p:outputlabel值

问题描述 投票:0回答:1

我正在我的一个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类下设置了selectedcurrency值中的currency值(如下所示)。

输出标签:

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

我在这里尝试在单击commandbutton时动态更新outputlabel值。重新加载页面后它正在工作,但不会动态更改标签

jsf primefaces
1个回答
1
投票
  1. 将id赋给p:outputLabel。
  2. 将此id添加到p:commandButton update。
  3. 确保已为selectedcurrency创建了getter和setter
  4. 确保selectedcurrency不为空。
© www.soinside.com 2019 - 2024. All rights reserved.