Ned Collyer wrote:
er... form.hasError()? form.onError()?
What do you mean by page? - are there lots of forms on the page all with errors?
Thanks Ned for pointing out the form’s hasError() and onError(). I could make use of these wtihin my visitor rather looking at all components. But what if an error is created outside a form component? Such as:
if (!isPhoneDirectoryAvailble) {
Session.get().error("The phone directory is not available at this time…");
}
Let me explain my need for this. I’m writing a custom Refreshing view item reuse strategy that will redisplay the items as they were submitted if any page errors occur (such as validation). I know there is already an existing ReuseIfModelsEqual strategy, but I cannot make use of it. The reason is my model is many levels deep and is highly complex (hibernate generated) and has its own equals/hashcode strategy (our custom implementation) which will not work for this case and I don’t want to further override them. My custom reuse strategy is rather simple. If a page error occurred in which the page gets redisplayed, it simply makes use of the existing items (and does not try to make use of any new items like the ReuseIfModelsEqual strategy does).
So going back to my original question, what is the best way to determine if ANY error was generated on the page during the page submit?