struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Métras <gen...@sympatico.ca>
Subject Re: Re[2]: An enhancement for <struts:errors>?
Date Thu, 21 Sep 2000 16:44:42 GMT
I advocated for such a mechanism two months ago. Dont't forget to allow
parameters substitution in the message text...

In code:

ErrorMessages errors = new ErrorMessages();

errors.addError( "form.percentIncrease", "outOfRange", "1", "99" );

Would print "percentage must be in the range [1, 99]" or "le pourcentage
doit se situer dans l'intervalle [1, 99]"...

Pierre Métras

----- Original Message -----
From: "Joe Walnes" <joe@wirestation.co.uk>
To: <struts-user@jakarta.apache.org>; "Oleg V Alexeev" <gonza@penza.net>
Sent: Thursday, September 21, 2000 12:24 PM
Subject: RE: Re[2]: An enhancement for <struts:errors>?


> Yes. That would also allow you to place error msgs in relevent places too
> (ie: next to the field they are associate with), thereby creating a much
> more intuitive interface for the end user.
>
> -Joe Walnes
>
>
>
> -----Original Message-----
> From: Oleg V Alexeev [mailto:gonza@penza.net]
> Sent: 21 September 2000 17:13
> To: Joe Walnes
> Subject: Re[2]: An enhancement for <struts:errors>?
>
>
> Error processing can be more flexible when error message would be
> broken to part of error 'source' and part of error 'message'.
>
> In code:
>
>  ErrorMessages errors = new ErrorMessages();
>
>  errors.addError( "form.fieldname1", "not.filled" );
>  errors.addError( "form.fieldname2", "not.filled" );
>                       ^                   ^
>                    source              message
>
> In resources:
>
> form.fieldname1=Name of anything
> form.fieldname2=Description of anything
> not.filled=Fill this field, please
>
> In *.jsp
>
> <logic:present name="errors">
>  <b><struts:message key="errorHeader" /></b><br>
>   <table>
>    <logic:iterate id="currentError" name="errors">
>     <tr>
>      <td><bean:write name="currentError" property="source" /></td>
>      <td><bean:write name="currentError" property="message" /></td>
>     </tr>
>    </logic:iterate>
>   </table>
> </logic:present>
>
> JW> This makes a lot more sense. There would also have to be a conditional
> block
> JW> as well, so error headers/footers would only be displayed if there are
> JW> actually errors.
>
> JW> ie:
>
> JW> <struts:errorsPresent>
> JW>         <b><struts:message key="errorHeader" /></b>
> JW>         <ul>
> JW>                 <struts:listErrors>
> JW>                         <li><struts:errorMsg /></li>
> JW>                 </struts:listErrors>
> JW>         </ul>
> JW> </struts:errorsPresent>
>
> JW> Hmm... all those tags look familiar. <struts:errorPresent> looks like
> JW> <logic:present>, <struts:listErrors> looks like <logic:iterate>
and
> JW> <struts:errorMsg> looks like <struts:message>.
>
> JW> If the errors were exposed to page as a bean, and the <struts:message>
> tag
> JW> could accept dynamic keys, very flexible error messages could be
> generated
> JW> like:
>
> JW> <logic:present name="errors">
> JW>         <b><struts:message key="errorHeader" /></b>
> JW>         <ul>
> JW>                 <logic:iterate id="currentError" name="errors">
> JW>                         <li><struts:message name="currentError"
/></li>
> JW>                 </logic:iterate>
> JW>         </ul>
> JW> </logic:present>
>
> JW> Is an error tag needed at all? For convenience it's very useful, but
the
> JW> other tags provide a much more flexible means for displaying errors.
>
> JW> -Joe Walnes
>
>
> JW> -----Original Message-----
> JW> From: Chris Miller [mailto:kiwi@vardus.com]
> JW> Sent: 21 September 2000 07:53
> JW> To: struts-user@jakarta.apache.org
> JW> Subject: Re: An enhancement for <struts:errors>?
>
>
> JW> Even better than that would be to write a <struts:listErrors> tag that
> would
> JW> iterate over the errors.
> JW> That way any arbitrary formatting could be applied, on a case-by-case
> basis
> JW> if so desired. Also, it would be nice to remove the HTML from the
> properties
> JW> file - I really don't think it belongs in there.
>
> JW> eg.
>
> JW> <struts:listErrors error="error" count="count">
> JW>   <font color="red"><%= error %></font><br>
> JW> </struts:listErrrors>
> JW> <% if (count > 0) { %>
> JW>   <p/>Please correct the above problems before continuing
> JW> <% } %>
>
> JW> The above code would problably be put in a separate file and included
> using
> JW> <struts:include>.
>
> JW> What do you think?
>
>
> JW> ----- Original Message -----
> JW> From: "Martin Cooper" <martin.cooper@tumbleweed.com>
> JW> To: <struts-user@jakarta.apache.org>
> JW> Sent: Thursday, September 21, 2000 5:27 AM
> JW> Subject: An enhancement for <struts:errors>?
>
>
> >> Right now, if there are multiple error messages to be output by the
> >> <struts:errors> tag, they will be separated by newlines. This means
they
> >> effectively run together when displayed in an HTML page. Unless I'm
> JW> missing
> >> something, any formatting has to be included within the messages
> JW> themselves.
> >>
> >> What about extending ErrorsTag to use an errors.format value as well as
> >> errors.header and errors.footer, where this string would be used with
> >> MessageFormat? This would allow much more control over the
presentation.
> JW> For
> >> example, with the following values:
> >>
> >> errors.header="<table>"
> >> errors.format="<tr><td>{0}</td></tr>"
> >> errors.footer="</table>"
> >>
> >> the errors would be displayed as a table, one row per error message.
> >>
> >> --
> >> Martin Cooper
> >> Tumbleweed Communications
> >>
> >>
> >>
> >>
>
>
>
> --
> Best regards,
>  Oleg                            mailto:gonza@penza.net
>
>
>


Mime
View raw message