I am writing some nested custom tags using JSP. I understand there are two ways to do this: 1) to write tag handler that extends BodyTagSupport, 2) to write a tag file.
In the 1st method, code is ugly. And I couldn't find a way to incorporate current struts tags.If I write the following using a JspWriter, I get this string in final HTML output instead of a meaningful output generated by the compiled JSP.
<bean:write name="label">
So, I turned to the 2nd method, I wrote tag files. Then the above issue is solved. However, I then have problem getting a tag's parent tag, since I don't know the parent tag class. I could do the following if I wrote my own tag handler,
ParentTag parent =
(ParentTag)findAncestorWithClass(this, ParentTag.class);
if (parent == null) {
throw new JspTagException("this tag is outside of its parent tag");
}
But since, I used tag files instead, I don't quite know what class its parent is.
How could I solve this problem?