Just to be clear, I'm not advocating that the custom tag internally
instantiate the Struts tag, but rather let the container instantiate them as
it encountered them in the JSP. So

 CustomTag.doStartTag();
    StrutsTag.doStartTag();
    StrutsTag.doEndTag();
 CustomTag.doEndTag();

The custom tag must enable it's body to be evaluated so the Struts tag is
invoked. but other than that.

-----Original Message-----
From: Edgar P Dollin [mailto:[EMAIL PROTECTED]
Sent: Monday, October 27, 2003 10:51 AM
To: 'Lukas Bradley'; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: Tags creating Tags


There is a little more overhead than this.

You are now taking control of the struts tag lifespan.  Currently, assuming
tag pooling, this is done by the container based on a hash of the parameter
values.  If you are careful you can piggyback on that by synchronizing the
internal tag instantiation with your tag.  You could instantiate the
internal tag on every reference, but that would be a step back in terms of
efficiency.

Then any jsp parameters you will be passing to the internal tag must be
passed prior to invoking the tag.  Additionally, each of the methods of the
Tag or BodyTag interfaces must be implemented and call the internally
referenced tag based on the requirements of the tag.  Most of the struts
tags don't have a 'real' body so this is not that important.  If you were
considering wrapping the iterate tag, you would have an interesting problem.

Edgar

> -----Original Message-----
> From: Lukas Bradley [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 27, 2003 10:25 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: Tags creating Tags
>
>
> Mike emailed me this idea last night, and I think it's the best yet.
>
> Brilliant solution, Mike.
>
> Lukas
>
> "Mike Jasnowski" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Going from your example, I'm not sure why you even need to
> subclass a
> Struts
> > tag to get the output you described. You should be able to code
> > something like this on your JSP:
> >
> > <lukas:myTag lang="en">
> >   <html:file property="formFile" styleClass="FormField"/>
> > </lukas:myTag>
> >
> >
> > The tag handling flow would look like (similar to what you proposed
> > earlier):
> >
> >  myTag.doStartTag();
> >
> >  pageContext.getOut().println("<table><tr><td>");
> >
> >  *include output of body of custom tag here, which might be Struts
> > tags which are invoked.
> >
> >  myTag.doEndTag();
> >
> >  pageContext.getOut().println("</td></tr></table>");
> >
> >
> >  Which would evaluate to
> >
> >
> >  <table>
> >   <tr>
> >    <td>
> >     <input type="file" name="formFile" value="" class="FormField">
> >    </td>
> >   </tr>
> >  </table>
> >
> > All this w/o changing or subclassing a Struts tag, the only
> Custom tag
> work
> > is myTag.
> >
> > HTH,
> > Mike
> >
> > -----Original Message-----
> > From: Lukas Bradley [mailto:[EMAIL PROTECTED]
> > Sent: Sunday, October 26, 2003 7:34 PM
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: Tags creating Tags
> >
> >
> > Hi all,
> >
> > Maybe I'm just tired, but the answer to this is not to be found.  I
> > could
> me
> > making this harder than it is, or something might be right
> in front of
> > me, and I don't see it.
> >
> > What I want is a custom tag that creates other custom tags.
>  Here is a
> > simple example:
> >
> > <lukas:myTag lang="en" />
> >
> > Should produce something like this:
> >
> > <table>
> >   <tr><td>English</td></tr>
> >   <tr><td><html:file property="formFile"
> styleClass="FormField"/></td></tr>
> >    <!-- Imagine a lot more custom tags here -->
> > </table>
> >
> > Which should then evaluate to:
> >
> > <table>
> >   <tr><td>English</td></tr>
> >   <tr><td><input type="file" name="formFile" value=""
> > class="FormField"></td></tr>
> >    <!-- Imagine a lot more custom tags rendering here. --> </table>
> >
> > I've thought about trying to extend BodyTagSupport, return
> > EVAL_BODY_BUFFERED in doStartTag(), modify the bodyContent in
> doAfterBody(),
> > then return EVAL_PAGE() in doEndTag().  However, BodyContent has a
> protected
> > constructor, and no way to set its content.
> >
> > I want to maintain the functionality gained from Struts-like custom
> > tags, while extracting the creation of them in a super-duper momma
> > tag.  Any
> help?
> >
> > Lukas
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to