Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionErrors" Watch "ActionErrors" New topic
Author

ActionErrors

Geethanandh Kandasamy
Greenhorn

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>
</html:messages>
</logic:messagesPresent>

what am i missing here??


Thanks
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.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionErrors