tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mfncoo...@gmail.com>
Subject Re: TagSupport vs BodyTagSupport
Date Sun, 24 Jul 2005 03:22:02 GMT
On 7/23/05, Luca Passani <passani@eunet.no> wrote:
> 
> ooops, I felt this was a general taglib question, more than a Struts
> question. It only takes struts as an example,
> but the question is "is there a reason why it makes sense to always
> subclass BodyTagSupport in a tag-library?"

Sorry, I read it as "why are almost all of the Struts tags based on
BodyTagSupport?", which would be a question for the Struts list. But I
guess I'll go ahead and answer that anyway, since it's probably the
simplest way to answer what you're asking.

The reason is exactly what you noted - that almost all of the tags
extend BaseHandlerTag, which has quite a lot of stuff in it. We needed
a common base class so that we could share all of that code, and not
have to reimplement the common attributes for each tag, and since some
of the tags process their bodies, there's no alternative but for that
base class to extend BodyTagSupport. We could have used two base
classes, but that would have meant duplicating code, and would no
doubt have led to the tags getting out of sync.

Rahul mentioned SimpleTagSupport, and that would have been nice, but
that came along long after the Struts tags, and indeed the Struts tags
still need to support earlier versions of JSP.

Hope that helps.

--
Martin Cooper


> Luca
> 
> Martin Cooper wrote:
> 
> >Once again, please ask questions about Struts on the Struts mailing
> >lists, rather than here.
> >
> >--
> >Martin Cooper
> >
> >
> >On 7/23/05, Luca Passani <passani@eunet.no> wrote:
> >
> >
> >>Hello, I would love to hear about some taglib theory here.
> >>
> >>My understanding is that, when creating a new tag, I can inherit from
> >>either TagSupport or BodyTagSupport
> >>depending on whether I need to manipulate  the tag content or not.
> >>For this reason, most of my tags (WALL library) inherit from TagSupport
> >>with the exception of one (which inherits from BodyTag).
> >>Looking at the code for the Struts html tag-lib, I see that most tag
> >>inherit from BaseHandlerTag (which looks
> >>totally reasonable to me), which, in turn, inherits from BodyTagSupport,
> >>even for tags that have no particular reason to do so,.
> >>
> >>in fact, in moost cases, doAfterBody() ends up doing domething as simple as,
> >>
> >> if (bodyContent != null) {
> >>            String value = bodyContent.getString().trim();
> >>            if (value.length() > 0) {
> >>                text = value;
> >>            }
> >>        }
> >>
> >>i..e,  just comsmetic for the returned source markup.
> >>
> >>My question is, in general, what is the rationale for inheriting from
> >>BodyTagSupport everywhere?
> >>what is the performance hit when inheriting from BodyTagSupport as
> >>compared to TagSupport?
> >>
> >>Thank you
> >>
> >>Luca
> >>
> >>
> >>
> >>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message