aspose file tools*
The moose likes Struts and the fly likes Action Form - ERROR_KEY & saveErrors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action Form - ERROR_KEY & saveErrors" Watch "Action Form - ERROR_KEY & saveErrors" New topic
Author

Action Form - ERROR_KEY & saveErrors

satish pune
Ranch Hand

Joined: Sep 04, 2003
Posts: 44
Could someone please explain the significance of thie variable
" ERROR_KEY " in the Struts Action class ?
How can I make use of it ?
Also I was wondering what the use of the method "saveErrors" is ?
Do I need to implement this method in my action class ?
Thanks in advance ,
-satish
[ September 05, 2003: Message edited by: satish pune ]
[ September 05, 2003: Message edited by: satish pune ]
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by satish pune:
Could someone please explain the significance of thie variable
" ERROR_KEY " in the Struts Action class ?
How can I make use of it ?
Also I was wondering what the use of the method "saveErrors" is ?
Do I need to implement this method in my action class ?
Thanks in advance ,
-satish

This is my understanding,
Even though you have created the ActionErrors instance and populated it with ActionError objects, it needs to be available in the request for later retreival. This is what saveErrors(request,errors) does, it stores the errors in the http request object under the key Globals.ERROR_KEY.
You dont have to implement it since org.apache.struts.action.Action from which your Action class extends already does it.
If you do request.getAttribute(Globals.ERROR_KEY) in the resource you have forwarded to, you s'd be able to get an ActionErrors instance if an error had actually occured and you had stored it in the request object.
If you are forwarding to a JSP, you dont have to make use of Globals.ERROR_KEY, use html:errors tag instead. By default it looks up the request using the Globals.ERROR_KEY key.
Am not sure how to store the errors under a differnt key though. :roll:
Yes you can defintely do a request.setAttribute("some-other-error-key",errors) in your action class. I dont know how to make saveErrors() store the errors under a different key though.

If am wrong please somebody correct me.
satish pune
Ranch Hand

Joined: Sep 04, 2003
Posts: 44
thanks karthik
that was helpful
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action Form - ERROR_KEY & saveErrors