Firstly, let's take a look at what immediate property implies with an example:
=======================================================
Suppose you have a page with a button and a field for entering the quantity of a book in a shopping cart.
If the immediate attributes of both the button and the field are set to true, the new value entered in the field will be available for any processing
associated with the event that is generated when the button is clicked.
The event associated with the button as well as the events, validation, and conversion associated with the field are all handled when request parameter values are applied.
If the button's immediate attribute is set to true but the field's immediate attribute is set to false, the event associated with the button is processed
without updating the field's local value to the model layer.
The reason is that any events, conversion, and validation associated with the field occur after request parameter values are applied.
Now, let's take the following use-case:
The quantity field for each book (see below) does not set the immediate attribute, so the value is false (the default).
<h:inputText id="quantity"
size="4"
value="#{item.quantity}"
title="#{bundle.ItemQuantity}">
<f:validateLongRange minimum="0"/>
...
</h:inputText>
The immediate attribute of the Continue Shopping hyperlink is set to true, while the immediate attribute of the Update Quantities hyperlink is set to false:
<h:commandLink id="continue"
action="bookcatalog"
immediate="true">
<h:outputText value="#{bundle.ContinueShopping}"/>
</h:commandLink>
...
<h:commandLink id="update"
action="#{showcart.update}"
immediate="false">
<h:outputText value="#{bundle.UpdateQuantities}"/>
</h:commandLink>
If we click the Continue Shopping hyperlink, none of the changes entered into the quantity input fields will be processed.
If we click the Update Quantities hyperlink, the values in the quantity fields will be updated in the shopping cart.
=======================================================
Suppose you have a page with a button and a field for entering the quantity of a book in a shopping cart.
If the immediate attributes of both the button and the field are set to true, the new value entered in the field will be available for any processing
associated with the event that is generated when the button is clicked.
The event associated with the button as well as the events, validation, and conversion associated with the field are all handled when request parameter values are applied.
If the button's immediate attribute is set to true but the field's immediate attribute is set to false, the event associated with the button is processed
without updating the field's local value to the model layer.
The reason is that any events, conversion, and validation associated with the field occur after request parameter values are applied.
Now, let's take the following use-case:
The quantity field for each book (see below) does not set the immediate attribute, so the value is false (the default).
<h:inputText id="quantity"
size="4"
value="#{item.quantity}"
title="#{bundle.ItemQuantity}">
<f:validateLongRange minimum="0"/>
...
</h:inputText>
The immediate attribute of the Continue Shopping hyperlink is set to true, while the immediate attribute of the Update Quantities hyperlink is set to false:
<h:commandLink id="continue"
action="bookcatalog"
immediate="true">
<h:outputText value="#{bundle.ContinueShopping}"/>
</h:commandLink>
...
<h:commandLink id="update"
action="#{showcart.update}"
immediate="false">
<h:outputText value="#{bundle.UpdateQuantities}"/>
</h:commandLink>
If we click the Continue Shopping hyperlink, none of the changes entered into the quantity input fields will be processed.
If we click the Update Quantities hyperlink, the values in the quantity fields will be updated in the shopping cart.