Java Reference
In-Depth Information
Source Page Resolution
To determine the page from which a request came from,
Stripes calls the
getSourcePageResolution
( ) method of the
Action-
BeanContext
class. This method uses the
_sourcePage
request
parameter, which is automatically generated by Stripes.
• If we delete all errors from the list and return
null
, it's as if those
errors never happened. Only in this case is the event handler exe-
cuted.
For example:
public class
MyActionBean
extends
BaseActionBean
implements
ValidationErrorHandler
{
Resolution handleValidationErrors(ValidationErrors errors) {
if
(specialSituation) {
return new
ForwardResolution("/WEB-INF/jsp/special.jsp");
}
if
(bypassErrors) {
errors.clear();
}
return null
;
}
}
If the
specialSituation
flag is
true
, the user is sent directly to
special.jsp
.
If the
bypassErrors
flag is
true
, the event handler is executed because the
list of errors is emptied before returning
null
. If neither flag is
true
, the
user is sent back to the source page because the method returns
null
but the list still contains errors.
The custom methods part of the validation process is summarized in
dleValidationErrors
( ) method of the
ValidationErrorHandler
interface, we have
full control over what happens after the built-in validations have been
executed. We can run custom validation methods and control what hap-
pens when errors have occurred.
Validation in the Event Handler
Finally, we may encounter situations where the validation that we want
to perform just doesn't fit anywhere in the validation process.
Search WWH ::
Custom Search