Announcement Announcement Module
Collapse
No announcement yet.
How to set a prefix on validation messages Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to set a prefix on validation messages

    Hi,

    I want to use the setPrefix(String prefix) method of DefaultMessageCodesResolver to set a different prefix when each of my different forms is being validated.

    Where do I get the instance of DefaultMessageCodesResolver from?
    I have tried getting it in my form handler like so:

    Code:
    protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors)
         		throws Exception {
        	DefaultMessageCodesResolver resolver = (DefaultMessageCodesResolver) this.getMessageCodesResolver();
        	resolver.setPrefix("editProduct.");
        }
    But this throws a Null pointer exception (presumably because the MessageCodesResolver has not been instanciated at this point).

    Any help would be greatly appreciated.
    Thanks.
Working...
X