• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Validator plus my own javascript methods

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic