| Author |
javascript error using validator
|
David Strelitz
Greenhorn
Joined: Aug 17, 2004
Posts: 3
|
|
I'm using struts 1.1, and am having a problem with the validator where I'm combining two forms onto one page using jsp:includes. Each jsp/form has its own <html:javascript> tag which creates a small block of javascript code to handle required fields. The problem is that struts creates the javascript function "required()" twice, once for each <html:javascript> block. The required() function contains the list of form fields that are required for entry. It wouldn't be a problem if it named each function according to the form it is associated with, e.g.: function StateFormrequired () { this.aa = new Array("certstate", "State is required.", new Function ("varName", " return this[varName];")); } So what happens is that when anything validates, it uses the first required() function, and produces a javascript error if it doesn't match the form you're on. Do you know of a way to get around this? I did see a post out there that showed the following, so it makes me think there's a version of struts that addresses it: var formName = form.getAttributeNode( "name "); oRequired = e v a l( 'new ' + formName.value + '_required() '); Thanks!
|
 |
Shankar Narayana
Ranch Hand
Joined: Jan 08, 2003
Posts: 134
|
|
|
I think atleast for the pages which contain other included jsp pages, you should maintain different function names.
|
"Failure is not when you fall down; its only when you fail to get up again."
|
 |
David Strelitz
Greenhorn
Joined: Aug 17, 2004
Posts: 3
|
|
The problem is that I don't have control over the function names. The required() function is generated automatically by struts as part of the dynamicJavascript option on <html:javascript>
|
 |
Shankar Narayana
Ranch Hand
Joined: Jan 08, 2003
Posts: 134
|
|
I don't find any other alternatives unless you have the control over the names
|
 |
David Strelitz
Greenhorn
Joined: Aug 17, 2004
Posts: 3
|
|
OK I found the answer. This was a bug (or deficiency) in Struts 1.1. It has been corrected in the recent 1.1 nightly builds and is incorporated into 1.2 for more info: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22462
|
 |
 |
|
|
subject: javascript error using validator
|
|
|