velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Fixler <...@fixler.com>
Subject Re: Struts Javascript Validators
Date Wed, 10 Nov 2004 17:20:41 GMT
It's already there...if you mean this [the form name is 
simpleSearchForm]

  <form-bean
     	name="simpleSearchForm"
     	type="org.apache.struts.validator.DynaValidatorForm">
     	<form-property name="keyword" type="java.lang.String"/>
  </form-bean>

eric


On Nov 10, 2004, at 8:48 AM, David You wrote:

>
> 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.
>
> Regards
> David
>
> -----Original Message-----
> From: Eric Fixler [mailto:fix@fixler.com]
> 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
> tool.
>
> 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;
>          else
>         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
> this.
>
> 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.
>
> thanks!
> eric
> ---------------------------------------------------------------------
> Eric Fixler
> fix@fixler.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
Eric Fixler
fix@fixler.com


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


Mime
View raw message