< Previous | Next >

Lesson 5: Edit a form bean

Edit the form bean source file and the Java™ resource file so that they work correctly in your Struts application.

  1. In the Project Explorer, double-click the dateData form bean in the /computeDay node to open the form bean in the Java editor.
  2. In the editor, find the following line of code near the bottom of the file:
    ActionErrors errors = new ActionErrors();
  3. Immediately below this line, insert the following code:
    if (year < 1582)
    {
      errors.add("year",new org.apache.struts.action.ActionError("pre_gregorian"));
    }
  4. Save and close the DateData.java file.
  5. In the Project Explorer, navigate to the DayOfWeekJava\Resources: src\com.ibm.dayofweek.resources folder.
  6. Double-click the ApplicationResources.properties file.
  7. In ApplicationResources.properties, remove the # character from the lines that begin with errors.header and errors.footer.
  8. Add the following code to the end of the file:
    pre-gregorian=<li>Date is before 1582, the year the Gregorian calendar began</li>
    The "pre-gregorian" error text is preceded by the optional header and footer.
  9. Save and close the file.

Lesson checkpoint

In this lesson, you edited the source file of the form bean.

You learned to do these tasks:
  • Locate the source file for the form bean.
  • Edit the source code.
< Previous | Next >