• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validate() Method in action form

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inside the function, you can do this:

Nick
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another solution:

You can using <html:errors/> tag in jsp page to display errors.
 
shaggy lype
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
shaggy lype
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Praveen. It sure did help me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic