You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ian Zabel <ia...@ezabel.com> on 2003/04/03 23:30:55 UTC

Taglib troubles with 4.1.24

I'm trying to code up some enhancements to my tag library, and I've just
switched to Tomcat 4.1.24.

I have a String defined in a base class which is appended to by many methods
in the tag. For instance:

public abstract class TagBase extends TagSupport
{
    private String attributes;

    public void addAttribute( String attr, String value )
    {
        if ( attributes == null || attributes.length() == 0 )
            attributes = " ";

        attributes += " " + attr;
        if ( value != null )
            attributes += "=\"" + value + "\"";
    }

    ....
}

The problem is that my tags are accumulating more and more attributes from
previous calls to the tag. One tag for example is an html radio tag. All of
the attributes that I am setting with the addAttribute() method accumulate
across tags. Like so:

<input type="radio"   name="testing" value="1"/>Radio Button 1
<input type="radio"   name="testing" value="1" value="2"/>Radio Button 2
<input type="radio"   name="testing" value="1" value="2" value="3"/>Radio
Button 3
<input type="radio"   name="testing" value="1" value="2" value="3"
value="4"/>Radio Button 4
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true"/>Radio Button 5
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true" value="6"/>Radio Button 6
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true" value="6" value="7"/>Radio Button 7
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true" value="6" value="7" value="8"/>Radio Button 8

What am I doing wrong here? Is this related to Tomcat 4.1's Tag Pooling? Is
there anything I can do to fix this?

Ian.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Taglib troubles with 4.1.24

Posted by Ian Zabel <ia...@ezabel.com>.
Sorry about the double post! I wasn't sure if my email was working.

To follow up: Maybe I need to null this specific variable at the beginning
of my doStartTag()?

Ian.

-----Original Message-----
From: Ian Zabel [mailto:ian@ezabel.com] 
Sent: Thursday, April 03, 2003 4:31 PM
To: tomcat-user@jakarta.apache.org
Subject: Taglib troubles with 4.1.24
Importance: High


I'm trying to code up some enhancements to my tag library, and I've just
switched to Tomcat 4.1.24.

I have a String defined in a base class which is appended to by many methods
in the tag. For instance:

public abstract class TagBase extends TagSupport
{
    private String attributes;

    public void addAttribute( String attr, String value )
    {
        if ( attributes == null || attributes.length() == 0 )
            attributes = " ";

        attributes += " " + attr;
        if ( value != null )
            attributes += "=\"" + value + "\"";
    }

    ....
}

The problem is that my tags are accumulating more and more attributes from
previous calls to the tag. One tag for example is an html radio tag. All of
the attributes that I am setting with the addAttribute() method accumulate
across tags. Like so:

<input type="radio"   name="testing" value="1"/>Radio Button 1
<input type="radio"   name="testing" value="1" value="2"/>Radio Button 2
<input type="radio"   name="testing" value="1" value="2" value="3"/>Radio
Button 3
<input type="radio"   name="testing" value="1" value="2" value="3"
value="4"/>Radio Button 4
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true"/>Radio Button 5
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true" value="6"/>Radio Button 6
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true" value="6" value="7"/>Radio Button 7
<input type="radio"   name="testing" value="1" value="2" value="3" value="4"
value="5" checked="true" value="6" value="7" value="8"/>Radio Button 8

What am I doing wrong here? Is this related to Tomcat 4.1's Tag Pooling? Is
there anything I can do to fix this?

Ian.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org