aspose file tools*
The moose likes Struts and the fly likes How to acess ActionErrors in Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to acess ActionErrors in Action" Watch "How to acess ActionErrors in Action" New topic
Author

How to acess ActionErrors in Action

vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
Hello All,

I am bit confused with action errors;
see AcrionErrors generally prepared by validate method,and in validate method i don't want to put any database check-up,for a case if user logs in to system and validate method passes all check like required,minlength etc.
but for existance in to data base i have to check in the action and if user not found then i have to prepare actionerrors.
so the question is how can i prepare actionerrors in action ?
i am using 1.2.9 version (with netbeans 5.5)
and if some one is thinking that solution is as bellow


ActionErrors ae = new ActionErrors( );
ae.add("userId", new ActionError("error.invalid.login"));
request.setAttribute(Action.ERROR_KEY, ae);


it is not working , i think Action.ERROR_KEY is not present there.
can any one help me ?


Thanks
Vijay Saraf.
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
ya i myself found that key its Globals.ERROR_KEY.now working fine...
raj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 96
hi vijay , all

great for sharing the information with all.
i would like to know how to display the error massages .
you stored the ActionErrors Object in request.

do we need to display in jsp. or the server will display.
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
<html:errors/> should do the trick.
raj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 96
hi dom,
Thank you for reply.
i understood your reply. but i would like to know how the errors will
display when an error occur in action class.

please be some more specific.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to acess ActionErrors in Action
 
Similar Threads
JSP Reload without loosing values
validate to check errors on jsp
Behaviour on failure of validate in form bean
ActionErrors (Struts)
Getting values from properties in validate-using multiple message-resources in struts