Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p:commandButton with immediate=true

Tags:

jsf-2

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?

like image 812
Ponni Maran Avatar asked May 14 '13 11:05

Ponni Maran


People also ask

What is immediate true in Primefaces?

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.

What is immediate attribute?

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.


1 Answers

JSF lifecycle contains 6 phases, which are:

  1. Restore view
  2. Apply request values
  3. Process validations
  4. Update model values
  5. Invoke application
  6. Render response

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.

like image 196
damian Avatar answered Oct 29 '22 17:10

damian