Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: Release 1.5
-
Fix Version/s: Release 1.5
-
Component/s: Validation
-
Labels:None
-
Environment:Stripes SVN build 883
Description
ValidationError has a beanclass property which, among other things, serves in the resource bundle lookup for error messages.
For example, new LocalizableError("haha") in class foo.bar.MyActionBean will look for foo.bar.MyActionBean.haha=doh! in the resource bundle (among other keys.)
The beanclass property is set by DispatcherHelper.handleValidationErrors() which calls fillInValidationErrors(), and that's where the work is done.
The problem I've encountered is this: an Action Bean can implement ValidationErrorHandler and, in the handleValidationErrors() method, decide what to do with the validation errors that occurred.
In my use case, if any field errors occurred, I want to add a global error to be displayed at the top of the page. The problem is that with the errors added to ValidationErrors at this point, it's too late, fillInValidationErrors() has already been called and the added errors don't have their beanclass property set. Using FQN.key in the resource bundle will not be found.
The interesting part of the code is in DispatcherHelper#handleValidationErrors (lines 351-376). I would add another call to fillInValidationErrors() after handleValidationErrors() (after line 366), but I'm not sure if this is the correct solution and/or whether this would have any undesirable side effects.
In the meantime, I can get my code to work by setting the beanclass on the validation error object myself, but do we want to require users to have to do this?
Please let me know what you think..
Thanks,
Freddy
Fixed in build 885.