What is the difference between ActionErrors and ActionMessages

Showing Answers 1 - 38 of 38 Answers

Sundar

  • 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

  Was this answer useful?  Yes

Vinay Kumar Samudrala

  • 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

 

bangaram

  • Apr 26th, 2006
 

ActionMessages is the super class of ActionErrors.

siva kumar reddy

  • 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

  <ul>

         <li>

          </li>

  </ul>

 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

vijayaraja

  • Apr 20th, 2007
 

Its a superset of ActionErrors

  Was this answer useful?  Yes

kamala

  • Apr 22nd, 2007
 

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

  Was this answer useful?  Yes

sasikumar`

  • 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,

  Was this answer useful?  Yes

kuldeep kaushik

  • Jul 13th, 2007
 

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

  Was this answer useful?  Yes

charuta

  • Aug 3rd, 2007
 

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

  Was this answer useful?  Yes

jameel khan

  • Sep 1st, 2007
 

The difference between ActionErrors and ActionMessage is not more except that ActionError is depricated. Firstly came struts had the ActionErrors, 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 message error message, fatal error message. 

sita

  • Oct 25th, 2007
 

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

  Was this answer useful?  Yes

shilpa

  • 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

  Was this answer useful?  Yes

Amandeep

  • Nov 11th, 2007
 

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

  Was this answer useful?  Yes

mytoptips

  • Dec 26th, 2008
 

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

  Was this answer useful?  Yes

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. <li><bean:write name="msg"/></li>  
  3. </html:messages>

  Was this answer useful?  Yes

yusaf_you

  • Aug 14th, 2010
 

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


  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions