JSP taglib: Unable to find setter method for attribute

Discussion in 'Java' started by kaeli, Jan 5, 2004.

  1. kaeli

    kaeli Guest

    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)

    --
    --
    ~kaeli~
    When a clock is hungry, it goes back four seconds.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Jan 5, 2004
    #1
    1. Advertising

  2. kaeli

    Sudsy Guest

    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() );
    }
     
    Sudsy, Jan 5, 2004
    #2
    1. Advertising

  3. kaeli

    kaeli Guest

    Attribute value must be quoted, but value is boolean (was Re: JSP taglib: Unable to find setter method for attribute)

    In article <>,
    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,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
     
    kaeli, Jan 5, 2004
    #3
  4. kaeli

    Sudsy Guest

    Re: Attribute value must be quoted, but value is boolean (was Re:

    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.
     
    Sudsy, Jan 5, 2004
    #4
  5. kaeli

    kaeli Guest

    In article <>,
    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
     
    kaeli, Jan 5, 2004
    #5
  6. kaeli

    Sudsy Guest

    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).
     
    Sudsy, Jan 5, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anonymous
    Replies:
    2
    Views:
    29,119
    phamlen
    Aug 31, 2006
  2. callme sanjay via JavaKB.com
    Replies:
    5
    Views:
    4,362
    haraul
    Apr 17, 2007
  3. Vijay
    Replies:
    4
    Views:
    1,346
    Vijay
    Apr 13, 2005
  4. Replies:
    2
    Views:
    610
  5. Brummeline
    Replies:
    1
    Views:
    787
    Brummeline
    Mar 8, 2007
Loading...

Share This Page