Java Reference
In-Depth Information
2. ActionBeanResolution : The action bean that is targeted by the re-
quest is determined from the URL.
3. HandlerResolution : The name of the event and the event handler
method are resolved from the URL and request parameters.
4. BindingAndValidation : The request parameters are bound to the cor-
responding properties of the action bean, with validation and type
conversion.
5. CustomValidation : The custom validation methods are executed.
Also, the handleValidationErrors ( ) is called if the action bean imple-
ments ValidationErrorHandler .
6. EventHandling : The event handler method is executed.
7. ResolutionExecution : The resolution that was returned from any of
the preceding stages is executed, producing a response to the
client.
8. RequestComplete : This final stage is executed in a finally block to
make sure that it always runs, even if an exception is thrown.
For stages 4-6, the usual rules of validation apply: a validation error
normally means event handling won't be executed, and custom valida-
tion depends on previous validations as explained in Section 4.3 , Con-
tinue or Stop Validation When There Are Previous Errors?, on page 89 .
Besides exceptions and validation errors, the other way that life-cycle
stages can be interrupted is by an interceptor. If, at any stage, a resolu-
tion is returned, the life cycle immediately skips to ResolutionExecution .
This is how the flow can be altered.
Let's learn a bit more about interceptors and how we can tinker with
The Flow of Things.
Implementing Before/After Methods
To execute code before or after one or more life-cycle stages, we must
first decide whether we want the code to apply to just one action bean
or to the whole application. Let's start with the former case. By adding
a method to an action bean and annotating the method with @Before or
@After , it will be executed before or after the life-cycle stages we specify:
@Before(stages=LifecycleStage.BindingAndValidation)
public void interceptor1() {
// do something before binding and validation
}
 
 
Search WWH ::




Custom Search