previous | index | next

Bypassing Validation

By default the JSF life cycle forces a redisplay of the current page, with errors displayed, in the event of validation errors. See the Life Cycle Diagram.

Sometimes you don't want the same page to appear, much less to see the messages, even when input fields are incorrect.

For example, clicking a button to leave a page prematurely or to cancel an operation should not cause validation error messages because of missing or bad values left in input fields.

Ordinarily, an action associated with a command button is executed in the Invoke Application phase, which occurs after the Process Validations phase.

However, you can force execution of the action in the Apply Request Values phase (which precedes Process Validations) by setting the button tag's immediate attribute to "true", as in:

     <h:commandButton value="Cancel" action="cancel" immediate="true"/>

previous | index | next