JSF 生命周期 - JSF Liefcycle (1)
ZZ.
Well, you probably already know that the JSF lifecycle contains 6 phases:1.Restore view2.Apply request values3.Process validations4.Update model values5.Invoke application6.Render response
You can use a PhaseListener to trace the phases of the JSF lifecycle and execute some processes where required. But you can also use a "dummy" PhaseListener to debug the phases to see what is happening in which phase. Here is a basic example of such a LifeCycleListener:
Note: if you don't have a JSF playground environment setup yet, then you may find this tutorial useful as well: JSF tutorial with Eclipse and Tomcat.
?
Add the following lines to the faces-config.xml to activate the LifeCycleListener.
The minimal contents of the test JSF file: test.jsp
?
?
The dummy converter: MyConverter.java
?
The minimal faces configuration: faces-config.xml
?
?
?
Extend the
1. Restore view.
The bean is constructed. The?The form submit with the value "test" entered should output at least:
?那在UI 上就成了:aaaaa _updated...
?
Note for all components without immediate: as the Update model values phase is skipped, the value bindings aren't been set and the value binding getters will return null. But the values are still available as submitted value of the relevant components in the UIViewRoot. In this case you can retrieve the non-converted and non-validated input value from inputComponent.getSubmittedValue() in the action() method. You could even change it using inputComponent.setSubmittedValue(newValue) in the action() method.
?
?