aspose file tools*
The moose likes Struts and the fly likes display validation message as an alert in jsp which uses struts 2 validation.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "display validation message as an alert in jsp which uses struts 2 validation.xml" Watch "display validation message as an alert in jsp which uses struts 2 validation.xml" New topic
Author

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

vydehi vajanapally
Greenhorn

Joined: Mar 02, 2009
Posts: 9
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

Joined: Jan 10, 2002
Posts: 61426
    
  67

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Prakash Mani - Attur
Ranch Hand

Joined: Oct 08, 2009
Posts: 100
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display validation message as an alert in jsp which uses struts 2 validation.xml