Re: Tags creating Tags

2003-10-26 Thread Ruth, Brice
One way of accomplishing what you want to do, I think, is simply making 
calls to the appropriate Struts classes that are called when  
is parsed & compiled. Instead of outputting an  - just call 
those methods with the arguments that you would write out as  
attributes, and you should get pretty close to what you're trying to 
achieve (without the performance hit ;)

Brice

Craig R. McClanahan wrote:

Lukas Bradley wrote:

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:


Should produce something like this:


 English
 
  


Which should then evaluate to:


 English
 
  

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?

 

It's not much help, except in the sense that it will put your search 
for the answer out of it's misery :-).  What you are trying to do is 
not supported by JSP -- the reason is that custom tags are converted 
into appropriate method calls at page compile time.  After that, they 
are just executed.  To accomplish what you are after, you would need 
another layer of compilation.

You'll need to come up with a different approach to accomplish what 
you are after.

Lukas

 

Craig



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.


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


Re: Tags creating Tags

2003-10-26 Thread Lukas Bradley
> One way of accomplishing what you want to do, I think, is simply making
> calls to the appropriate Struts classes that are called when 
> is parsed & compiled. Instead of outputting an  - just call
> those methods with the arguments that you would write out as 
> attributes, and you should get pretty close to what you're trying to
> achieve (without the performance hit ;)

That's EXACTLY what I want to do.  However, I don't want to have to write
all the calls to doStartTag(), then determine what action should be taken
from the return int, etc etc etc.

I was hoping that grunt work was already done for me, or existed within the
Jasper packages.

Lukas




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



Re: Tags creating Tags

2003-10-26 Thread matsuhashi

Craig R.McClanahan wrote:
>To accomplish what you are after, you would need another
>layer of compilation.
>You'll need to come up with a different approach to accomplish what you
>are after.

I think this link ( an article by Jason Diamon at xml.com) presents an
example of what Craig calls "another layer of compilation"
 http://www.xml.com/pub/a/2002/03/27/templatexslt.html

Suppose you define a template language for your own. By that language(a set
of XML elements/attributes name vocabularies), you mark-up the page source
codes with the "super-duper mamma tags" you define. Also you develop a
"MyLang-JSP transformer" by XSLT to produce JSP source codes. You can use
whatever JSP custom tags, including Struts', in the JSP generated by your
preprocessor. In fact I used this method for my application, which proved
good enough.

 Kazuaki





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



Re: Tags creating Tags

2003-10-26 Thread Ruth, Brice
I think you'll still end up with a severe performance penalty. If you 
generate JSP dynamically, that JSP will have to be "pre-compiled" each 
time you re-generate it.

[EMAIL PROTECTED] wrote:

Craig R.McClanahan wrote:
 

To accomplish what you are after, you would need another
layer of compilation.
You'll need to come up with a different approach to accomplish what you
are after.
   

I think this link ( an article by Jason Diamon at xml.com) presents an
example of what Craig calls "another layer of compilation"
http://www.xml.com/pub/a/2002/03/27/templatexslt.html
Suppose you define a template language for your own. By that language(a set
of XML elements/attributes name vocabularies), you mark-up the page source
codes with the "super-duper mamma tags" you define. Also you develop a
"MyLang-JSP transformer" by XSLT to produce JSP source codes. You can use
whatever JSP custom tags, including Struts', in the JSP generated by your
preprocessor. In fact I used this method for my application, which proved
good enough.
Kazuaki





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

--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.


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


Re: Tags creating Tags

2003-10-26 Thread Lukas Bradley
I apologize for the original cross-post.  I was hoping there might be a
Struts method to do what I wanted.

Here is something I wrote to the other group, after a post from Felipe Leme.

> I think you can accomplish what you're looking for using JSP 2.0 and tag
> files.

Yep.  That's exactly what I'm looking for.  Now Tomcat 5 just needs to be
released, because I'm stuck with JSP 1.2 for now.  *sniff*

Thanks for the help everyone.  I'm including a snippet from the JSP 2.0 PFD
3.

Lukas

JSP.8.1 Overview

As of JSP version 2.0, the JSP Compiler is required to recognize tag files.
A tag file is a source file that provides a way for a page author to
abstract a segment of JSP code and make it reusable via a custom action.

Tag files allow a JSP page author to create tag libraries using JSP syntax.
This means that page authors no longer need to know Java or ask someone who
knows Java to write a tag extension. Even for page authors or tag library
developers who know Java, writing tag files is more convenient when
developing tags that primarily output template text.







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



Re: Tags creating Tags

2003-10-26 Thread Mark Mahieu
Hi Lukas,

If I understand you correctly you need to look into the pushBody and 
popBody methods on PageContext.  Basically, in doStartTag(), call 
pageContext.pushBody() then in doEndTag() you call 
pageContext.popBody(), retrieve the BodyContent's value, muck about with 
it to your heart's content, then output your transformed markup to the 
current JspWriter.

Something like that anyway.  This is off the top of my head so I may be 
remembering the semantics slightly wrong, but I've definitely done this 
before

