Pages

Tuesday, August 2, 2011

Override Invalid value for field [fieldName] message in Struts2

The default field error message in struts 2 is Invalid field value for field "[fieldName]".

To override this message you need to create a property file with a file name pattern [ClassName].properties under the package of the Action class.



If you are getting error message like : Invalid field value for field "birthDate". You can override this by adding a line in properties file like,

             invalid.fieldvalue.birthDate = Birthdate is invalid

So now your message is : "Birthdate is invalid"

3 comments:

  1. Good research man!!!

    I m not sure about it but the last time i tried it gave message "Invalid field value for birthdate is invalid" :(, but may be because i tried in common properties file.

    ReplyDelete
  2. Thats y dude...

    We have tried this and its working.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete