Lesson 1.5: Editing a form bean

In this lesson, you will edit the form bean source file and the Java™ resource file so they work in this Struts application.

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

Lesson checkpoint

This lesson taught you to edit the form bean source file.

You learned to:
  • Locate the form bean source file.
  • Add to and edit the source code