<html> | |
<head> | |
<title>VelocityStruts - ValidatorTool</title> | |
<meta name="author" value="Marino A. Jonsson"/> | |
<meta name="email" value="marino@apache.org" /> | |
</head> | |
<body bgcolor="#ffffff" text="#000000" link="#525D76" | |
alink="#525D76" vlink="#525D76"> | |
<table border="0" width="100%" cellspacing="4"> | |
<tr><td colspan="2"> | |
<a href="http://jakarta.apache.org/"> | |
<img src="http://jakarta.apache.org/images/jakarta-logo.gif" | |
align="left" alt="The Jakarta Project" border="0"/> | |
</a> | |
<a href="index.html"> | |
<img src="../images/velocitystruts.png" align="right" alt="< Velocity Tools - Struts >" border="0"/> | |
</a> | |
</td></tr> | |
<tr> | |
<td colspan="2"> | |
<hr noshade="" size="1"/> | |
</td> | |
</tr> | |
<tr> | |
<td width="20%" valign="top" nowrap="true"> | |
<p><strong><a href="../">Velocity Tools</a></strong></p> | |
<p> | |
<strong>VelocityStruts</strong> | |
</p> | |
<ul> | |
<li><a href="index.html">Overview</a></li> | |
<li><a href="index.html#Benefits">Benefits</a></li> | |
<li><a href="../index.html#Download">Download</a></li> | |
<li><a href="userguide.html">User Guide</a></li> | |
<li><a href="userguide.html#Installation">Installation</a></li> | |
<li><a href="../index.html#Example Applications">Examples</a></li> | |
<li><a href="../javadoc/index.html">Javadoc</a></li> | |
</ul> | |
<p> | |
<a href="StrutsTools.html"><strong>VelocityStruts Tools</strong></a> | |
</p> | |
<ul> | |
<li><a href="ActionMessagesTool.html">ActionMessagesTool</a></li> | |
<li><a href="ErrorsTool.html">ErrorsTool</a></li> | |
<li><a href="FormTool.html">FormTool</a></li> | |
<li><a href="MessageTool.html">MessageTool</a></li> | |
<li><a href="StrutsLinkTool.html">StrutsLinkTool</a></li> | |
<li><a href="SecureLinkTool.html">SecureLinkTool</a></li> | |
<li><a href="TilesTool.html">TilesTool</a></li> | |
<li><a href="ValidatorTool.html">ValidatorTool</a></li> | |
</ul> | |
<p> | |
<strong>Other Subprojects</strong> | |
</p> | |
<ul> | |
<li><a href="../generic/">GenericTools</a></li> | |
<li><a href="../view/">VelocityView</a></li> | |
</ul> | |
<p> | |
</p> | |
</td> | |
<!-- RIGHT SIDE MAIN BODY --> | |
<td colspan="1" valign="top" align="left"> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="ValidatorTool Reference Documentation"> | |
<strong>ValidatorTool Reference Documentation</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
The ValidatorTool is used to interact with the Validator framework to generate | |
dynamic javascript for form validation. | |
</p> | |
<table cellpadding="0" cellspacing="0"> | |
<tr><td colspan="2"><strong>Class</strong></td></tr> | |
<tr><td> </td><td>org.apache.velocity.tools.struts.ValidatorTool</td></tr> | |
<tr><td colspan="2"><strong>Name</strong></td></tr> | |
<tr><td> </td><td>$validator (this is the recommended name of the tool in | |
the Velocity context)</td></tr> | |
<tr><td colspan="2"><strong>Toolbox Configuration Example</strong></td></tr> | |
<tr><td> </td><td><pre><tool> | |
<key>validator</key> | |
<scope>request</scope> | |
<class>org.apache.velocity.tools.struts.ValidatorTool</class> | |
</tool></pre></td></tr> | |
<tr><td colspan="2"><strong>Author(s)</strong></td></tr> | |
<tr><td> </td><td><a href="mailto:marinoj@centrum.is">Marino A. Jonsson</a><br></td></tr> | |
</table> | |
<dl> | |
<dt><strong>Method Overview</strong></dt> | |
<dd> | |
<table cellpadding="2" cellspacing="2" border="0"> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getPage()">getPage()</a></td> | |
<td bgcolor="EEEEEE"> | |
Gets the current page number of a multi-part form. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#setPage()">setPage()</a></td> | |
<td bgcolor="EEEEEE"> | |
Sets the current page number of a multi-part form. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getMethod()">getMethod()</a></td> | |
<td bgcolor="EEEEEE"> | |
Gets the method name that will be used for the javascript | |
validation method name if it has a value. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#setMethod()">setMethod()</a></td> | |
<td bgcolor="EEEEEE"> | |
Sets the method name that will be used for the javascript | |
validation method name if it has a value. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getHtmlComment()">getHtmlComment()</a></td> | |
<td bgcolor="EEEEEE"> | |
Gets whether or not to delimit the javascript with html comments. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#setHtmlComment()">setHtmlComment()</a></td> | |
<td bgcolor="EEEEEE"> | |
Sets whether or not to delimit the javascript with html comments. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getSrc()">getSrc()</a></td> | |
<td bgcolor="EEEEEE"> | |
Gets the src attribute's value when defining the html script element. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#setSrc()">setSrc()</a></td> | |
<td bgcolor="EEEEEE"> | |
Sets the src attribute's value (used to include | |
an external script resource) when defining | |
the html script element. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getCdata()">getCdata()</a></td> | |
<td bgcolor="EEEEEE"> | |
Returns the cdata setting "true" or "false". | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#setCdata()">setCdata()</a></td> | |
<td bgcolor="EEEEEE"> | |
Sets the cdata status. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getJavascript()">getJavascript()</a></td> | |
<td bgcolor="EEEEEE"> | |
Generates javascript to perform validations on a struts-defined | |
form. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getDynamicJavascript()">getDynamicJavascript()</a></td> | |
<td bgcolor="EEEEEE"> | |
Generates the dynamic javascript methods to perform validation | |
on a struts-defined form. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getStaticJavascript()">getStaticJavascript()</a></td> | |
<td bgcolor="EEEEEE"> | |
Generates all the static javascript methods from validator-rules.xml. | |
</td> | |
</tr> | |
</table> | |
</dd> | |
</dl> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getPage()"> | |
<strong>getPage()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Gets the current page number of a multi-part form. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
int getPage() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p>Gets the current page number of a multi-part form. | |
Only field validations with a matching page number | |
will be generated that match the current page number.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="setPage()"> | |
<strong>setPage()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Sets the current page number of a multi-part form. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
void setPage(int page) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>page</dt> | |
<dd> | |
<parameter name="page"> | |
the current page number of a multi-part form. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Sets the current page number of a multi-part form. | |
Only field validations with a matching page number | |
will be generated that match the current page number.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getMethod()"> | |
<strong>getMethod()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Gets the method name that will be used for the javascript | |
validation method name if it has a value. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
String getMethod() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p>Gets the method name that will be used for the javascript | |
validation method name if it has a value. This overrides | |
the auto-generated method name based on the key (form name) | |
passed in.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="setMethod()"> | |
<strong>setMethod()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Sets the method name that will be used for the javascript | |
validation method name if it has a value. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
void setMethod(String methodName) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>methodName</dt> | |
<dd> | |
<parameter name="methodName"> | |
the method name that will be used for the javascript validation | |
method name. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Sets the method name that will be used for the javascript | |
validation method name if it has a value. This overrides | |
the auto-generated method name based on the key (form name) | |
passed in.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getHtmlComment()"> | |
<strong>getHtmlComment()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Gets whether or not to delimit the javascript with html comments. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
boolean getHtmlComment() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p>Gets whether or not to delimit the | |
javascript with html comments. If this is set to 'true', which | |
is the default, html comments will surround the javascript.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="setHtmlComment()"> | |
<strong>setHtmlComment()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Sets whether or not to delimit the javascript with html comments. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
void setHtmlComment(boolean htmlComment) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>htmlComment</dt> | |
<dd> | |
<parameter name="htmlComment"> | |
whether or not to delimit the javascript with html comments. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Sets whether or not to delimit the | |
javascript with html comments. If this is set to 'true', which | |
is the default, html comments will surround the javascript.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getSrc()"> | |
<strong>getSrc()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Gets the src attribute's value when defining the html script element. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
String getSrc() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p>Gets the src attribute's value when defining the html script element.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="setSrc()"> | |
<strong>setSrc()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Sets the src attribute's value (used to include | |
an external script resource) when defining | |
the html script element. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
void setSrc(String src) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>src</dt> | |
<dd> | |
<parameter name="src"> | |
the src attribute's value. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Sets the src attribute's value (used to include | |
an external script resource) when defining | |
the html script element.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getCdata()"> | |
<strong>getCdata()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Returns the cdata setting "true" or "false". | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
boolean getCdata() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p>Returns the cdata setting "true" or "false".</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="setCdata()"> | |
<strong>setCdata()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Sets the cdata status. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
void setCdata(boolean cdata) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>cdata</dt> | |
<dd> | |
<parameter name="cdata"> | |
The cdata to set | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Sets the cdata status.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getJavascript()"> | |
<strong>getJavascript()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Generates javascript to perform validations on a struts-defined | |
form. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
String getJavascript() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
String getJavascript(String formName) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>formName</dt> | |
<dd> | |
<parameter name="formName"> | |
The name of a struts-defined form. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Generates both dynamic and static javascript to perform | |
validations on a struts-defined form. By default it | |
uses the form associated with the action. A form name can | |
also be supplied as a parameter to generate javascript | |
for a struts-defined form that is not associated with this | |
particular action.</p> | |
<p>Assuming that the name of a form associated with a given action is myForm, the | |
following Velocity script:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode><form action="/someAction.do" onsubmit="return validateMyForm(this)"> | |
... | |
... | |
</form> | |
$validator.getJavascript()</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<p>produces something like this output (heavily abbreviated):</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode><form action="/someAction.do" onsubmit="return validateMyForm(this)"> | |
... | |
... | |
</form> | |
<script type="text/javascript" language="Javascript1.1"> | |
<!-- Begin | |
var bCancel = false; | |
function validateMyForm(form) { | |
// call the relevant static methods to validate this form | |
... | |
} | |
// some more dynamic functions dependent on which validations to perform. | |
... | |
... | |
// finally come all the static validator methods defined in validator-rules.xml | |
... | |
... | |
//End --> | |
</script></sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getDynamicJavascript()"> | |
<strong>getDynamicJavascript()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Generates the dynamic javascript methods to perform validation | |
on a struts-defined form. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
String getDynamicJavascript() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
String getDynamicJavascript(String formName) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>formName</dt> | |
<dd> | |
<parameter name="formName"> | |
The name of a struts-defined form. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Generates the dynamic javascript to perform validations on | |
a struts-defined form. By default it uses the form associated | |
with the action. A form name can also be supplied as a parameter | |
to generate javascript for a struts-defined form that is not | |
associated with this particular action. This method does not | |
work by itself - it requires that the relevant static methods | |
be accessible i.e. in a seperate .js file.</p> | |
<p>Assuming that the name of a form associated with a given action is myForm, the | |
following Velocity script:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode><form action="/someAction.do" onsubmit="return validateMyForm(this)"> | |
... | |
... | |
</form> | |
$validator.getDynamicJavascript()</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<p>produces something like this output (heavily abbreviated):</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode><form action="/someAction.do" onsubmit="return validateMyForm(this)"> | |
... | |
... | |
</form> | |
<script type="text/javascript" language="Javascript1.1"> | |
<!-- Begin | |
var bCancel = false; | |
function validateMyForm(form) { | |
// call the relevant static methods to validate this form | |
... | |
} | |
// some more dynamic functions dependent on which validations to perform. | |
... | |
... | |
//End --> | |
</script></sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getStaticJavascript()"> | |
<strong>getStaticJavascript()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Generates all the static javascript methods from validator-rules.xml. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
String getStaticJavascript() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p>Generates the static javascript methods from validator-rules.xml | |
to perform validations on a any form. Useful i.e. if the static | |
methods should be located in a seperate .js file.</p> | |
<p>The following Velocity script:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>$validator.getStaticJavascript()</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<p>produces something like this output (heavily abbreviated):</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode><script type="text/javascript" language="Javascript1.1"> | |
<!-- Begin | |
function validateFloatRange(form) { | |
... | |
... | |
} | |
function validateByte(form) { | |
... | |
... | |
} | |
// and a bunch more ... | |
... | |
//End --> | |
</script></sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
<!-- FOOTER SEPARATOR --> | |
<tr> | |
<td colspan="2"> | |
<hr noshade="" size="1"/> | |
</td> | |
</tr> | |
<!-- PAGE FOOTER --> | |
<tr><td colspan="2"> | |
<div align="center"><font color="#525D76" size="-1"><em> | |
Copyright © 1999-2003, Apache Software Foundation | |
</em></font></div> | |
</td></tr> | |
</table> | |
</body> | |
</html> |