UIInput components and command components can set the immediate attribute to true.
This attribute, when set to true, forces the conversion and validation
phase to occur earlier in the lifecycle, during the apply request values
phase. In other words, if some components on the page have their
immediate attributes set to true, then the validation, conversion, and
events associated with these components will be processed during apply request values phase.
The immediate attribute can be used for the following purposes :
- Immediate attribute, when set to true, allows a commandLink or commandButton to
process the back-end logic and ignore validation process related to
the fields on the page. This allows navigation to occur even when there are
validation errors.
- To make one or more input components "high priority" for validation,
so validation is performed, if there is any invalid component data,
only for high priority input components and not for low priority
input components in the page. This helps reducing the number of
error messages shown on the page.
For example :
In the code below, button performs navigation without validating the
required field.
<h:inputText id="it" required="true"/>
<t:message for="it"/>
<t:commandButton value="submit" immediate="true" action="welcome"/> |
In the code below, validation is performed only for the first
component when button is clicked in spite of being both the input
components required.
<h:inputText id="it1" immediate="true" required="true"/>
<h:inputText id="it2" required="true"/>
<t:message for="it1"/>
<t:message for="it2"/>
<t:commandButton value="submit" action="welcome"/> |
|