aspose file tools*
The moose likes Struts and the fly likes Validator plus my own javascript methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validator plus my own javascript methods" Watch "Validator plus my own javascript methods" New topic
Author

Validator plus my own javascript methods

Meera Godse
Greenhorn

Joined: Jan 09, 2007
Posts: 28
Hi,
How do I use struts validator and my own javascript functions at the same time ? Right now because I am using the validator for client-side validations, i write the onsubmit as "return validateFormName(this)". For the checks not included by the struts validator, how do i call my own javascript methods ? please help.
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
hi meera

you have to write the java scripts methods in the jsp

and call them on some events like onclick



regards
amir
[ April 05, 2007: Message edited by: Amirtharaj Chinnaraj ]
Meera Godse
Greenhorn

Joined: Jan 09, 2007
Posts: 28
thank you for your response.
Isnt there any other way to do it ? I want my methods to be called after all the validator methods have been called. Right at the end. For an onclick event, these methods will be called first & then the validator ones will be executed.
Is there no way, i can write both validator methods & my methods without these problems ? Validator is unable to provide my requirement , so I must write my own methods along with the validator ones.
pls help
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
well first i would like to ask you wether you

examined this sceniaro. see when you are using both

javaScript and validator framework for clentside validation

java script will be invoked first and then the validator framework

(javascript) will be invoked

so want you to examine your scenario

regards
amir
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
You can add custom javascript validation by modifying validator-rules.xml. Here is an example of it http://raibledesigns.com/rd/date/20030226 .

Make sure you also implement the back end validation rules as well and everything should work the way you want it to.
Meera Godse
Greenhorn

Joined: Jan 09, 2007
Posts: 28
I am not quite clear with the example provided. Is 'ValidationUtil' a simple class with this one method of validate fields ? Do I write my javascript methods in this class just the way I would write them down on my JSP ? Can i write multiple javascript methods here ? and how do i access the controls of JSP through this method (eg: I want to validate the array of objects. so how can i access each textbox control ?)

Just a wild thought .... can we use the validate method of the form-bean in any way, for using my own javascript methods ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validator plus my own javascript methods