This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:errors renders none of my errors

 
Roger Graham
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I maybe have a few misconceptions about Struts, please bear with me.

The Form
--------

Ok, so I have an ActionForm where I override validate(). In validate(), all I do is create an ActionErrors instance and return it at the end of the method, adding ActionError instances as I need:

ActionError err1 = new ActionError(ActionErrors.GLOBAL_ERROR, "my.key");

my.key has been defined in MessageResources.properties in WEB-INF/classes - I have 'read this in' with <message-resources property="MessageResources" in my config file.

The Action
----------

In my Action class, all I do is forward to a page which has an html:errors/ tag on it.

The Problem
-----------

No errors are rendered by the html:errors tag.


My questions are:

1. Why does this not work?
2. Should I be using saveErrors(req, errors) - does the validate="true" not save the errors in the request? If I should do this, do I do it in the validate(..) method of the form or the execute(..) method of the action?
3. I am using v1.2.4 of Struts. Do I still need to enable the Validator plug-in to enable the old mechanism to still work?

Any help greatly appreciated - thanks in advance!

Roger
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Could be any number of reasons.
2. No - it should save it for you. It isn't necessary.
3. You don't need the plugin for what you are doing.

I recommend using a debugger or inserting various System.out lines in your code to figure out what parts of your code are being entered. It might be that the validate method you wrote has the wrong parameters, causing the default validate method to run.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic