• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
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.
 
Author and ninkuma
Marshal
Posts: 66787
168
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.
 
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...
 
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!