class MyTag extends BodyTagSupport {

   public int doStartTag() {

   pageContext.pushBody();

   return EVAL_BODY_INCLUDE;
   }
   public int doEndTag() {

   pageContext.popBody();
   String transformedMarkup =
   doSomeTransformations(getBodyContent().getString());
   pageContext.getOut().print(transformedMarkup);
   return EVAL_PAGE;
   }
}

Hope that helps,

Mark



Lukas Bradley wrote:

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:


Should produce something like this:


 English
 
  

Which should then evaluate to:


 English
 
  

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]


Re: Tags creating Tags

2003-10-26 Thread Mark Mahieu
I said,

> Hi Lukas,
>
> If I understand you correctly ...
But I didn't (understand that is).  I guess my reading comprehension 
skills at 6am just aren't up to it ;)

So just disregard my last 

Mark

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


Re: Tags creating Tags

2003-10-26 Thread Craig R. McClanahan
Lukas Bradley wrote:

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:


Should produce something like this:


 English
 
  

Which should then evaluate to:


 English
 
  

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?
 

It's not much help, except in the sense that it will put your search for 
the answer out of it's misery :-).  What you are trying to do is not 
supported by JSP -- the reason is that custom tags are converted into 
appropriate method calls at page compile time.  After that, they are 
just executed.  To accomplish what you are after, you would need another 
layer of compilation.

You'll need to come up with a different approach to accomplish what you 
are after.

Lukas

 

Craig



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


Re: Tags creating Tags

2003-10-26 Thread Lukas Bradley
Ruth, Craig, and lurkers,

I think what I'm after boils down to a method like this:

public String renderTag(PageContext pPageContext, Tag pTagToRender) throws
JspException

After creating the tag manually, you could pass it to this method, and have
it rendered.  The return value of a String should be the final output of the
Tag.  The method would check for BodyTag, IterationTag, etc support, and
react to it.  This way, the user could embed custom tags (Struts or
otherwise) within their own custom tags.

I'm surprised a method like this doesn't already exist.  This wouldn't be
recursive, nor would it recompile on each shot.  You may be right in calling
this a tad "hackish," but it would be useful, no?  I can even think of
another method that would be the incredi-hack:

public String renderTag(PageContext pPageContext, Tag pTagToRender) throws
JspException

Where you pass in "" instead of the Tag object itself.
Now that would be aggressive.

For another approach, the JspFragment interface looks promising.  However,
I'm stuck with Tomcat 4.1 for now, so JSP 2.0 is out.

Lukas




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



Re: Tags creating Tags

2003-10-26 Thread Craig R. McClanahan
Lukas Bradley wrote:

Ruth, Craig, and lurkers,

I think what I'm after boils down to a method like this:

public String renderTag(PageContext pPageContext, Tag pTagToRender) throws
JspException
 

A look at the JSP Specification will tell you that this would not work 
at all for a classic tag handler (i.e. implements Tag or implements 
BodyTag).

After creating the tag manually, you could pass it to this method, and have
it rendered.  The return value of a String should be the final output of the
Tag.  The method would check for BodyTag, IterationTag, etc support, and
react to it.  This way, the user could embed custom tags (Struts or
otherwise) within their own custom tags.
I'm surprised a method like this doesn't already exist.  This wouldn't be
recursive, nor would it recompile on each shot.  You may be right in calling
this a tad "hackish," but it would be useful, no?  I can even think of
another method that would be the incredi-hack:
public String renderTag(PageContext pPageContext, Tag pTagToRender) throws
JspException
Where you pass in "" instead of the Tag object itself.
Now that would be aggressive.
For another approach, the JspFragment interface looks promising.  However,
I'm stuck with Tomcat 4.1 for now, so JSP 2.0 is out.
 

I think the approach you suggest is problematic, for many of the reasons 
that Action chaining is problematic.  The most serious issue is that 
you're trying to use a JSP artifact (a custom tag implementation class) 
for something it was never designed to do (be a reusable "output 
generator" outside the context of the very strict and complex lifecycle 
for tag instances described in the JSP specfiication).  "Hackish" does 
not begin to describe how much trouble this kind of anti-object-oriented 
approach will lead you to in the long run.

The right answer would be to create your own tag class that does exactly 
what you want.  If your tag wants to leverage functionality from 
existing tag classes (and you don't want to cut-n-paste), either make 
your class a subclass of the existing one (presuming the stuff you need 
is already abstracted into useful protected methods), or abstract the 
stuff you need into utility classes that can be shared between your tag 
and the standard ones, and then lobby to have the same factoring done in 
the standard classes.

This is the foundational basis on which all Struts tag classes are 
organized, and has proven to support a pretty rich library of tag class 
implementations that (in many cases) reuse or specialize protected 
methods in their subclasses.  In no case was a "generate a tag" type of 
hack considered, because it's not necessary.  All that's necessary is 
applying sound design practices for factoring reusable code into 
reusable chunks.  I won't try to claim that we've done a perfect job at 
the current factoring, but the existence of something like struts-el 
(which was basically built on top of the existing tags, without having 
to rip them apart) is pretty good evidence that we're on the right track.

Trying to interfere with the tag instance lifecycle that the JSP page 
compiler assumes pretty much guarantees you'll end up with disaster.

Lukas

 

Craig



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


Re: Tags creating Tags

2003-10-27 Thread Steve Apeero
For what you want to do what is wrong with using a



where common_tags.jsp contain all the tags and html you
wanted to declare in a seperate tag.
Stephan


From: "Lukas Bradley" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Tags creating Tags
Date: Sun, 26 Oct 2003 19:34:04 -0500
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:


Should produce something like this:


  English
  
   


Which should then evaluate to:


  English
  
   

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]
_
Cheer a special someone with a fun Halloween eCard from American Greetings! 
Go to  http://www.msn.americangreetings.com/index_msn.pd?source=msne134

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


