I have a form where there is a set of input textboxes and we are populating data as well as giving a provision to edit these. After editing we are showing the same page again with the edited details which is saved to database.
The problem is in cancel button click when we are modifying the data and instead of saving we are clicking on cancel button then the page is getting populated with edited data although we have clicked on cancel & its not saved in database the same page is getting rendered with the edited data. I want to avoid this scenario.
<h:outputText value="#{institutionalUser.userName}" rendered="#{not ProfileBean.editProfile}"></h:outputText>
<p:inputText id="UserNameData" value="#{organizationProfileBean.institutionalUser.userName}" rendered="#{organizationProfileBean.editProfile}">
<h:commandButton styleClass="button" value="Cancel" id="cancelButton" immediate="true">
So in the above code is a part of companyorganisationprofile.xhtml page where we have the username having value from bean on page load. When we are going to edit the value we are using the textbox with the prepopulated value. When we are saving the data the same page is getting rendered again. But when we are clicking on cancel button the page is getting populated with the data which we have tried to edit but not inteded to save. The value is not getting saved still its showing in the page which is wrong.
I am not getting how to avoid to set the value in bean when we are not saving or clicking on cancel button.
So I want help in not to set value in bean when we are clicking on cancel button as it is not useful. Please share your valuable suggestion in this.