JSP taglib: Unable to find setter method for attribute

K

kaeli

Okay, I can't get what's wrong with my code. This is my first try at a
taglib beyond the helloWorld example at orionserver.com (which worked).

Note that I already checked everything that I could find via Google,
including case of names, name conflict with parent class, putting in
getters, and unique signatures.

The compiler throws the exception "Unable to find setter method for
attribute" at setClosed. The other setters work fine.

Here is a sample of the setters/getters. The String one works. The
boolean one does not. (Am I not allowed to use boolean or something?)

private String perms=null;
private boolean closed=false;

public void setPerms(String perms)
{
this.perms = perms;
}
public String getPerms()
{
return this.perms;
}
public void setClosed(boolean closed)
{
this.closed = closed;
}
public boolean getClosed()
{
return this.closed;
}

The JSP code:
<my_taglib:theTextbox
perms="write"
closed="false"
/>

Any ideas?

Full error:
[05/Jan/2004:10:10:32] info ( 8100): JSP: JSP1x compiler threw exception
org.apache.jasper.JasperException: Unable to find setter method for
attribute: closed
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at javax.servlet.ServletException.<init>
(ServletException.java:107)
at org.apache.jasper.JasperException.<init>
(JasperException.java:73)
at org.apache.jasper.compiler.TagBeginGenerator.generateSetters
(Compiled Code)
at
org.apache.jasper.compiler.TagBeginGenerator.generateServiceMethodStatem
ents(TagBeginGenerator.java:210)
at org.apache.jasper.compiler.TagBeginGenerator.generate
(TagBeginGenerator.java:279)
at org.apache.jasper.compiler.JspParseEventListener
$GeneratorWrapper.generate(Compiled Code)
at org.apache.jasper.compiler.JspParseEventListener.generateAll
(Compiled Code)
at
org.apache.jasper.compiler.JspParseEventListener.endPageProcessing
(JspParseEventListener.java:180)
at org.apache.jasper.compiler.Compiler.compile(Compiled Code)
at com.netscape.server.http.servlet.NSServletEntity.load
(NSServletEntity.java:230)
at com.netscape.server.http.servlet.NSServletEntity.update
(NSServletEntity.java:149)
at com.netscape.server.http.servlet.NSServletRunner.Service
(NSServletRunner.java:469)

--
 
S

Sudsy

kaeli wrote:
public void setClosed(boolean closed)
{
this.closed = closed;
}
public boolean getClosed()
{
return this.closed;
}

Not permitted. You have to use String objects. Rewrite as follows:

public void setClosed( String closed ) {
this.closed = Boolean.getBoolean( closed );
}

public String getClosed() {
return( new Boolean( closed ).toString() );
}
 
K

kaeli

Okay, I can't get what's wrong with my code. This is my first try at a
taglib beyond the helloWorld example at orionserver.com (which worked).

Note: this error fixed. I'm an idiot and didn't recompile the code after
adding the getters.

full tag
<my_taglib:myTextbox
perms="write"
closed="false"
/>

However, I now have a new error. When I quote the attribute, I get an
error that it expects a boolean. When I don't quote it, I get an error
that attribute values should be quoted.
How do I resolve this?

If I quote it, I get this error.
(closed="false")

Incompatible type for method. Can't convert java.lang.String to boolean.
_jspx_th_my_taglib_myTextbox_0.setClosed("false");

If I don't quote it, I get
(closed=false)

[05/Jan/2004:10:29:16] info (14716): JSP: JSP1x compiler threw exception
org.apache.jasper.compiler.ParseException: /pages/test2.jsp(11,8)
Attribute value should be quoted

I'm confused.

--
--
~kaeli~
If that phone was up your a$$, maybe you could drive a
little better!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
S

Sudsy

kaeli wrote:
Incompatible type for method. Can't convert java.lang.String to boolean.
_jspx_th_my_taglib_myTextbox_0.setClosed("false");

Please see my previous reply. Note the text of the error: "Can't convert
java.lang.String to boolean". Just what I was trying to convey earlier.
 
K

kaeli

kaeli wrote:


Not permitted. You have to use String objects. Rewrite as follows:

I was beginning to think that was the case, but I am having a really
hard time finding good documentation for custom taglibs (read: not API
docs, but something readable for beginners) for someone not using
Tomcat.

Thanks!

--
--
~kaeli~
If that phone was up your a$$, maybe you could drive a
little better!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
S

Sudsy

kaeli wrote:
I was beginning to think that was the case, but I am having a really
hard time finding good documentation for custom taglibs (read: not API
docs, but something readable for beginners) for someone not using
Tomcat.

Thanks!

You're welcome. I highly recommend "Advanced JavaServer Pages" by David
M. Geary (ISBN 0-13-030704-1).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top