struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <ahardy.str...@cyberspaceroad.com>
Subject Re: Action Messages
Date Sat, 28 May 2005 15:05:14 GMT
Ray,
it's not clear what you are trying to do that is different from 
standard. Struts puts the ActionErrors in the request by default. The 
Messages too.

I used to know this inside out but it's been a year or so... but I think 
the key is like this:

request.getAttribute(org.apache.struts.Globals.MESSAGE_KEY);
request.getAttribute(org.apache.struts.Globals.ERROR_KEY);




On 27/05/05 19:46&nbsp;Ray Madigan wrote:
> I am looking for the ability to handle the ActionMessage in a different way
> in my application.  In the validate method of the form I create a new
> instance of ActionErrors and add ActionMessage instances to it.  In the
> Action dispatch method I call validate and get a non empty ActionErrors
> instance.  To figure how to make this work, I can get the iterator to the
> keys and copy it to the request attribute like
> 
> Iterator iter = errors.properties ( );
> request.setAttribute ( "ERRORS", errors );
> 
> but I can't get the messages associated with the property to allow me to
> manipulate my page.
> 
> What I would like is:
> 
> for ActionErrors to be a collection, the I could iterate on the errors and
> get the key and the values.  I could iterate on the values, or reteive a
> specific one.
> 
> I want the ability to inspect an error condition and if it exists or not and
> generate jsp accordingly with an error message.
> 
> Does anyone know how to do this?
> 
> it would look like, but I dream too much
> 
> <c:choose>
> <c:when test='${ not empty ERROR.confirmMatch }'>
>     <c:forEach var='message' items='${ERROR.confirmMatch}'>
>         <tr><td><fmt:message key='${message}'/></td></tr>
>         <!--  Generate specific code -->
>     </c:forEach>
> </c:when>
> <c:otherwise>
>         <!-- Generate specific code -->
> </c:otherwise>
> </c:choose>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message