Announcement Announcement Module
Collapse
No announcement yet.
Associating error messages with fields that are map keys Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Associating error messages with fields that are map keys

    If I have a form object which has a Map, I can set map values using the syntax myMap['key'] for the field name, the question is, how can I associate an error message with this field using the Errors class (ie what would the field name be)?

    Cheers
    Daniel

  • #2
    Associating error messages with fields that are map keys

    Hello Daniel,

    to link an error message to a field held in a Map, you just have to name the field name the same way as you do in your view if you're using JSTL.

    For instance, you can use :

    Code:
    errors.rejectValue("myMap[key]", "errorMessage");
    Your command object must have the getter/setter for the 'myMap' attribute and 'key' must be valid.

    Hope this helps

    Vince

    Comment

    Working...
    X