5.1.3.1
Call Functionality, no Body
This is probably the simplest example: just collect attributes and call into some action. The 
only action involved is 
foo
, and in this case it should have no body. I.e something like:
In this case we would define a 
FooTag
 tag handler that extends 
TagSupport
 only 
redefining 
doStartTag
. The 
doStartTag
 method would take the attribute information, 
perhaps interact with the 
PageContext
 data and invoke into the appropriate functionality.
The entry for this tag in the Tag Library Descriptor should indicate that the action must have 
no body; no 
TagExtraInfo
 class is needed.
5.1.3.2
Call Functionality, No Body, Define Object
In a simple variation of the previous example the action defines an object.
mybar
  
att1
= ...  
att2
= ...  
att3
= ... 
 />
After this, an object with name 
mybar
 is available to the scripting language.
The semantics of 
doStartTag()
 invocation is as before except that additionally it should 
insert the appropriate object for the  mybar  entry into the pageContext.
The Tag Library Descriptor entry for this action needs to mention a 
TagExtraInfo
 class 
that will be used to determine the scripting variables that will be created by the action; in this 
case  mybar  (note that id must be a translation time attribute).
5.1.3.3
Call Functionality, Define Object by Scope
In some cases, the previous example can also be described without using a TagExtraInfo by 
having the bar action enclose the actions that would use the created object.  In this case, the 
defining action needs not indicate any id attribute but it must have a body:
= ...  
att2
= ...  
att3
= ... 
>
  BODY
The nesting actions will invoke 
findAncestorWithClass
 to locate the bar handler 
object.
5.1.3.4
Template Mechanisms
There are a number of  template  mechanisms in server side frameworks.  The simplest of 
these mechanisms will take a  token  and replace it by some fixed replacement text (that can 
be changed easily); more sophisticated mechanisms compute the replacement text, and can 
Chapter 5
Tag Extensions
90




JSP Web Hosting JavaServer Pages Specifications JSP Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.