Search code examples
javavalidationstruts2resourcebundleognl

${getText(fieldName)} shows nothing in client validation


I have implemented client side validation mechanism using Struts2 framework, but when an error occurred ${getText(fieldName)} variable present in properties file appears empty, for example, it appears "The field is required" instead of "The field username is required"

I have this in properties file:

errors.required=Field ${getText(fieldName)} is required.

Solution

  • Just define the key value pare in the properties file

    username=username
    

    assumed that username is a fieldName in the -validation.xml