You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Prabhakar Krishnaswami <PK...@dynix.com> on 2004/06/15 20:59:07 UTC

Not able to retrieve errors

I am having a problem where I am not able to retrieve errors objects
saved in the request. I have saved the error objects as per the standard
protocol outlined in many struts textbooks:

 

              ActionError ae = new
ActionError("exception.required.field","Title");

             errArray.add(ActionErrors.GLOBAL_ERROR,ae);

             this.saveErrors(req,errArray);

             return map.findForward("copyfillinform");

 

I try to retrieve the error objects as below:

 

#if($errors.exist())

  #foreach ($e in $errors.all )

            <error>$e</error>

 

  #end

#end

 

when I print out the XML being generated, I don't see the error tag
along with the message being generated.  Is there a syntax error in
retrieving the error object?

 

Prabhakar Krishnaswami

Software Engineer

 

Dynix

pkrishnaswami@dynix.com

p 801-223-5817

f  801-223-5202

www.dynix.com
<file:///C:\Documents%20and%20Settings\PKrishna\Application%20Data\Micro
soft\Signatures\www.dynix.com> 

 


Re: Not able to retrieve errors

Posted by Nathan Bubna <na...@esha.com>.
Prabhakar Krishnaswami said:
> I am having a problem where I am not able to retrieve errors objects
> saved in the request. I have saved the error objects as per the standard
> protocol outlined in many struts textbooks:
>
>               ActionError ae = new
> ActionError("exception.required.field","Title");
>              errArray.add(ActionErrors.GLOBAL_ERROR,ae);
>              this.saveErrors(req,errArray);
>              return map.findForward("copyfillinform");
>
> I try to retrieve the error objects as below:
>
> #if($errors.exist())
>   #foreach ($e in $errors.all )
>             <error>$e</error>
>   #end
> #end
>
> when I print out the XML being generated, I don't see the error tag
> along with the message being generated.  Is there a syntax error in
> retrieving the error object?

it all looks pretty good to me.  are there any errors or warnings in the log
output?  also, what versions of VelocityTools and Struts are you using?  and
here's a few more shot in the dark questions...  are you sure the ErrorsTool
is defined in your toolbox and that your toolbox is getting loaded?  what
happens if you put the following in your template:

#set( $actionerrors =
$request.getAttribute('org.apache.struts.action.ERROR') )
ActionErrors class: $actionerrors.class.name
ActionErrors size: $actionerrors.size()
#foreach( $e in $actionerrors.get() )
ActionError key: $e.key
#end

oh, and lastly, it shouldn't be the problem, but you ought to know that
ActionError and ActionErrors.GLOBAL_ERROR are deprecated.  you should use
ActionMessage and ActionMessages.GLOBAL_MESSAGE instead.

Nathan Bubna
nathan@esha.com


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