Michelle,

Regarding #1, you use the 'property' attribute of the ActionError to associate the error with the problematic field. In your validation code:

    if((form.getName() == null) || form.getName().equals("")) {
      // Name can't be empty. Report the problem.
      ActionErrors errors = new ActionErrors();
      errors.add("name", new ActionError("error.nameEmtpy"));
      saveErrors(request, errors);
      return new ActionMapping(mapping.getInput());
    }

In the JSP,

  <table width="75%" border="0">
    <tr>
      <td width="35%">
        <div align="left">Name:</div>
      </td>
      <td width="65%">
        <html:text property="name" />
        <html:errors property="name" />
       </td>
    </tr>
    ....


To include an image, in your resource bundle,

  error.nameEmtpy=Name cannot be empty
  errors.header=<img src="" color="red">
  errors.footer=</font>
 
--
John


At 09:56 pm 23-10-2001 -0400, you wrote:
Hi,

A couple things that I would like to do with the Struts 1.0 release relating to errors that I can't see doing without writing a bunch of extra code.

1)  When I have validation errors (ActionErrors) I would like to show an image (red arrow gif) next to the fields that are in error.
2) I would also, like to have the list of error messages to be hyperlinked so that they take the focus directly to the field in error when clicked.

Has anyone been able to do this?
Any ideas? Sample code?

Thanks,
Michelle
[EMAIL PROTECTED]

--
John Yu                       Scioworks Technologies
e: [EMAIL PROTECTED]         w: +(65) 873 5989
w: http://www.scioworks.com m: +(65) 9782 9610

Scioworks Camino - "Rapid WebApp Assembly for Struts"

Reply via email to