< Previous | Next >

Lesson 1.8: Display error messages

This lesson shows you how to add the display for the error messages, so that failure messages can be returned out to input.jsp.

When using ActionErrors, you need to add the ActionErrors tag to display the error message in the input.jsp. This also requires the action mapping to be modified to include an input field.

To update the action so that it will forward any errors found in bean validation out to the input.jsp page. In the DateData class, verify that the user input year is less than year 1582, then it will return an error with the "pre-gregorian" message.

DateData class file header
Validation action mapping

Locate the "pre-gregorian" date which is defined in the ApplicationResources.properties file and verify the following information:

ApplicationResources.properties file.

To create the validation message, specify an Action Input for the action using the form bean and update the input.jsp to display the error message.

  1. Open the Web diagram.
  2. Click on the computeDay action and drag the handle to the input.jsp
    1. Select an Action Input link.
      Action input icon
      This will specify the target page for the error message that the form bean validation can return.
      Target page connections for error messages.
  3. Double click the input.jsp to open the Web page.
  4. From the palette, drag and drop the Struts HTML tag (errors tag) where you want the error message to be displayed in the Web page. This should resemble:
    Example error message placement in the input.jsp page

Lesson checkpoint

In this lesson, you learned how to update the action mapping and create the output for error messages in the input.jsp page.

You learned the following:
  • To add ActionErrors tags to display error messages in the input.jsp.
  • Modify the action mapping to include an output field.
< Previous | Next >