| Author |
validate() Method in action form
|
shaggy lype
Greenhorn
Joined: Apr 02, 2004
Posts: 21
|
|
Hi, I am implementing struts validator in my application and using struts 1.1. I am trying to validate certain conditions in the validate() method of the struts action form. How can we display errors generated for a particular text field beside that field in the JSP? I would really appreciate your help in this regard. shaggy
|
 |
Nicholas Cheung
Ranch Hand
Joined: Nov 07, 2003
Posts: 4982
|
|
Inside the function, you can do this: Nick
|
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
|
 |
Surasak Leenapongpanit
Ranch Hand
Joined: May 10, 2002
Posts: 341
|
|
Another solution: You can using <html:errors/> tag in jsp page to display errors.
|
 |
shaggy lype
Greenhorn
Joined: Apr 02, 2004
Posts: 21
|
|
Hi, Thank you for your reply, but i guess my question has not been interpreted correctly. My problem is that suppose there are 3 text fields in a page say textfield1, textfield2 and textfield3. Then in the validate method of the action form, i do some checks and if there are any errors generated say by textfield1, how would i display the error for that field beside textfield1 in the jsp. In a similar way suppose textfield2 fails the validations, how could i display the error related to textfield2 beside it. The same for textfield3 and so on. I hope i was able to present my question much clearly this time. I would really appreciate any suggestions to tackle this. thanks shaggy
|
 |
Praveen Teegala
Greenhorn
Joined: Apr 03, 2004
Posts: 11
|
|
Where ever you want to display the error message in JSP, add the code like this, <html:messages id="errorx" property="Error1"> <bean:write name="errorx"/> </html:messages> where "Error1" is the error that you have added in the validation method. Hope this helps. Praveen.
|
Praveen
|
 |
shaggy lype
Greenhorn
Joined: Apr 02, 2004
Posts: 21
|
|
|
Thank you Praveen. It sure did help me.
|
 |
 |
|
|
subject: validate() Method in action form
|
|
|