this bug was introduced with revision 1.45 from 2004/02/04 in JavascriptValidatorTag.java
you find the working code in revision 1.44. method renderJavascript.
StringBuffer results = new StringBuffer();
ModuleConfig config = TagUtils.getInstance().getModuleConfig(pageContext);
ValidatorResources resources =
(ValidatorResources) pageContext.getAttribute(
ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix(),
PageContext.APPLICATION_SCOPE);
Locale locale = TagUtils.getInstance().getUserLocale(this.pageContext, null);
Form form = resources.getForm(locale, formName);
if (form != null) {
if ("true".equalsIgnoreCase(dynamicJavascript)) {
results.append(
this.createDynamicJavascript(config, resources, locale, form));
} else if ("true".equalsIgnoreCase(staticJavascript)) { results.append(this.renderStartElement()); if ("true".equalsIgnoreCase(htmlComment)) { results.append(HTML_BEGIN_COMMENT); } } }
if ("true".equalsIgnoreCase(staticJavascript)) { results.append(getJavascriptStaticMethods(resources)); }
if (form != null && ("true".equalsIgnoreCase(dynamicJavascript) || "true".equalsIgnoreCase(staticJavascript))) {
results.append(getJavascriptEnd()); }
return results.toString();
Thanks for fixing that. But there is still a problem. (Nightly Build 2004/02/25) You can see the error in the struts-example web application.
Hm. I don't believe that that's been changed in any of the last few revisions.
Please file this in Bugzilla; I don't know about anyone else, but it's going to be a while before I can pay closer attention to find the real fix. (If you have a patch, could be sooner.)
Does anyone have any decent idea how to unit test a complicated JSP tag like this? It sounds like we're having only fair-to-middling results with Cactus stuff as it is, but it would be nice to put in the test case that we're trying to fix now so that we don't break it again in the future.
Joe
There is a staticJavascript.jsp page with this content
<%@ page language="java" %>
<%-- set document type to Javascript (addresses a bug in Netscape according to a web resource --%>
<%@ page contentType="application/x-javascript" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:javascript dynamicJavascript="false" staticJavascript="true"/>
and logon contains this line: <script language="Javascript1.1" src="staticJavascript.jsp"></script>
Now the problem is that the html:javascript tag also writes the <script> tag into the output.
<script type="text/javascript" language="Javascript1.1">
<!-- Begin ..... //End -->
</script>
The result is a javascript error in the browser.
Regards Ralph
Hm. No one brought that up when we were talking about implementing the fix, but that explains the old default behavior, which was to render the javascript without wrapping script tags. That makes sense when you're rending javascript for external use.
It seems to me that the solution would be fixed by moving the check for a non-null form into createDynamicJavascript, where there is nothing to be done if the form is null.
Does this get fixed in 1.2.1? Or do we fix it now and move the release tag for that file?
Obviously I don't use static javascript, or I would have seen the problem with the fix before -- would anyone care to double check my logic here?
Joe
At 6:29 AM +0100 2/24/04, Ralph Schaer wrote:
I've found a bug in JavascriptValidatorTag.java. (Nightly build 2004/02/23)
I use this tag in one of my jsp pages: <html:javascript dynamicJavascript="false" staticJavascript="true"/>
Now the JavascriptValidatorTag crashes with this error message:
javax.servlet.jsp.JspException: No form found under name null, locale de_CH
The error occurs on line 381. There is a null check for the form attribute. But there is no need for a form when you just want the static part of the validator javascript code.
if (form == null) { throw new JspException("No form found under name " + formName + ", locale " + locale); }
--------------------------------------------------------------------- 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]