File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes html:errors renders none of my errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:errors renders none of my errors" Watch "html:errors renders none of my errors" New topic

html:errors renders none of my errors

Roger Graham

Joined: Feb 04, 2005
Posts: 10

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

Joined: Feb 05, 2003
Posts: 4727

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.

A good workman is known by his tools.
I agree. Here's the link:
subject: html:errors renders none of my errors
It's not a secret anymore!