You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Young, Wayne" <WY...@metasolv.com> on 2001/02/27 15:22:23 UTC

recursive tag

Does anyone know how to create a tag that produces struts tags & then
recursively processes them.

Something like:
<app:databyschema schema="test"/>
is processed and returns
<struts:text property="field1" size="16" maxlength="16"/>
<struts:text property="field2" size="16" maxlength="16"/>
which is then processed to HTML.

Any help would be appreciated.

Thanks.

Wayne
wyoung@metasolv.com

Re: recursive tag

Posted by ma...@tumbleweed.com.
When a JSP page is compiled, the JSP code itself is turned into a servlet, 
but the custom tags remain external to that servlet. The class files for 
these must be a part of the web app for it to work.

Regardless, you do raise a good point. If things worked the way I had 
supposed, then you would get into trouble very quickly if the text you 
wrote to the body called for evaluation of tags that were not in your web app!

Obviously what the spec is referring to is not reevaluation of the body 
text being generated, but of the code that was generated from the body of 
the tag in the JSP. Duh! If I'd thought a little about how <logic:iterate> 
works first...  (Reminder to myself: turn on brain before answering questions!)

Thanks for setting me straight!

--
Martin Cooper
Tumbleweed Communications


At 10:30 AM 2/28/01 +1100, Nick Pellow wrote:
>Martin,
>         I do not believe that what you suggest would work.
>         My understanding is that when a jsp is compiled, all
>         the custom taglibs and the jsp are compiled into one huge
>         servlet. So at runtime, the container knows nothing about
>         custom tags or taglibs, just servlets. Since the doAfterBody()
>         method would be invoked at run time, there is no means to translate
>         the Body's Output into servlet code, and then  re-execute it.
>
>         The jsp spec does mention that Body Content of a Body tag can be
>processed, however,
>         I am not sure that this means it can be processed as another Taglib
>rather,
>         just as text.
>
>
>regards,
>
>Nick
>
>
>
>
>martin.cooper@tumbleweed.com wrote:
> >
> > You should be able to do this by creating a custom tag that writes your
> > initial output (the <struts:text> tags you suggested from your example) to
> > the body, and then returns EVAL_BODY_TAG from doAfterBody() to cause the
> > body to be reevaluated. Take a look at the JSP spec (e.g. the section on
> > Actions with Body) for more on this.
> >
> > Hope this helps.
> >
> > --
> > Martin Cooper
> > Tumbleweed Communications
> >
> > At 08:22 AM 2/27/01 -0600, Young, Wayne wrote:
> > >Does anyone know how to create a tag that produces struts tags & then
> > >recursively processes them.
> > >
> > >Something like:
> > ><app:databyschema schema="test"/>
> > >is processed and returns
> > ><struts:text property="field1" size="16" maxlength="16"/>
> > ><struts:text property="field2" size="16" maxlength="16"/>
> > >which is then processed to HTML.
> > >
> > >Any help would be appreciated.
> > >
> > >Thanks.
> > >
> > >Wayne
> > >wyoung@metasolv.com



Re: recursive tag

Posted by Nick Pellow <ni...@cortexebusiness.com.au>.
Martin, 
	I do not believe that what you suggest would work.
	My understanding is that when a jsp is compiled, all
	the custom taglibs and the jsp are compiled into one huge
	servlet. So at runtime, the container knows nothing about
	custom tags or taglibs, just servlets. Since the doAfterBody()
	method would be invoked at run time, there is no means to translate
	the Body's Output into servlet code, and then  re-execute it.

	The jsp spec does mention that Body Content of a Body tag can be
processed, however, 
	I am not sure that this means it can be processed as another Taglib
rather, 
	just as text.


regards, 

Nick


	

martin.cooper@tumbleweed.com wrote:
> 
> You should be able to do this by creating a custom tag that writes your
> initial output (the <struts:text> tags you suggested from your example) to
> the body, and then returns EVAL_BODY_TAG from doAfterBody() to cause the
> body to be reevaluated. Take a look at the JSP spec (e.g. the section on
> Actions with Body) for more on this.
> 
> Hope this helps.
> 
> --
> Martin Cooper
> Tumbleweed Communications
> 
> At 08:22 AM 2/27/01 -0600, Young, Wayne wrote:
> >Does anyone know how to create a tag that produces struts tags & then
> >recursively processes them.
> >
> >Something like:
> ><app:databyschema schema="test"/>
> >is processed and returns
> ><struts:text property="field1" size="16" maxlength="16"/>
> ><struts:text property="field2" size="16" maxlength="16"/>
> >which is then processed to HTML.
> >
> >Any help would be appreciated.
> >
> >Thanks.
> >
> >Wayne
> >wyoung@metasolv.com

Re: recursive tag

Posted by ma...@tumbleweed.com.
You should be able to do this by creating a custom tag that writes your 
initial output (the <struts:text> tags you suggested from your example) to 
the body, and then returns EVAL_BODY_TAG from doAfterBody() to cause the 
body to be reevaluated. Take a look at the JSP spec (e.g. the section on 
Actions with Body) for more on this.

Hope this helps.

--
Martin Cooper
Tumbleweed Communications


At 08:22 AM 2/27/01 -0600, Young, Wayne wrote:
>Does anyone know how to create a tag that produces struts tags & then
>recursively processes them.
>
>Something like:
><app:databyschema schema="test"/>
>is processed and returns
><struts:text property="field1" size="16" maxlength="16"/>
><struts:text property="field2" size="16" maxlength="16"/>
>which is then processed to HTML.
>
>Any help would be appreciated.
>
>Thanks.
>
>Wayne
>wyoung@metasolv.com