Kief Morris typed the following on 10:07 13/12/2000 +0000
>>Root cause:
>>java.lang.NullPointerException
>>      at
>>org.apache.jasper.compiler.TagBeginGenerator.generateSetters(TagBeginGenerat
>>or.java:196)

OK, I've tracked this down. In my own code, this is caused by having a setter with
a different parameter type than the property the setter is changing. Namely, I had
a boolean property named "required" in my tag class, and my setter method takes
a String parameter, which I was checking and using to set the boolean property.

        private boolean required = false;

        public void setRequired (String required)
        {
                this.required = "true".equals(required);
        }

Jasper uses introspection to get the setter name for the "required" property, and
introspection looks for a setRequired method which takes a boolean property.

It turns out that if I implement setRequired() with a boolean parameter, Jasper
does the right thing: using <myTag required+"true"> generates Java code in
the JSP servlet which passes a boolean parameter to my setter. I had assumed
that tag parameters all had to be handled as Strings.

As a side note, I've submitted a patch to fix a minor bug in Jasper so this error
is reported in a somewhat more intelligible manner. Hopefully it will get rolled 
into 3.2.2.

alex, I haven't looked at your code, but you should double check it to make
sure your tag attribute setter methods all match the types of the properties
they set. Also make sure the methods are public, and are named following
the JavaBeans convention, i.e. property my_property has a setter named
setMyProperty(). I can mail you the patched source file or jar file if you want.

---
              bitBull makes the Internet bite: http://www.bitBull.com/demos/

Reply via email to