|
|||||||||||||||||||||
|
JSP Tags
Javascript Validator TagJavascript is generated to match the validation that is performed server side if the JavascriptValidatorTag is set correctly and the form onSubmit value must be added manually. The pluggable validator must have a Javascript validation method specified for its javascript. When the tag is generating the client side Javascript generation, it looks for a value in the
validator's javascript attribute and generates an object for each pluggable validator that
the supplied method can use to validate the form. The Javascript object is named after the
validator's name attribute. Currently a simple sort is performed to create the
order that the different Javascript validation methods are called in and they are each joined by the logical
AND (&&). The Javascript object's variable that corresponds to a field on the form is an Array. The first element
is the name of the field, the second element is the internationalized error message with correct parameter
replacements, and the third element is a Javascript Function object that has all of the variables associated
with this field. Below is pseudo Javascript code to show how to loop through the auto-generated Javascript
object and retrieve a variable value. Have a Submit Button in a Form not Perform ValidationIf you want to turn off the validation for a specific submit button like the html:cancel tag, you can set the bCancel variable to true for the JavaScript validation not to execute and bCancel to false for it to execute.<html:submit onclick="bCancel=false;"> <bean:message key="button.save"/> </html:submit> <html:cancel onclick="bCancel=true;"> <bean:message key="button.cancel"/> </html:cancel> Creating a Separate Page for Static JavaScriptIf you want to just generate the dynamic JavaScript on you form page and have a separate page
with the static JavaScript to take advantage of browser caching you can use the
dynamicJavascript and staticJavascript attributes to the JavascriptValidatorTag. You can turn
each attribute's generation of JavaScript on and off by putting in true or false
(they default to true). Reference jsType.jsp and staticJavascript.jsp in the main
example webapp for a working example. |