----- Original Message -----
From: "Peter Giannopoulos" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 26, 2001 7:49 PM
Subject: A bit of newbie question
> Hello all,
>
> I am new to the taglib development world so please bare with me, if I
> sometimes seem to ask silly questions. :-)
>
> That being said, I would love to know if there is a way to use a custom
tag
> within another custom tag (as an attribute value)
>
> For example something like (please let me know if I'm being stupid
here...is
> there a better way?)
>
> <foo:bar attrib1="baz" attrib2=" <foo:othertag attrib1=""> " />
> OR
>
> <foo:bar attrib1="baz" attrib2="<%=somevalue%>"> " />
> ----> I really would rather avoid any code between <% and %> on the jsp
> page.
If <foo:bar> isn't a JSP custom tag then this isn't an issue at all. If it
is then how about
<foo:bar attrib1="baz">
<foo:othertag attrib1="">
</foo:bar>
Then in the OtherTag class can communicate implicitly with its parent tag to
set the required attribute(s).
It can have code along the lines of
public class OuterTag extends TagSupport {
public int doEndTag()
Tag parent = getParent();
if ( parent instanceof FooTag ) {
FooTag foo = (FooTag) parent;
foo.setAttribute2( someValue );
}
...
}
If you go down this route be careful to make sure most of the 'action' code
of the <foo:bar> and <foo:othertag> tags are in the doEndTag() methods
rather than the doStartTag() methods so that the tags have time to initalise
themselves first, via containment.
James
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com