Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionErrors

 
Geethanandh Kandasamy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic