struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos Pita" <cp...@tycdigital.com>
Subject Re: Some proposals
Date Wed, 07 Mar 2001 15:28:16 GMT
Hi!

    The constant is named Action.ERROR_KEY, and under it you can find the
entire ActionErrors instance. So if you have to show individual errors (or
lists of errors) under keys, you will find yourself dealing with code like:

<bean:define id="errors" name="<%=Action.ERROR_KEY%>" scope="request"
type="ActionErrors"/>

<% if(errors!=null && errors.size("firstName")>0) { %>
<tr bgcolor="#FFCCCC" align="center" valign="middle" bordercolor="#FFCCCC">
<td colspan="2" height="31" class="arial9-pad6l-red" align="left">Error:
<struts:errors property="firstName"/></td>
</tr>
<% } %>

    This seems to me far from ideal and it's based on the supossition that
there will be only one error under each key. And if all that you want to do
is to list the entire collection of errors, you still should put the
presentational content related to individual items (the <tr><td> o <li>
stuff, if you are lucky) in the resources file.
    If I am too wrong and there is a really better way to get the same
results, please stop me.

See you,
    Carlos


----- Original Message -----
From: "Nick Pellow" <nick@cortexebusiness.com.au>
To: <struts-dev@jakarta.apache.org>
Sent: Wednesday, March 07, 2001 1:13 AM
Subject: Re: Some proposals


>
>
> Carlos Pita wrote:
> >
> >     5) The errors tag should be more capable of controlling the
presentation
> > of its output. I think it's a very dirty solution to write html in the
> > application resources file. The examples someway hide this, showing
property
> > values like: "<li>Invalid format for From Address</li>", but real
> > applications would have an important percentage of html (or some kind of
> > presentational information) embedded in the resources file. This is not
> > easily mantenible and internationalization support would be very
cumbersome
> > to achieve in this scenario (having to update several files and lot of
items
> > in these files with duplicated information about  presentation). I
suggest
> > that the errors tag should let the programmer to specify some kind of
> > formatting content, preferently as the content of the tag and inside
> > sections like
> > <start-of-item>,<end-of-item>,<start-of-list>,<end-of-list>,<no-errors>,
> > etc. (by the way, this would be very useful with any iterator tag;
perhaps
> > we should have to subclass from some basic iterator tag class, or to
have
> > some kind of hierarchy here, but I've not seen the current code so I
could
> > not say any more about this).
>
> You can do this:
> (Please correct me if there is a better way)
>
> <logic:present parameter="org.apache.struts.action.ERROR">  (parameter,
> even though "org.apache.struts.action.ERROR" is an attribute?)
>   ... all the html you want here
>    <html:errors/>
>   ... and here
> </logic:present>
>
> <logic:notPresent parameter="org.apache.struts.action.ERROR">
> Display this otherwise.
> </logic:notPresent>
>
>
>
> I would like to a write two tags however, that look like the following:
>
> <html:inError>
>     <html:errors/>
> </html:inError>
>
> <html:notInError>
>
>    Display this otherwise
>
> </html:notInError>
>
> Any objections to the above suggestion?
>
>
> Cheers,
> Nick
>
>
> >     Well, I think this is all for now. I've thought some solutions for
each
> > of the enumerated problems, but I would like to hear your oppinion about
> > these being real problems before explaining or discussing them.
> >
> > See you,
> >     Carlos
> >
> > Ah... sorry if my English is not the best
>



Mime
View raw message