!_NEWLINE_!Is it possible to create a custom tag whose body is...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Todd_Trimmer
Posted On:   Friday, March 9, 2001 01:59 PM

MyPage Is it possible to create a custom tag whose body is not evaluated right away? Instead, another tag can call the first tag, and only THEN have it's body be evaluated. Kind of like a template in XSL. For instance, I might want to specify a tag that allows the JSP creator to insert arbitrary HTML, using page attribute values if any of the HTML is conditional. However, this HTML is not spit out as soon as it is encountered. Rather, some other arbitrary HTML is written OUTSIDE the tag. Some sort of call will be embedded in one of the elements. The JSP tag will THEN be evaluated and spit out to the location from where it was called. Example:    More>>
MyPage


Is it possible to create a custom tag whose body is not evaluated right away? Instead, another tag can call the first tag, and only THEN have it's body be evaluated. Kind of like a template in XSL.




For instance, I might want to specify a tag that allows the JSP creator to insert arbitrary HTML, using page attribute values if any of the HTML is conditional. However, this HTML is not spit out as soon as it is encountered. Rather, some other arbitrary HTML is written OUTSIDE the tag. Some sort of call will be embedded in one of the elements. The JSP tag will THEN be evaluated and spit out to the location from where it was called.



Example:



			





Hello!






Welcome!


<% callMyLibTinyTableTag() %>

Have fun!





Would produce:



			

MyPage

Welcome!






Hello!


Have fun!






This is a simple example, but what if there were several calls to callMyLibTinyTableTag() embedded in arbitarily complex HTML, with no discernable pattern of repetition? Making it even more complex, what if has several page variables associated with it? And these variables have to be evaluated when the tag is called, NOT when it is first read in by the JSP container.

   <<Less

Re: !_NEWLINE_!Is it possible to create a custom tag whose body is...

Posted By:   Joe_Pardi  
Posted On:   Thursday, May 17, 2001 07:37 PM

Sure. The custom tag needs to provide a TEI class so it can get put into a scripting variable. A method can then be provided in the tag to spit out the body's contents.
Something like:



id="theTable">




Hello!




MyPage

Welcome!


<%=theTable.putBody()%>

Have fun!








Good luck.
About | Sitemap | Contact