You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nathan Coast <na...@codeczar.com> on 2003/11/13 11:19:58 UTC

ExceptionHandler to ActionError

Hi

I'd like to catch exceptions in an exception handler and then re-use the 
ActionMessage mechanism to relay messages to the failed input page.  Is this 
possible?  What do I have to do within the ExceptionHandler to invoke the 
ActionMessage mechanism?

thanks
Nathan


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


RE: ExceptionHandler to ActionError

Posted by Norm Deane <no...@vanderbilt.edu>.
Assuming you want to do this to make use of the <html:messages> tag... The
default ExceptionHandler (org.apache.struts.action.ExceptionHandler) creates
an ActionErrors object which encapsulates the error message derived from the
Exception and the ExceptionConfig.  By nature of the inheritance
relationship an ActionErrors is an ActionMessages.  Therefor you can use the
<html:messages> tag with the ActionErrors created by the ExceptionHandler.

In your page you can iterate over the ActionErrors created by the
ExceptonHandler like so...

<html:messages id="error">
   <li><c:out value="${error}" escapeXml="false"/></li>
</html:messages>

By default the "messages" tag will iterate over the ActionErrors rather than
the ActionMessages which is what you want in this case since
ExceptionHandler created and stored them as ActionErrors.

-- 
Norm Deane
MIS Consultant
Vanderbilt University
(615) 322-7855
norm.deane@vanderbilt.edu 

> -----Original Message-----
> From: Nathan Coast [mailto:nathan@codeczar.com] 
> Sent: Thursday, November 13, 2003 4:20 AM
> To: Struts Users Mailing List
> Subject: ExceptionHandler to ActionError
> 
> 
> Hi
> 
> I'd like to catch exceptions in an exception handler and then 
> re-use the 
> ActionMessage mechanism to relay messages to the failed input 
> page.  Is this 
> possible?  What do I have to do within the ExceptionHandler 
> to invoke the 
> ActionMessage mechanism?
> 
> thanks
> Nathan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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