Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSP taglib: Unable to find setter method for attribute

Reply
Thread Tools

JSP taglib: Unable to find setter method for attribute

 
 
kaeli
Guest
Posts: n/a
 
      01-05-2004

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.gener ateSetters
(Compiled Code)
at
org.apache.jasper.compiler.TagBeginGenerator.gener ateServiceMethodStatem
ents(TagBeginGenerator.java:210)
at org.apache.jasper.compiler.TagBeginGenerator.gener ate
(TagBeginGenerator.java:279)
at org.apache.jasper.compiler.JspParseEventListener
$GeneratorWrapper.generate(Compiled Code)
at org.apache.jasper.compiler.JspParseEventListener.g enerateAll
(Compiled Code)
at
org.apache.jasper.compiler.JspParseEventListener.e ndPageProcessing
(JspParseEventListener.java:180)
at org.apache.jasper.compiler.Compiler.compile(Compil ed Code)
at com.netscape.server.http.servlet.NSServletEntity.l oad
(NSServletEntity.java:230)
at com.netscape.server.http.servlet.NSServletEntity.u pdate
(NSServletEntity.java:149)
at com.netscape.server.http.servlet.NSServletRunner.S ervice
(NSServletRunner.java:469)

--
--
~kaeli~
When a clock is hungry, it goes back four seconds.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      01-05-2004
kaeli wrote:
<snip>
> 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() );
}

 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      01-05-2004
In article <(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) enlightened us with...
>
> 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,
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

 
Reply With Quote
 
Sudsy
Guest
Posts: n/a
 
      01-05-2004
kaeli wrote:
<snip>
> 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.

 
Reply With Quote
 
kaeli
Guest
Posts: n/a
 
      01-05-2004
In article <(E-Mail Removed)>, (E-Mail Removed)
enlightened us with...
> kaeli wrote:
> <snip>
> > 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:
>


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

 
Reply With Quote
 
Sudsy
Guest
Posts: n/a
 
      01-05-2004
kaeli wrote:
<snip>
> 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).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling setter method from initialize method Le Wang Ruby 2 08-13-2011 06:44 PM
Error in tag lib : saying "unable to find setter method for attribute" callme sanjay via JavaKB.com Java 5 04-17-2007 08:58 AM
unable to find setter method for attribute: newspapercolumns Brummeline Java 1 03-08-2007 10:00 AM
JSTL version Tomcat vs Resin - Unable to find setter method - set(Object) kebabkongen@hotmail.com Java 2 11-14-2006 11:42 AM
Setter method in form bean corresponding to text field in JSP Vijay Java 4 04-13-2005 09:29 AM



Advertisments