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.
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.
Joined: Sep 28, 2005
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.
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.
Joined: Sep 28, 2005
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...