Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

html:errors renders none of my errors  RSS feed

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

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 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!

Marc Peabody
pie sneak
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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!