Announcement Announcement Module
Collapse
No announcement yet.
Error Message Codes for Validator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error Message Codes for Validator

    Im just trying to implement my first SimpleForm with Validation. Almost working but in my Validator Im adding code of the form:
    Code:
    errors.rejectValue("description",null,"This value cannot be left blank");
    errors.rejectValue("description","ERR1","This value cannot be left blank");
    This error code doesnt map to anything and although ive provided a default message it doesnt like it
    Code:
    org.springframework.context.NoSuchMessageException: No message found under code 'null.DataItem.description' for locale 'en_GB'.
    Whilst I think having error codes is an excellant idea I cant quite see what I am meant to do to set them up do I creates a MessageCoderesolver or something.
    [/code]

  • #2
    I had the same problem. If you supply an empty message.properties file, and set a messageSource, it should go away.

    I put this in the application context.

    Code:
    	<!-- Message source for this context, loaded from localized "messages_xx" files -->
    	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    		<property name="basename"><value>messages</value></property>
    	</bean>
    And then put a file called messages.properties in the classpath.

    Comment


    • #3
      Thanks, that works

      Could some point me to how to do this properly now

      Comment

      Working...
      X