Custom JSP tags w/ Tomcat - setter not found? Please help.

Discussions

Web tier: servlets, JSP, Web frameworks: Custom JSP tags w/ Tomcat - setter not found? Please help.

  1. Hi all.

    I'm at my wit's end here. I'm trying to add some new attributes to a custom JSP tag and I cannot figure out what the problem is. Here's my problem, in brief:

    First off, I'm running on Tomcat 5.5.

    I'm trying to extend the DisplayTag library, adding an attribute called 'headgroup' (to group header cells together).

    I have the following in the TLD file:

    <tag>
    <name>column</name>
    <tag-class>org.displaytag.tags.ColumnTag</tag-class>
    ...
    <attribute>
        <name>headgroup</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
        <type>java.lang.String</type>
    </attribute>
    ...

    Then, in the tag handler class, org.displaytag.tags.ColumnTag, I have added:

    private String headgroup;
    public void setHeadgroup(String value)
    {
        this.headgroup = value;
    }

    So far, so good, right? Not quite. So, within my table I have the <display:column> tag, where I use my new attribute:

    <display:column headgroup="Event Dates" title="Start" property="startDateString" />

    Looks good! I go to this JSP page, and get a Tomcat exception:

    org.apache.jasper.JasperException: /event-table.jsp(25,16) Unable to find setter method for attribute: headgroup

    Huh?? There IS a setter! setHeadgroup(), as I showed above.

    What I've tried: I know it's not an issue of an old class, or a similar classloading issue. I inserted a couple of debug statements in the tag class, redeployed it, and the debug statements I added appear. So Tomcat is certainly using the latest version of the class.

    So, in summary, I (1) added the attribute to the TLD, (2) added the property and setter method in the tag handler class, and (3) used the tag.

    Am I forgetting or missing something? Why would Tomcat still be unable to find my setter method?

    (Incidentally, just to test it out, I changed the JSP page and added some scriptlet code to it:

    <% ColumnTag ct = new ColumnTag();
       ct.setHeadgroup("foo"); %>

    And it runs with no errors. So the setter is obviously accessible to Tomcat.

    Please help! Any assistance would be greatly appreciated...

    /** Joe

    Threaded Messages (2)

  2. I'm having the exact same problem..[ Go to top ]

    trying to extend display tag. Did you ever figure out a fix?
  3. Answer[ Go to top ]

    Edit the TableTabBeanInfo and ElTableTagBeanInfo classes to incorporate the new attribute.