You can also do the same kind of thing that Chris suggests with Struts tags:

For your global message, uses the "messagesPresent" tag to detect if
there are errors and then output the appropriate message:

 <logic:messagesPresent>
      <bean:message key="error.title.some-fields-are-bad" />
 </logic:messagesPresent>

For your field specific messages, you can use either the
<html:messages> or <html:errors> tags to position messages next to
their fields

 http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html#section5

Niall


On 11/1/06, Christopher Schultz <[EMAIL PROTECTED]> wrote:
Robin,

> When the user submits the form with more than one fields left blank (or
> with incorrect values), I want to show a
> general (GLOBAL) message on top of the form saying
>
> "Following shown mandatory fields were provided with incorrect values"

How about putting something like this in your JSP (haven't worked with
JSP in forever, but this ought to get the point across):

<jstl:if test="$errors">
   <p class="error">
      <struts:msg key="error.title.some-fields-are-bad" />
   </p>
</jstl:if>

> b) And then I want to show a field-specific error message beside each
> input field that failed the validation rules.

Umm...

<jstl:if test="$errors.form-field-1">
    <jstl:echo value="$errors.form-field-1" />
</jstl:if>
<label for="form-field-1">Field</label>
<input id="form-field-1" name="form-field-1" ... />

etc.

Does that help?

- -chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to