Tutorials > Program model > Use Struts tags, action forms, and validation

< Previous | Next >


Add custom messages to the consumer direct store error message properties

In this step, we will add the Validator default error messages, the own custom error messages, as well as some general error message display information to the consumer direct store error message properties files.


Procedure

  1. In the Enterprise Explorer view, expand Stores > Java Resources > Java Source > ConsumerDirect_name.

  2. Double-click the storeErrorMessages_en_US.properties file to open it for editing.

  3. Observe the entry for the _ERR_CMD_INVALID_PARAM.5210 key that you have referenced in the mapping for the email field in the validation.xml file.

  4. Copy the Struts Validator default error messages from the introductory comment in the validator-rules.xml file, which you should have open for editing, to the bottom of the file:

    # Struts Validator Error Messages 
    errors.required={0} is required. 
    errors.minlength={0} can not be less than {1} characters. 
    errors.maxlength={0} can not be greater than {1} characters. 
    errors.invalid={0} is invalid. 
    
    errors.byte={0} must be a byte. 
    errors.short={0} must be a short. 
    errors.integer={0} must be an integer. 
    errors.long={0} must be a long. 
    errors.float={0} must be a float. 
    errors.double={0} must be a double. 
    
    errors.date={0} is not a date. 
    errors.range={0} is not in the range {1} through {2}. 
    errors.creditcard={0} is an invalid credit card number. 
    errors.email={0} is an invalid e-mail address. 
    

  5. Copy the following snippet to the bottom of the file to define the additional error messages you have referenced in the validation.xml file:

    # MyContactUsDisplay.jsp Validator error messages
    My_CONTACT_US_name.required=Type the name in the Name field.
    My_CONTACT_US_email.email=Type a valid e-mail address in the E-mail
    address field.
    My_CONTACT_US_comment.required=Type a comment in the Comment field.
    
    

  6. Copy the following snippet to the bottom of the file to configure how the error messages will be displayed in the JSP page:

    # Struts error tag messages
    errors.header=<font color="red">Validation errors:</font><ul>
    errors.footer=</ul>
    errors.prefix=<li>
    errors.suffix=</li>
    

  7. Save the changes.

  8. Copy the changes to the storeErrorMessages.properties file.

< Previous | Next >


+

Search Tips   |   Advanced Search