Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display validation message as an alert in jsp which uses struts 2 validation.xml

 
vydehi vajanapally
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a validation xml and i mentioned those error messages in package.resources.

Now I want to display those error messages(when i click on submit button) as java script alerts on the page.

Please help me how to merge javascript function with the struts validation messages.

and how/when to call this alert message with code.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Prakash Mani - Attur
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use <html:javascript> tag and add an attribute(i forgot the name) which contains validateUrFormname(this) to the form element... this will generate the script from the commons validator based on the rule you have specified in the validation.xml...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or use the Struts 2 client side validation (Prakash's answer is for Struts 1). Note that not all validations are supported on the client side out-of-the-box.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic