Tony Santinello wrote:
Hi,

I'm using Struts 1.2.7 and I'm using commons-validator
to validate my forms.  Can someone tell me why
validator includes all the javascript functions when
rendering the jsp page?
Even including javascript functions that I'm not using
in validation.xml, such as creditcard validation or
integer validation?

Is there anyway to include just the javascript my jsp
needs and not all the extra javascript?

There's two types of Javascript emitted by the validator framework: static and dynamic. The static script includes all the code that doesn't vary from form to form, whereas the dynamic stuff is dependent on the validations you've configured for the form.

The html:javascript, by default, emits all the static code every time and generates additional dynamic code appropriate to the form. You can tell it not to emit the static Javascript at all (in which case you need to include it elsewhere on the page, directly or by reference), but you can't tell it to emit only a sub-set of the static code.

Your best bet is to copy the static Javascript into a seperate .js file, include that in the head of your page, and turn it off in the html:javascript tag. Browser caching will then avoid the user having to download the static code everytime, which is one step better than inlining a sub-set of it.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to