jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <bay...@generationjava.com>
Subject Re: RE: taglibs: retrieve tag name
Date Wed, 27 Aug 2003 16:25:24 GMT

I'm pretty sure I tried this with String Taglib, having an abstract tag
that introspected the name of the tag. As far as I recall, it wasn't
possible.

But I probably just didn't figure it out :)

Hen

On Wed, 27 Aug 2003, Wouter  Huijnink wrote:

> > well it's more for estetic reasons. I do want the tags to have different
> > name for different things,
> > and have less attributes for the end user. also another use for the
> > getTagName would be for someting
> > as simple as returning an error. out.write("Tag "+getTagName()+" requires
> > either field x or field y")
>
> I think you should either decide to write different tags to do different things (as it
looks like your class design has some flaws), or to live with more attributes.
>
> But if you really want to hold on to your initial plan, I'd suggest you declare your
Tag an abstract class, and subclass it with concrete classes that do not add any functionality,
but are just different labels for AbstractTag instances.
>
> For instance:
>
> abstract class AbstractTag {
>   public void doIt() {
>     ...
>     String tagName = this.getClass().getName();
>     doSomethingWith(Class.forName("mycompany.entity." + tagName));
>   }
> }
>
> public class ConcreteTag1 extends AbstractTag {
> }
>
> public class ConcreteTag2 extends AbstractTag {
> }
>
> in your tld you just declare the ConcreteTag classes
>
> Regards,
> Wouter
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org
>


Mime
View raw message