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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionErrors" Watch "ActionErrors" New topic


Geethanandh Kandasamy

Joined: Sep 28, 2004
Posts: 5
In my validate method of a class that extends ActionForm i am adding messages to actionerrors like this

errors.add("capacityerror", new ActionMessage("location.capacity"));

When i use <html:errors /> in the jsp input page i am getting the errors, but when i use the following code snippet its not displaying the errors

<logic:messagesPresent message="true">
<html:messages id="message" message="true" property="capacityerror">
<b><c ut value="${message}" /></b>

what am i missing here??

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The validate() method of a form returns a value of type ActionErrors. The contract of the validate() method is that if you find an error, you will instantiate either an ActionError or ActionMessage object, and add it to the ActionErrors object using the add() method. ActionError objects are displayed using the <html:errors/> tag, not the <html:messages/> tag.

The <html:messages /> tag will display an ActionMessages object that you have put in the request using the saveMessages() method in the Action superclass.

Even in your <html:messages/> tag, you are working way too hard. All you have to do is place the tag where you want the messages, and they will display if they are present, and won't display if they aren't.

Consultant, Sima Solutions
I agree. Here's the link:
subject: ActionErrors
Similar Threads
ActionMessages causing me great distress
ActionMessages in STRUTS 1.1 Please help !!!
Using ActionMessages to display Errors using errors.headers and errors.footers
Message Resource problem.