GeekInterview.com
Series: Subject: Topic:
Question: 103 of 110

What is the difference between ActionErrors and ActionMessages

Asked by: Interview Candidate | Asked on: Mar 22nd, 2005
Showing Answers 1 - 16 of 16 Answers
Sundar

Answered On : Mar 22nd, 2005

The difference between the classes is zero -- all behavior in ActionErrors was pushed up into ActionMessages and all behavior in ActionError was pushed up into ActionMessage. This was done in the attempt to clearly signal that these classes can be used to pass any kind of messages from the controller to the view -- errors being only one kind of message

  
Login to rate this answer.
Vinay Kumar Samudrala

Answered On : Oct 4th, 2005

Hi Friends,

               ActionErrors and ActionMessages are same but in the struts-config.xml file if you are given the input in action tag and If action errors object is not empty it will goes to that input defined path.

But if your ActionMessages object is null or it contains the value it will goes to forwarded action only. ActionMessages are used to display the warnings

regards

Vinay Kumar Samudrala

Hyderabad

 

Yes  1 User has rated as useful.
  
Login to rate this answer.
bangaram

Answered On : Apr 26th, 2006

ActionMessages is the super class of ActionErrors.

Yes  1 User has rated as useful.
  
Login to rate this answer.
siva kumar reddy

Answered On : Aug 4th, 2006

 in struts 1.0  to dispaly the errors, ActionError was used but struts1.1 that feature depricated by ActionMessage tag.

it will be generated like

 

             

  •          

  •  

 main advantage of ActionMmessage tag is it does not force to write html tags in properties file .but ActionError object forces to write html tags.

cheers

siva

Yes  2 Users have rated as useful.
  
Login to rate this answer.
vijayaraja

Answered On : Apr 20th, 2007

Its a superset of ActionErrors

  
Login to rate this answer.
kamala

Answered On : Apr 22nd, 2007

There isno difference between action errors and action Messages both working for same usage that is displaying error messages to the client

  
Login to rate this answer.
sasikumar`

Answered On : May 31st, 2007

Action Message :
Encapsulate the collection of message,these messgae are global, each message specified the perticular bean property, these are contain the key, whichis refer the resourse bundle in database.

Action Error :This is a return type of the validate(),contain the collection of error messages, these messgae are reported by the validate() of the Action form
these message are global and represent the perticular bean property,

  
Login to rate this answer.
kuldeep kaushik

Answered On : Jul 13th, 2007

The ActionErrors object is basically a collection class for storing org.apache.struts.action.ActionMessage instances.

  
Login to rate this answer.
charuta

Answered On : Aug 3rd, 2007

The difference between Struts 1.1 and Struts 1.2 isDeprecation of ActionError class. (Use ActionMessage instead)

  
Login to rate this answer.
jameel khan

Answered On : Sep 1st, 2007

The difference between ActionErrors and ActionMessage is not more except that ActionError is depricated. Firstly came struts had theActionErrors, but that is the confusing because Error means only problem but while it revealed new version then gave the name is ActionMessage. In this we can give all the type of message like info message, warn messageerror message, fatal error message.

Yes  2 Users have rated as useful.
  
Login to rate this answer.
sita

Answered On : Oct 25th, 2007

There is no specific difference between action messages and action errors. Both having the same functionality, displaying the error messages.

  
Login to rate this answer.
shilpa

Answered On : Oct 25th, 2007

A class that encapsulates the error messages being reported by the validate()method of an ActionForm. A class that encapsulates messages. Messages can be either global or they are specific to a particular bean property

  
Login to rate this answer.
Amandeep

Answered On : Nov 11th, 2007

There is not much difference. Both work for reporting error messages..It is the superset of Error classes.

  
Login to rate this answer.
mytoptips

Answered On : Dec 26th, 2008

View all answers by mytoptips

PS:This is w.r.t Struts 1.3

There is no difference between ActionErrors and ActionMessages.
ActionErrors extends ActionMessages which means ActionMessages is a type of ActionErrors.
ActionErrors doesnt have any other methods other than the constructor(s).
 
  
1. RequestProcessor invokes validate() on ActionForm.
2. ActionErrors is a return type of validate() method in ActionForm.
3. If ActionErrors object is not empty, the RequestProcessor forwards to the path
   based on "input" attribute and doesnot invoke execute().
4. If ActionErrors object is empty, the execute() of Action class is invoked and
   the RequestProcessor forwards to the path specified in the "forward" of Struts-config.xml

  
Login to rate this answer.
toxicatedblood

Answered On : Oct 25th, 2009

View all answers by toxicatedblood

Hi, actually there is no difference between these two. Struts 1.1 used ActionErros and Struts 1.2 is using ActionMessages.
ActionError is being deprecated in favour of ActionMessage, unfortunately the validate method of ActionForm still returns the ActionError object, so to work around it what you can do is instead of putting the ActionErrors objects into ActionErrors, put the ActionMessage objects.

  1. ActionErrors actionErrors = new ActionErrors();  
  2.      actionErrors.add("CompanyName",new ActionMessage   
  3.                    (ErrorConstants.ERROR_REQUIRED,"Company Name"));  
  4.     actionErrors.add("Phone No"new ActionMessage  
  5.                     (ErrorConstants.ERROR_REQUIRED,"Phone No"));
ActionErrors actionErrors = new ActionErrors(); actionErrors.add("CompanyName",new ActionMessage (ErrorConstants.ERROR_REQUIRED,"Company Name")); actionErrors.add("Phone No", new ActionMessage (ErrorConstants.ERROR_REQUIRED,"Phone No")); and to access this errors in the jsp page use this code
  1.   <html:messages id="msg" message="false" >  
  2. <bean:write name="msg"/>
  3.   
  4. </html:messages>

  
Login to rate this answer.
yusaf_you

Answered On : Aug 14th, 2010

View all answers by yusaf_you

Action Errors(org.apache.struts.action.ActionErrors): A class that encapsulates the error messages being reported by the validate() method of an ActionForm. Validation errors are either global to the entire ActionForm bean they are associated with, or they are specific to a particular bean property (and, therefore, a particular input field on the corresponding form). Each individual error is described by an ActionMessage object, which contains a message key (to be looked up in an appropriate message resources database), and up to four placeholder arguments used for parametric substitution in the resulting message.

ActionMessage(org.apache.struts.action.ActionMessage): An encapsulation of an individual message returned by the validate method of an ActionForm, consisting of a message key (to be used to look up message text in an appropriate message resources database) plus up to four placeholder objects that can be used for parametric replacement in the message text

Yusaf here


  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.