0

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

Md Kamran Azam
  • 129
  • 2
  • 17
  • Possible duplicate of [Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes](https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes) – akhil Rao Mar 12 '19 at 13:38
  • I guess you have your outputLabel properly placed in some of the referenced components? Also you don't need to specifically call action with a setter, the commandbutton sends the whole form by default.. – Aritz Mar 13 '19 at 15:35

1 Answers1

1
  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.
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
mks
  • 37
  • 1
  • 10