• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Using Javascript in Struts

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyway out to use javascript in JSP's designed in a struts framework using the tags provided by struts.
Will there not be a performance overhead if we move all our client side validations to the Action Class?
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can use javascript with struts tags. If you look at the tags you will see that they provide all the parameters that the regular HTML tags provide.
With the Validator plugin you can do both client sode as well as server side validations. The validator plugin generates the required Javascript for you.
It makes sense to have serverside validations because Javascript can be turned of on the browser. Or your client may be used in an enviroment where Javascript is not supported (Think Handhelds,cellphones,Any OS with no Javascript support,...).
I usually do basic validations on the client side like required field and numbers fall in a range. On the server side I do all the basic validations plus checking for duplicates and enforcement of other business rules.
Checking if a few strings are empty and that they fall within a particular range isn't going to overload your system
Regards
Ravi
 
Vijay Jayaraman
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for you response.Can you please elaborate to me on where to get the validator plug-in and a simple example where you have used javascript for a client side validation(for instance password not entered on the password field of a login form).
Note:
the way i am handling it at present is like i am going to my action class and validating it rather than validating for it on the client side itself.
 
Ravi Veera
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a link that will help. I have struts 1.02 running and got the validator plugin from here and installed it a few months ago.
The Validator is now a core part of the Struts 1.1b2 distribution and certain elements have changed. Unfortunately the documentation has not caught up with the changes and there is no simple how-to (yet) on how to use it.
HTH
Ravi
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic