Md Kamran Azam
Md Kamran Azam

Reputation: 129

How to update p:outputabel value dynamically in Prime Faces

I am implementing a dynamic currency in one of my jsf project. I am getting the value of currency from backend and setting it up in the front end using p:outputlabel. There is command button, which once clicked will update all the data coming in specific field. Its currently working perfect, as when I click on Ok button it update all the input field, but is not updating the output label. I tried changing this to h:outputText but didnt worked, even I tried creating an id for the label and updating the id in p:commandbutton, but didn't worked. Below is the sample code:

<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" >

On the click of this commandbutton we called a stored procedure at the backend which sets the value of currency in selectedcurrency value under fetchcurrencyBean class(given below).

Output label:

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

Here I am trying to update the outputlabel value dynamically as soon as we click on commandbutton. It is working after the page is reloaded, but not changing the label dynamically

Upvotes: 0

Views: 1232

Answers (1)

mks
mks

Reputation: 37

  1. Give id to p:outputLabel.
  2. Add this id to p:commandButton update.
  3. Make sure you have created getter and setter for selectedcurrency
  4. Make sure selectedcurrency is not empty.

Upvotes: 1

Related Questions