Not that nice but it should work:

<logic:present name="org.apache.struts.action.ERROR">
<bean:define id="errors" name="org.apache.struts.action.ERROR" type="ActionErrors"/>
<logic:iterate collection="<%=errors.get()%>" type="ActionError" id="anError">
<bean:message key="<%= anError.getKey() %>" arg0="<%= (String)anError.getValues()[0] 
%>" arg1="<%=
(String)anError.getValues()[1] %>"
 arg2="<%= (String)anError.getValues()[3] %>" arg3="<%= (String)anError.getValues()[3] 
%>"/>
</logic:iterate>
</logic:present>

Jean-Noël


----- Original Message -----
From: Firmin David <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 20, 2001 12:59 PM
Subject: Manually iterating the ActionErrors object


> Hi all,
> I know something similar has been discussed on the list recently, but I
> couldn't find the answer I was looking for.
> I want to display each error on a separate table row (so I don't think I can
> use <html:errors/> straight), but I won't always know what those errors will
> be, or where they have come from (so I don't think I can use <html:errors
> property="xxx"/> either).
> By doing the following (nasty, I know), I can display a list of the *message
> keys* in the ActionErrors object....
>
> <bean:define id="errors" name="org.apache.struts.action.ERROR"
> type="ActionErrors">
>
> <logic:iterate collection="<%=errors.get()%>" type="ActionError"
> id="anError">
> <bean:write name="anError" property="key"/>
> </logic:iterate>
>
> ....although obviously I'd like the *values* to be displayed instead, (as
> the keys mean nothing to the user), but I don't know how to make this
> happen. I've tried <bean:write name="anError" property="values"/>, but
> couldn't make that work either. (I think I was doing it wrong, as I imagine
> it should)
>
> The only idea I've had is to substitute the resource keys for the values
> from the resource bundle when I initially create the ActionError object. I
> think this would have the effect of making the 'anError' bean give me the
> value thinking it was the key, if you see what I mean...
> I don't know if this would work, and I think it's too ugly to live so I
> haven't tried it.
>
> I guess the question is, "Is there a nice way of doing what I'm trying to
> do?"
>
> Any help would be gratefully received.
>
> Many thanks
>
> Kind regards
> Dave
>
> ************************************************************************
> The information in this email is confidential and is intended solely
> for the addressee(s).
> Access to this email by anyone else is unauthorised. If you are not
> an intended recipient, you must not read, use or disseminate the
> information contained in the email.
> Any views expressed in this message are those of the individual
> sender, except where the sender specifically states them to be
> the views of Capco.
>
> http://www.capco.com
> ***********************************************************************
>
>

Reply via email to