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" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> 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 ? > > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
XML Entity Resolution (was Re: 2 unanswered questions)
Maybe you need to register a custom EntityResolver on the Digesters? Struts doesn't really expose this in a graceful way right now, for tiles and validator you could probably look at either subclassing the plugins and taking charge of how the Digester is configured. See http://jakarta.apache.org/commons/digester/apidocs/org/apache/commons/digester/package-summary.html#doc.RegisteringDTDs Joe At 8:58 AM -0600 1/30/04, Matt Bathje wrote: > regarding "entity includes in tiles-defs.xml (again)" -- both struts-config and tiles-definitions files can be specified using a comma-separated list of files (in web.xml for struts-config, and in the plugin descriptor in struts-config for tiles) -- isn't that a simpler way to solve the same problem of breaking down big config files? The problem with that is, we have some forms (probably 5-6 of them) that have duplicated properties/validations. It would be nice to be able to do an entity include to include those duplicated validations in each form they are required in validation.xml. If I get some free time I am going to look into this, but as I mentioned in: http://www.mail-archive.com/struts-user%40jakarta.apache.org/msg92220.html I really think there is some sort of bug in either the plugin interface or the tiles and validator plugins specifically that make the "root" for the xml documents change to be %SystemRoot% or something like that. Matt Bathje - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining." -- Jef Raskin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 2 unanswered questions
> > regarding "entity includes in tiles-defs.xml (again)" -- both > struts-config and tiles-definitions files can be specified using a > comma-separated list of files (in web.xml for struts-config, and in > the plugin descriptor in struts-config for tiles) -- isn't that a > simpler way to solve the same problem of breaking down big config > files? > The problem with that is, we have some forms (probably 5-6 of them) that have duplicated properties/validations. It would be nice to be able to do an entity include to include those duplicated validations in each form they are required in validation.xml. If I get some free time I am going to look into this, but as I mentioned in: http://www.mail-archive.com/struts-user%40jakarta.apache.org/msg92220.html I really think there is some sort of bug in either the plugin interface or the tiles and validator plugins specifically that make the "root" for the xml documents change to be %SystemRoot% or something like that. Matt Bathje - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 2 unanswered questions
> I'm assuming that you've at least specified distinct values for the > "method" attribute for each use of ? > 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 2 unanswered questions
First - how can I have multiple forms on the same page all use javascript validation? The javascript that struts prints out for each form conflicts with each other, and causes only the "last" form's validations to work. Originally asked here: http://www.mail-archive.com/struts-user%40jakarta.apache.org/msg92019.html I'm assuming that you've at least specified distinct values for the "method" attribute for each use of ? 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! And as long as I am doing this, there are 2 other questions with no answers regarding "entity includes in tiles-defs.xml (again)" -- both struts-config and tiles-definitions files can be specified using a comma-separated list of files (in web.xml for struts-config, and in the plugin descriptor in struts-config for tiles) -- isn't that a simpler way to solve the same problem of breaking down big config files? Sorry, no answers for the other two questions... Joe -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining." -- Jef Raskin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]