You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Bathje <mp...@ntsource.com> on 2004/02/02 17:37:24 UTC

Re: 2 unanswered questions

Replying to myself here - but after some searching over the weekend, I found
bug 17667 - which is the same problem I have been having. Stupid me
searching for "multiple form" all this time instead of "multi-form" never
found it.

Anyways, I took the patches that had been attached to that bug already, and
updated them for the latest versions of Struts and Commons Validator (mostly
moving all the javascript fixes out of validator-rules.xml and into the
individual .js files in validator) and it is working great. Much cleaner
then the crap I had been brewing up as well.

I put the new patches back up under the bug if anybody else is interested.
(Or if they want to put this in 1.2)

Matt Bathje


----- Original Message ----- 
From: "Matt Bathje" <mp...@ntsource.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, January 29, 2004 6:00 PM
Subject: Re: 2 unanswered questions


> > I'm assuming that you've at least specified distinct values for the
> > "method" attribute for each use of <html:javascript>?
> > http://jakarta.apache.org/struts/userGuide/struts-html.html#javascript
> > (Actually, looking at the doc I see that the process when this isn't
> > specified should result in unique validate method names.)  I've never
> > actually tried to validate multiple forms in a single page.  You may
> > have simply discovered a limitation in the design of the validator
> > stuff.  If so, feel free to submit an enhancement request in
> > Bugzilla, and feel just as free (or more so) to attach patches to
> > help solve the problem!
>
> Yes, specifying the method doesn't help with the problem.
>
> I started working on a patch - and it doesn't seem like it is going to be
> struts specific. The validator javascript files (as well as the validator
> itself maybe) need to be changed so that this can be done.
>
> Basically what I have started on doing is:
>
> 1. adding a multipleForm (true|false) property to the html:javascript
tag -
> if it is true it means we want multiple js validators on the same page.
> 2. Modifying
>
org.apache.struts.taglib.html.JavascriptValidatorTag.createDynamicJavascript
> to append the formName to the javascript functions that it outputs in the
> ValidatorAction iteration loop. (If multipleForm = true)
> 3. Modifying
>
org.apache.struts.taglib.html.JavascriptValidatorTag.getJavascriptStaticMeth
> ods to alter the validator javascript if multipleForm = true. The 2 things
I
> am trying to have it do are replace the function definition with a
function
> definition that includes the form name and replace the oRequired (or
> whatever) array definition call with a call that includes the form name
(so
> oRequired = new required(); becomes oRequired = new requiredFormName();)
>
> 1 and 2 are no problems.
> 3 on the other hand is a major pain in the butt, and where alterations to
> validator instead of struts come in.
>
> First, the .js files follow very loose standards for naming. Weird things
> like oRequired for the required validator, but oMasked for the mask
> validator. Weird things like minlength and maxlength both having wacky
> upper/lower case changes all over. This makes doing String.replaceall()
> operations on the .js files extremely tricky. The .js files would need to
be
> changed to make sure they follow a standard that could be parsed properly.
>
> The second problem is that I don't even think these replace operations
> belong in struts, but in the validator code itself. (Like in
> org.apache.commons.validator.ValidatorAction.loadJavascriptFunction
> possibly) The problem here is I'm not entirely sure how to get the
> html:javascript multipleForm variable into ValidatorAction properly. I am
> also not sure if this is even the best/most elegant solution. If having it
> in the validator code is good, is loadJavascriptFunction the best place
for
> it, or is somewhere else better? Does that code actually belong in struts
or
> validator?
>
> I can hack some stuff together and use it on our own sites, but I'd really
> like to be able to contribute this stuff back so I want to make it
"right".
>
> Thats all for now, let me know what you all think.
>
> Thanks,
> Matt Bathje
>
>
> ---------------------------------------------------------------------
> 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