How to skip validation in JSF
Published: October 29, 2010 , Updated: October 29, 2010 , Author: mkyong
Problem
See following JSF example :
<h:inputSecret id="password" value="#{user.password}" size="20" required="true" label="Password"> <f:validateRegex pattern="((?=.*\d).{6,20})" /> </h:inputSecret> <h:message for="password" style="color:red" /> <h:commandButton value="Cancel" action="cancel" /> <h:commandButton value="Submit" action="result" />
If you click on the “cancel” button, the password validation will be fired and stop you proceed on the cancel page, which is doesn’t make sense. Is there any way to bypassing the validation in JSF?
Solution
To skip validation, add a immediate=”true” attribute to the cancel button.
<h:inputSecret id="password" value="#{user.password}" size="20" required="true" label="Password"> </h:inputSecret> <h:message for="password" style="color:red" /> <h:commandButton value="Cancel" immediate="true" action="cancel" /> <h:commandButton value="Submit" action="result" />
Note : You can find more similar articles at - JSF 2 Tutorials








Good solution.