Java Reference
In-Depth Information
Validation for operations such as adding a record to a database belongs
in an event handler, not in a validation method. Since event handlers
return a Resolution , it's up to us to send the user back where they came
from in case of a validation error. As we can see, it's quite straightfor-
ward with the action bean context:
public Resolution add() {
try {
database.add(record);
return new RedirectResolution(ListActionBean. class );
}
catch (DuplicateRecordException) {
getContext().getValidationErrors().addGlobalError(
new SimpleError("Add error: duplicate record"));
return getContext().getSourcePageResolution();
}
}
With built-in validations, validation methods, error handlers, and val-
idation in event handlers, Stripes gives us many tools to validate user
input. We can use them to keep your model clean of invalid data, let
our users know about the errors that occurred, and give them a chance
to fix the input and resubmit the form.
 
 
Search WWH ::




Custom Search