Re: Bug in JavascriptValidatorTag

2004-02-25 Thread Ralph Schaer
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" %>



and logon contains this line:

Now the problem is that the html:javascript tag also writes the 
 tag into the output.<br>
<script type="text/javascript" language="Javascript1.1"></tt><br>
<br>
<pre style="margin: 0em;"><!-- Begin
.
//End --></pre><br>
<tt>

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:

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]


Re: Bug in JavascriptValidatorTag

2004-02-25 Thread Ralph Schaer
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" %>



and logon contains this line:

Now the problem is that the html:javascript tag also writes the  
tag into the output.<br>
<script type="text/javascript" language="Javascript1.1"></tt><br>
<br>
<pre style="margin: 0em;"><!-- Begin
.
//End --></pre><br>
<tt>

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:

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]


Bug in JavascriptValidatorTag

2004-02-23 Thread Ralph Schaer
I've found a bug in JavascriptValidatorTag.java.
(Nightly build 2004/02/23)
I use this tag in one of my jsp pages:

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Struts Validation DTD

2002-11-29 Thread Ralph Schaer
I found a problem with struts validation. 
I have one struts installation on a pc that does not have an internet connection. This 
works fine. Struts can read the dtd for the struts-config file from the jar 
(org\apache\struts\resources\struts-config_1_1.dtd).
Then I added the struts validation configurations file to the application. The 
ValidatorPlugIn tries to read the dtd from the Internet 
(http://jakarta.apache.org/commons/dtds/validator_1_0.dtd) and crashes with an 
Exception (UnknownHostException: jakarta.apache.org). 

Regards
Ralph




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




ConvertUtils

2001-01-27 Thread Ralph Schaer

Hello

Thanks for changing the ConvertUtils class. Unfortunately the class is no
longer able to support
the wrapper types. The attached source file contains this support.


IMHO is also better to user the Boolean.FALSE and Boolean.TRUE constants
instead
of creating new Boolean objects.

 ConvertUtils.java


Re: ConvertUtils

2001-01-27 Thread Ralph Schaer

Hi

I changed the ConvertUtils. Now the wrapper classes get a null value instead
of
a zero when the string is not valid. The native types get a default value,
which
is actually zero, but is changeable through a method.

Also add support for short.


Ralph

>I'm open to suggestion on alternatives.

>The problem is that there is nothing in the range of most of the primitive
types
>(byte, char, int, long) that corresponds to a "null" value for an object
>reference.  The only thing we can do is:
>* Pick one particular value to be ambiguous ("did the user
>  really type a zero or not?").
>* Throw a conversion exception, which just throws the
>  same decision back up a level.





 ConvertUtils.java


ConvertUtils

2001-01-26 Thread Ralph Schaer


Hello

Short comment about the ConvertUtils.convert... Methods.
All convert methods returns zero when the String is not a valid value.

Isn't this very dangerous, because zero can be a reasonable value in an
application?

Ralph




HTML Validation

2001-01-26 Thread Ralph Schaer



Hello

I check the pages of the example application with CSE HTML Validator.
The Validator complains about the script tag in the logon.jsp

"[16] HTML 4.01 requires the "type" attribute to specify the scripting
language for the "script" element. For example, use type="text/javascript"
for JavaScript.  "

Struts generates