Re: Tags creating Tags

2003-10-27 Thread struts
I was wondering the same thing.

Along with tags like  tags and using ApplicationResources for 
language specifics, it seems like it would work well.

Oscar

On Mon, 27 Oct 2003, Steve Apeero 
wrote:

> For what you want to do what is wrong with using a
> 
> 
> 
> where common_tags.jsp contain all the tags and html you
> wanted to declare in a seperate tag.
> 
> Stephan
> 
> 
> >From: "Lukas Bradley" <[EMAIL PROTECTED]>
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >CC: [EMAIL PROTECTED]
> >Subject: Tags creating Tags
> >Date: Sun, 26 Oct 2003 19:34:04 -0500
> >
> >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:
> >
> >
> >
> >Should produce something like this:
> >
> >
> >   English
> >>styleClass="FormField"/>
> >
> >
> >
> >Which should then evaluate to:
> >
> >
> >   English
> >>class="FormField">
> >
> >
> >
> >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]
> >
> 
> _
> Cheer a special someone with a fun Halloween eCard from American Greetings! 
> Go to  http://www.msn.americangreetings.com/index_msn.pd?source=msne134
> 
> 
> -
> 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]



RE: Tags creating Tags

2003-10-27 Thread Mike Jasnowski
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:


  



The tag handling flow would look like (similar to what you proposed
earlier):

 myTag.doStartTag();

 pageContext.getOut().println("");

 *include output of body of custom tag here, which might be Struts tags
which are invoked.

 myTag.doEndTag();

 pageContext.getOut().println("");


 Which would evaluate to


 
  
   

   
  
 

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:



Should produce something like this:


  English
  
   


Which should then evaluate to:


  English
  
   


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]



Re: Tags creating Tags

2003-10-27 Thread Lukas Bradley
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:
>
> 
>   
> 
>
>
> The tag handling flow would look like (similar to what you proposed
> earlier):
>
>  myTag.doStartTag();
>
>  pageContext.getOut().println("");
>
>  *include output of body of custom tag here, which might be Struts tags
> which are invoked.
>
>  myTag.doEndTag();
>
>  pageContext.getOut().println("");
>
>
>  Which would evaluate to
>
>
>  
>   
>
> 
>
>   
>  
>
> 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:
>
> 
>
> Should produce something like this:
>
> 
>   English
>   
>
> 
>
> Which should then evaluate to:
>
> 
>   English
>class="FormField">
>
> 
>
> 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]



RE: Tags creating Tags

2003-10-27 Thread Edgar P Dollin
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:
> >
> > 
> >
> > 
> >
> >
> > The tag handling flow would look like (similar to what you proposed
> > earlier):
> >
> >  myTag.doStartTag();
> >
> >  pageContext.getOut().println("");
> >
> >  *include output of body of custom tag here, which might be Struts 
> > tags which are invoked.
> >
> >  myTag.doEndTag();
> >
> >  pageContext.getOut().println("");
> >
> >
> >  Which would evaluate to
> >
> >
> >  
> >   
> >
> > 
> >
> >   
> >  
> >
> > 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:
> >
> > 
> >
> > Should produce something like this:
> >
> > 
> >   English
> >styleClass="FormField"/>
> >
> > 
> >
> > Which should then evaluate to:
> >
> > 
> >   English
> >> class="FormField">
> > 
> >
> > 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]



RE: Tags creating Tags

2003-10-27 Thread Mike Jasnowski
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:
> >
> > 
> >   
> > 
> >
> >
> > The tag handling flow would look like (similar to what you proposed
> > earlier):
> >
> >  myTag.doStartTag();
> >
> >  pageContext.getOut().println("");
> >
> >  *include output of body of custom tag here, which might be Struts
> > tags which are invoked.
> >
> >  myTag.doEndTag();
> >
> >  pageContext.getOut().println("");
> >
> >
> >  Which would evaluate to
> >
> >
> >  
> >   
> >
> > 
> >
> >   
> >  
> >
> > 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:
> >
> > 
> >
> > Should produce something like this:
> >
> > 
> >   English
> >styleClass="FormField"/>
> >
> > 
> >
> > Which should then evaluate to:
> >
> > 
> >   English
> >> class="FormField">
> > 
> >
> > 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]