What action is taken when I declare immediate="true"
in command button? The documentation says
Boolean value that determines the phaseId of the action event, when true actions are processed at "Apply Request Values", when false at "Invoke Application" phase.
However, I don't understand it. Can someone please explain this?
With immediate="true" on the button, the action is indeed invoked during apply request values phase and all the remaining phases are skipped. That's also the sole point of this attribute: process (decode, validate, update and invoke) the component immediately during apply request values phase.
The immediate attribute can be used to achieve the following effects: Allow a commandLink or commandButton to navigate the user to another page without processing any data currently in input fields of the current screen. In particular, this allows navigation to occur even when there are currently validation errors.
JSF lifecycle contains 6 phases, which are:
If a command button has immediate="true"
, then the phases 'Process validations' and 'Update model values' are skipped. Therefore, convertions and validations are not processed and attributes in managed bean are not updated.
However, if a UIInput in the form also has immediate="true", then its value will be converted, validated and updated in managed bean, because it will happen in 'Apply request values' phase.
One example of when you might use a button with immediate="true" is the case of a 'Cancel' button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With