wood burning stoves
The moose likes Struts and the fly likes Help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help me " Watch "Help me " New topic

Help me

Mohit Agarwal
Ranch Hand

Joined: Mar 30, 2004
Posts: 88
Hi All,

I am trying to display the validation errors in my page using the htmk:errors tag . But to my utter surprise the page comes as blank.
I had set the keys in ApplicationResources.properties. Set the message resources tag in struts-config.xml which points to the location of the struts-config.xml file set the null attribute for this tag to false.

I am using struts-1.2 , tiles for the view.

Tomcat 4.1.31.

I had also provided the input for the action.

In my form-bean , i give a println() & it gives me the errors size , whatever it is.
next i give a println(mapping.getinputForward())//output for this is null.

Where are the things going wrong?

Plz. i need urgent help on this .

Thanks in advance,

Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
Do you call saveErrors() before forwarding ?

Regards,<br />Seb<br /> <br />SCJP 1.4
Mohit Agarwal
Ranch Hand

Joined: Mar 30, 2004
Posts: 88

Thanks for the reply , i am using the form-bean's validate() method did i need to save the errors there also. I mean that are the errors not available without saving them , i am pin-pointing the case of validate() method. In actions i know that we need to save the errros.

Also can u tell me what does the id attribute means in <html:messages>tag?

Thanks a ton in advance.

Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
I'm not sure to understand... When are you calling validate() on your bean ?

To display errors using <html:errors> , the bean wich contains your errors must be in the request scope. (under name Globals.ERROR_KEY by default).

The id attribute is for identifying the page scope bean which will contain the current message while iterating over your messages collection.

For example :

You can replace "msg" with what you like...
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

Seb, I'm afraid you may be confusing Mohit more than helping. Seb, it seems that you have not used Struts' built in validation mechanisms and you are used to setting the validations from the Action classes. What Mohit is doing is a part of Struts and it should work fine.

Mohit, you at first said you were using the html:errors tag but now you are asking about the html:messages tag. Please post for us two things so I can assist you:
1) Post how you are creating the individual errors... such as:
errors.add("myMessage", new ActionError("myError"));
2) Post your html:errors tag exactly as you are using it in the jsp.

A good workman is known by his tools.
Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
You're right, Mark, I did not remember there were a validate attribute for actions... (I set it to false everytime since I call validate() from my actions, for some praticals reasons.)

Mohit, as Mark says, it will be fine if you would post your parts of code and struts-conf...
Aash Patel

Joined: Sep 14, 2005
Posts: 24
Mohit - is your ActionForm extending ValidatorForm?
I agree. Here's the link: http://aspose.com/file-tools
subject: Help me
It's not a secret anymore!