Is it possible to perform some actions (some cleanup) if jsf validation errors occur?
Fields are validated with tags in xhtml, for example 'required="true"', 'f:validateRegex pattern="\d*"', 'f:validator validatorId="someValidator"'.
I need to set some property field of managed bean to null (when there are any failures on the page).
But if validation fails, then JSF goes to Render Response Phase and managed bean method is not invoked.
Listener (using f:actionListener tag) also is not invoked in that case.
Now I'm thinking about to replace xhtml validation by validation using bean annotations like @AssertTrue, @Size, etc.
Then in some of this validating methods it would be possible to make a cleanup:
@ManagedBean
class SomeBean {
...
@AssertTrue
public void isClenup() {
cleanup();
}
...
}
But it seems not a good solution to me.
Also I noticed that several methods annotated with @AssertTrue are called in undefined order. Therefore switching from xhtml validation to bean annotations validation is getting not so easy.
Is it possible to define some order of calling methods annotated with @AssertTrue?