You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Blignaut <br...@hemtech.co.za> on 2003/02/24 14:27:15 UTC

Validation Rules XML

Hi,

I am trying to write the javascript for my own validation rules based on 
the javascript in the validation-rules.xml file. Can anyone tell me what 
the statement 'new required()' does. Where is required defined?

Any help would be greatly appreciated

Brian


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Validation Rules XML

Posted by Jeff Kyser <kt...@comcast.net>.
Hey Brian,

here's my guess:	(note uncertainty :)

	The javascript function required() is generated in:

		org.apache.struts.taglib.html.JavascriptValidatorTag

	in method doStartTag().

If you look at similar statements in other rules in the 
validator-rules.xml file, such as

	oByte = new ByteValidations();

they often have a property jsFunctionName="ByteValidations", etc.

But required, minlength, maxlength, and a number of others do not.

In method doStartTag(), you find:

                     if (va.getJsFunctionName() != null && 
va.getJsFunctionName().length() > 0) {
                         functionName = va.getJsFunctionName();
                     } else {
                         functionName = va.getName();
                     }

and later:

                     results.append("    function " + functionName + " 
() { \n");

So it has to be generating the function:

	function required() {
		// ...
	}

and then later, in the snippet provided by the validator-rules.xml,
a function object is created with:

	oRequired = new required();

I don't have client-side validation enabled on my project, but
that certainly would seem to me to be what's happening.

regards,

-jeff

On Monday, February 24, 2003, at 07:27  AM, Brian Blignaut wrote:

> Hi,
>
> I am trying to write the javascript for my own validation rules based 
> on the javascript in the validation-rules.xml file. Can anyone tell me 
> what the statement 'new required()' does. Where is required defined?
>
> Any help would be greatly appreciated
>
> Brian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org