当前位置: 动力学知识库 > 问答 > 编程问答 >

jsf 2 - p:commandButton with immediate=true

问题描述:

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?

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: