Generates the dynamic javascript methods to perform validation
on a struts-defined form.
String getDynamicJavascript()
|
String getDynamicJavascript(String formName)
|
- Parameters
-
- formName
-
The name of a struts-defined form.
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.
Assuming that the name of a form associated with a given action is myForm, the
following Velocity script:
<form action="/someAction.do" onsubmit="return validateMyForm(this)">
...
...
</form>
$validator.getDynamicJavascript()
|
|
produces something like this output (heavily abbreviated):
<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>
|
|
|