jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: Parent/Child (Outer/Inner) Tags question
Date Wed, 13 Feb 2002 14:27:06 GMT
On Wed, 13 Feb 2002, Rick Sample wrote:

> I am using basic parent / child tags (outer/inner tags).
> Everything works fine with the below snip for a compile
> time (hard code) reference to the outer tag like so:
> InnerTag's doStart()
> ...
>   OuterTag parent = (OuterTag) findAncestorWithClass(this, OuterTag.class);
> ...
> I can get/set all the outer tags methods this way.
> Now, I want to reuse my inner tags with any outer tag(s). I can
> not seem to get my brain around a simple solution. Must have
> eaten lead paint over the weekend!

I'm not sure what you mean by "any outer tag(s)."  Do you mean that you
want to have the same inner tag work with more than one outer tag that
you've written?  If so, then there are three potential solutions:

 - ensure all the outer tags' handlers have a common superclass
   (e.g., OuterTagBase)
 - ensure all the outer tags' handlers implement the same interface
 - use reflection on the outer tag's handler that you find at runtime

In general, I'd need to know a bit more about what you're trying to do to
offer more specific help.  In the general case, when you want class A to
access some well-known method off a set of classes B, you want B to either
implement a common interface or have a common superclass.  Reflection lets
you avoid the type-safe solution in favor of runtime generality.

Best of luck - and feel free to respond with more detailed information.

Shawn Bayern
Author, "JSP Standard Tag Library"  http://www.jstlbook.com
(coming soon from Manning Publications)

To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>

View raw message