Johan Compagner wrote:

> Hi,
>
> I have attached 2 html files as an example;
> Errors.html is the default one that i get when using: <form:errors/> tag in a jsp 
>file.
> and a
> Error.html is the one that i want to have.
>
> <form:errors/> has some drawbacks like:
> 1> The layout of the input screen suddenly changes.
> 2> You must link the error text and the right input field with each other.  (the 
>user must, visually)
>         In the second approace the error text is right besides the input field.
>
> You do store errors under it's property name:
>    errors.add("fromAddress", new ActionError("error.fromAddress.required"));
>
> so with that in mind there must be somthing to get one specifiek error very easy 
>without much code.
> something like this: (registration.jsp example from adress section)
>
> <tr>
>     <th align="right">
>       <bean:message key="prompt.fromAddress"/>
>     </th>
>     <td align="left">
>       <form:text property="fromAddress" size="50"/>
>     </td>
>   </tr>
>
> becomes this:
>
> <tr>
>     <th align="right">
>       <bean:message key="prompt.fromAddress"/>
>     </th>
>     <td align="left">
>       <form:text property="fromAddress" size="50"/>
> <font color=#ff0000><form:error property="fromAddress"/></font>
>     </td>
>   </tr>
>
> The ><form:error property="fromAddress"/> returns the same error string that belowns
> to that property or "" if none set.
>
> Before i code this myself i thought let's ask it before i do something twice.
>

I have implemented an <xxx:ifErrorExists> and <xxx:ifErrorMissing> tag. Here's the doc 
of these tags:


ifErrorExists - tests if a specific error exists, for a specific property

Executes its body if a specific error is found. If name is not specified, the tag 
checks if one or more
errors exist for the specified property. If name is specified, then the tag checks 
that the specific
error exists for the specified property. If not specified, the property defaults to 
the "global"
property, i.e., the tag searches for global errors, not associated with any property.

    Attribute                                          Description
                 Should be omitted in most cases. Name of the request scope bean under 
which a String[]
   errorsName    object has possibly been stored. [The value of the 
org.apache.struts.Action.ERROR_KEY
                 constant string].
      name       Name of the specific error to test.
    property     Name of the property the error is associated with.

ifErrorMissing - tests if a specific error exists

Executes its body if a specific error is not found.If name is not specified, the tag 
checks if one or
more errors exist for the specified property. If name is specified, then the tag 
checks that the specific
error exists for the specified property. If not specified, the property defaults to 
the "global"
property, i.e., the tag searches for global errors, not associated with any property.

    Attribute                                          Description
                 Should be omitted in most cases. Name of the request scope bean under 
which a String[]
   errorsName    object has possibly been stored. [The value of the 
org.apache.struts.Action.ERROR_KEY
                 constant string].
      name       Name of the specific error to test.
    property     Name of the property the error is associated with.

This allows you to put an image or a text behind a form field if there is one or more 
errors associated
with this field.
I would of course be honored if these tags were put in the struts distribution.
The code of these tags is trivial, but I can mail it to you if you want.

JB.

>
> Johan  Compagner
>
>   --------------------------------------------------------------------------------
>                                   Name: saveRegistrationErrors.html
>    saveRegistrationErrors.html    Type: Hypertext Markup Language (text/html)
>                               Encoding: 7bit
>
>                                  Name: saveRegistrationError.html
>    saveRegistrationError.html    Type: Hypertext Markup Language (text/html)
>                              Encoding: 7bit

--
Jean-Baptiste Nizet
[EMAIL PROTECTED]

R&D Engineer, S1 Belgium
Kleine Kloosterstraat, 23
B-1932 Sint-Stevens Woluwe
+32 2 200 45 42


Reply via email to