velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David You <>
Subject RE: Struts Javascript Validators
Date Wed, 10 Nov 2004 16:48:05 GMT

You have to put the FormBean name in the struts XML file. I got the same
problem, while I used to only provide bean name on the submit processing
action but not the form page action.


-----Original Message-----
From: Eric Fixler [] 
Sent: Wednesday, November 10, 2004 2:33 AM
To: Velocity Users List
Subject: Struts Javascript Validators

Hi all.  I'm wondering if anyone is successfully using Struts client 
side validators in conjunction with ValidatorTool.

I believe that I have configured everything properly, and I get the 
javascript in the vm output.  But it looks to me like there is a 
javascript error, specifically, that there's something missing from the 
dynamic section of the javascript, which is, I think, generated by the 

To be specific:

- Here's a snippet from the required field validator, which is part of 
the static section and comes straight from Struts

function validateRequired(form) {
  oRequired = eval('new ' + formName.value + '_required()');

AFAICT, it's attempting to instantiate an object that will be used to 
figure out which field are required.  For a form called 'formName' 
there'd need to be a method called 'formName_required'.  There's no 
such method.  My log confirms this:

(event handler):Value undefined (result of expression 
simpleSearchForm_required) is not an object. Cannot be used with new.

- Here's the code of section of the dynamic javascript portion of the 
validator, which, I think, is generated by the ValidatorTool

      var bCancel = false;

     function validateSimpleSearchForm(form) {
         if (bCancel)
       return true;
        return validateRequired(form);

     function required () {
      this.aa = new Array("keyword", "null is required.", new Function 
("varName", " return this[varName];"));

I would expect the formName_object to be here, but it's not.  Instead, 
just a method called 'required', which refers to a 'this'.  The way I'm 
looking at this, there's no object context there to be referred to by 

Anyway, that's the result of my investigation.  I'd really appreciate 
some confirmation that this stuff is working out there in the real 
world, plus any pointers to make it work.

Eric Fixler

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message