Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeFaces disable validation on cancel button [duplicate]

Tags:

In a form, I have some inputText with two commandButton, one to accept and one to cancel.

How can I disable validation for the cancel button only?

<h:form id="detailsForm">   <p:inputText id="editUsername" value="#{userController.editUser.usrUsername}" />   <p:inputText id="editFirstName" value="#{userController.editUser.usrFirstName}" />   <p:inputText id="editLastName" value="#{userController.editUser.usrLastName}" />   <p:commandButton value="Accept" update=":detailsForm" actionListener="#{userController.onDetailsEditAccept}" />   <p:commandButton value="Cancel" update=":detailsForm" actionListener="#{userController.onDetailsEditCancel}" /> </h:form> 

I already tried inserting required="false" on fields but it didn't work. I also tried inserting <f:validateBean disabled="true" /> on fields and it didn't work.

like image 862
Paolo Dragone Avatar asked Feb 19 '13 13:02

Paolo Dragone


1 Answers

Use the attribute immediate="true" in your cancel commandButton. This will skip the entire processing of the form, tough, by skipping the Apply Request Values, Process Validations and Update Model Values phases.

<p:commandButton value="Cancel" update=":detailsForm" actionListener="#{userController.onDetailsEditCancel}" immediate="true"/> 
like image 167
Fritz Avatar answered Oct 26 '22 15:10

Fritz