Mantis - Resin
Viewing Issue Advanced Details
46 minor always 03-22-05 00:00 05-11-05 00:00
sergek  
 
urgent  
closed 3.0.12  
3.0.12 fixed  
none    
none 3.0.13  
0000046: Tag re-use finding wrong parent
RSN-37
I have a custom tag library that looks for a parent tag. For example:

<i:select>
  <c:forEach>
    <i:option></i:option>
  </c:forEach>
</i:select>

The option tag interacts with the select tag, so in my custom tag's doStartTag(), I have

SelectTag parent = (SelectTag) TagSupport.findAncestorWithClass(this,
                SelectTag.class);

I'm getting an exception when I have multiple select/option blocks. The problem seems to be how the tags are created and later reused. Here is the generated code for the option tag:

if (_jsp_OptionTag_5 == null) {
    _jsp_OptionTag_5 = new com.lokitech.jsp.input.OptionTag();
    _jsp_OptionTag_5.setPageContext(pageContext);
    _jsp_OptionTag_5.setParent((javax.servlet.jsp.tagext.Tag) _jsp_int_loop_1);
}

The second time the option tag is used, you have generated code that looks like this:

if (_jsp_OptionTag_5 == null) {
    _jsp_OptionTag_5 = new com.lokitech.jsp.input.OptionTag();
    _jsp_OptionTag_5.setPageContext(pageContext);
    _jsp_OptionTag_5.setParent((javax.servlet.jsp.tagext.Tag) _jsp_int_loop_2);
}

The second time this is run, obviously the _jsp_OptionTag_5 instance has already been created, and thus _jsp_int_loop_2 is not set as the parent.

My custom tag either then gets the wrong parent tag (the first select tag), or it gets none (because of how I use forEach tags elsewhere on the page.)
Tested on Resin 3.0.10 through 3.0.12. Both Linux RH deployment and Windows XP development. JDK 1.4.2_07.

Notes
(0000051)
sergek   
03-22-05 00:00   
Here is the JSP that shows this behavior. I will attach the JAR taglib in a sec.
(0000052)
sergek   
03-22-05 00:00   
This is open source and will eventually get published at http://sf.net/projects/ivytags. [^]
(0000053)
sergek   
03-22-05 00:00   
Generated java file showing wrong parent setting.
(0000054)
ferg   
03-22-05 00:00   
jsp/1cm5