From the documentation:

"The dynamicJavascript and staticJavascript attributes default to true, but if dynamicJavascript is set to true and staticJavascript is set to false then only the dynamic JavaScript will be rendered. If dynamicJavascript is set to false and staticJavascript is set to true then only the static JavaScript will be rendered which can then be put in separate JSP page so the browser can cache the static JavaScript."

So, you can create a 'validation.jsp' containing <html:javascript staticJavascript='true' dynamicJavascript='false'/> and reference this JSP with a <script/> tag in any JSP which uses validation -- or you can save the result of processing validation.jsp into a static file and reference that, to avoid the JSP processing for the static content.

L.

Deepa Khetan wrote:
I dint understand how to copy the static javascript on the validator.xml to
another .js file? Can u please elaborate?

On 12/10/05, Laurie Harper <[EMAIL PROTECTED]> wrote:
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]





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

Reply via email to