You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Ralph Schaer <ra...@yahoo.com> on 2004/02/24 06:29:41 UTC

Bug in JavascriptValidatorTag

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);
         }

Regards
Ralph


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


Re: Bug in JavascriptValidatorTag

Posted by Joe Germuska <Jo...@Germuska.com>.
At 9:08 PM +0100 2/25/04, Ralph Schaer wrote:
>this bug was introduced with revision 1.45 from 2004/02/04
>in JavascriptValidatorTag.java

OK; that makes sense.  But that was when I was trying to get it to 
throw an exception when there was no such form instead of just 
spewing the static javascript into the page.

Clearly my lack of familiarity with the method of generating static 
javascript in an external file led me to completely screw up that 
attempt, but rolling it back doesn't really get me where I'd like to 
be (and where a few other people seemed to agree was better.)

I'm still in the case where I don't have much time to fix it this 
week.  Please file a bug.  Maybe someone else can either figure out 
the compromise or if it burns them, roll it back to the way it was. 
If not, then I'll do it when I'm past the next deadline.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
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: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Bug in JavascriptValidatorTag

Posted by Ralph Schaer <ra...@yahoo.com>.
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: struts-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
> 
> 


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


Re: Bug in JavascriptValidatorTag

Posted by Joe Germuska <Jo...@Germuska.com>.
At 7:23 PM +0100 2/25/04, Ralph Schaer wrote:
>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: struts-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-dev-help@jakarta.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
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: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Bug in JavascriptValidatorTag

Posted by Ralph Schaer <ra...@yahoo.com>.
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.

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: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Bug in JavascriptValidatorTag

Posted by Joe Germuska <Jo...@Germuska.com>.
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);
>         }


-- 
Joe Germuska            
Joe@Germuska.com  
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: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org