< 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 Enterprise 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:
    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 Enterprise Explorer, double-click DayOfWeek\JavaResources: src\com.ibm.dayofweek.resources\ApplicationResources.properties to open it.
  6. In ApplicationResources.properties, remove the # character from the lines that begin with errors.header and errors.footer.
  7. 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.
  8. 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 >

Feedback