Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help me

 
Mohit Agarwal
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

Mohit.
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you call saveErrors() before forwarding ?
 
Mohit Agarwal
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Mohit
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohit - is your ActionForm extending ValidatorForm?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic