com.sas.taglib
Class BaseBodyTag

com.sas.taglib.BaseBodyTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally
Direct Known Subclasses:
BaseCellRendererTag, BaseROCFBodyTag, BaseTransformationBodyTag, BaseTransformationBodyTag, ColumnsTag, ColumnTag, CompositeValidatorTag, DataBeanTag, EditTag, JDBCConnectionTag, RowsTag, StyleSheetTag, TreeNodeTag

public class BaseBodyTag
implements javax.servlet.jsp.tagext.TryCatchFinally

The base object for all body tag support handlers in the SAS Custom Tag Library that have a body.

See Also:
Serialized Form

Field Summary
static java.lang.String DELIMITERS
          Static reference to String delimiters for parsing the body of a tag.
static java.lang.String RB_KEY
          Static key for referencing the Internationalization Strings for this class
 
Constructor Summary
BaseBodyTag()
          Constructor for BaseBodyTag.
 
Method Summary
protected  void applyAttributes()
          Called by the doStartTag method to set any variables or methods in the wrapped class.
 void doCatch(java.lang.Throwable t)
          This method implements the javax.servlet.jsp.tagext.TryCatchFinally doCatch method.
 void doFinally()
          This method implements the javax.servlet.jsp.tagext.TryCatchFinally doFinally method.
 int doStartTag()
          This Method Overrides the javax.servlet.jsp.tagext.TagSupport doStartTag Method.
protected  boolean getApplyAttributes()
          If a class is loaded from the page context from the ID it is not necessary to reapply the attributes.
 java.util.Enumeration getBodyStrings()
          Retrieves the body of a custom tag and returns an Enumeration of the elements.
protected  java.lang.String getCompositeComponentKey()
          Gets the compositeComponentKey property.
 boolean getInstantiate()
          Indicates whether or not the wrapped class should be instantiated if a suitable object is not found in the PageContext.
 java.util.Locale getLocale()
          Get the locale
protected  javax.servlet.jsp.PageContext getPageContext()
          This method is here simply as a place holder and to provide consistency with the Bean specification.
 java.lang.String getRef()
          Returns the reference variable name that should be used to instantiate the custom tag.
 java.lang.String getScope()
          Returns the string representation of the Tag's scope.
 int getTagScope()
          This method is in place simply as a place holder.
 java.lang.String getWrappedClassName()
          Gets the name of the class being wrapped by the custom tag.
 java.lang.Object getWrappedObject()
          Gets an object instance of the class being wrapped by the custom tag.
 java.lang.Object getWrappedObject(boolean forceCreation)
          Gets an object instance of the class being wrapped by the custom tag.
protected  void initialize(boolean includeAttributes)
          This method is used to initialize attributes and variables at various time during the tag handler lifecycle.
 void loadBeanInstance()
          Loads an instance of the specified transformation bean (or class).
 java.lang.Object newInstance()
          Creates a new instance of the wrapped class.
 void release()
          This method overrides the javax.servlet.jsp.tagext.TagSupport release method.
 void removeFromScope()
          If the "id" or "ref" are not null the tag will be removed from PageContext if it exists within the tag's specified scope.
 java.lang.Object searchContext(java.lang.String var)
          Searches the PageContext for the specified attribute.
protected  void setApplyAttributes(boolean applyAttributes)
          If a class is loaded from the page context from the ID it is not necessary to reapply the attributes.
protected  void setCompositeComponentKey(java.lang.String compositeComponentKey)
          Sets the compositeComponentKey property (boolean) from a tag attribute.
 void setInstantiate(boolean instantiate)
          Sets the instantiate property (boolean) from a tag attribute.
 void setLocale(java.util.Locale loc)
          Set the locale
 void setRef(java.lang.String ref)
          Sets the ref property (String) from a tag attribute.
 void setScope(java.lang.String scope)
          Sets the scope property (int) from a tag attribute.
 void setTagScope(int tagScope)
          This method is in place simply as a place holder.
 void setVariableWithinScope()
          If "id" is not null the tag will be added to the PageContext with tag's scope.
 void setWrappedClassName(java.lang.String wrappedClassName)
          Sets the name of the class being wrapped by the custom tag.
 void setWrappedObject(java.lang.Object wrappedObject)
          Sets an object instance of the class being wrapped by the custom tag.
 void validate(java.lang.Object obj, java.lang.String item)
          Validates whether or not an attribute is null.
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
Static key for referencing the Internationalization Strings for this class

See Also:
Constant Field Values

DELIMITERS

public static final java.lang.String DELIMITERS
Static reference to String delimiters for parsing the body of a tag.

See Also:
Constant Field Values
Constructor Detail

BaseBodyTag

public BaseBodyTag()
Constructor for BaseBodyTag.

Method Detail

setCompositeComponentKey

protected void setCompositeComponentKey(java.lang.String compositeComponentKey)
Sets the compositeComponentKey property (boolean) from a tag attribute.

Parameters:
compositeComponentKey - Sets the composite component key to set the underlying object on the parent object

setInstantiate

public void setInstantiate(boolean instantiate)
Sets the instantiate property (boolean) from a tag attribute.

Parameters:
instantiate - Flag that, if true, indicates that a new instance of the underlying class should be loaded if one cannot be found in PageContext. Must be used with an id attribute.

setLocale

public void setLocale(java.util.Locale loc)
Set the locale

Parameters:
locale - Specifies the locale to use for this instance of the class.

setApplyAttributes

protected void setApplyAttributes(boolean applyAttributes)
If a class is loaded from the page context from the ID it is not necessary to reapply the attributes. This function is in place to simply to gain access to the applyAttributes field.

Parameters:
applyAttributes - Flag that, if true, indicates that the attributes of the bean should be modified.

setRef

public void setRef(java.lang.String ref)
Sets the ref property (String) from a tag attribute. The ref String represents the property to initialize a Transformation Bean with. Roughly, if you create a custom tag of the same type earlier in the page, session, application, or request scope, it is possible to use the ref object to instantiate the new custom tag instead of creating a new instance of the tTransformationBean or InformationBean. The ref String is the same as the id String of the previous object.

Parameters:
ref - The variable String value that represents an object created earlier in the same scope.

setScope

public void setScope(java.lang.String scope)
Sets the scope property (int) from a tag attribute. The scope String specifies the scope of the tag. Valid values are: page - the tag is valid throughout the page
request - the tag is valid throughout the request
session - the tag is valid throughout the session
application - the tag is valid throughout the application
The default value for the scope is page.

Parameters:
scope - The scope (or page context) within which the reference is available.

setTagScope

public final void setTagScope(int tagScope)
This method is in place simply as a place holder. The setScope() Method converts the string representation of the scope into its PageContext int value. Due to introspection you can not return an int from getScope(), you must return a String.

Parameters:
tagScope - An int value that represents the PageContext Scope for the tag.

getCompositeComponentKey

protected java.lang.String getCompositeComponentKey()
Gets the compositeComponentKey property.

Returns:
compositeComponentKey to be used by the parent's underlying object.

getInstantiate

public boolean getInstantiate()
Indicates whether or not the wrapped class should be instantiated if a suitable object is not found in the PageContext.

Returns:
boolean representation of instantiate

getLocale

public java.util.Locale getLocale()
Get the locale

Returns:
locale used by the tag and underlying bean

getApplyAttributes

protected final boolean getApplyAttributes()
If a class is loaded from the page context from the ID it is not necessary to reapply the attributes. This function is in place to simply to gain access to the applyAttributes field.

Returns:
true if the bean's attributes should be modified

getPageContext

protected javax.servlet.jsp.PageContext getPageContext()
This method is here simply as a place holder and to provide consistency with the Bean specification. This method should be in javax.servlet.jsp.tagext.TagSupport class.

Returns:
PageContext an instance of the PageContext for the page executing the custom tag.

getRef

public java.lang.String getRef()
Returns the reference variable name that should be used to instantiate the custom tag.

Returns:
String reference variable used to instantiate the custom tag

getScope

public java.lang.String getScope()
Returns the string representation of the Tag's scope.

Returns:
string representation of the Tag's scope

getTagScope

public final int getTagScope()
This method is in place simply as a place holder. The setScope() Method converts the string representation of the scope into its PageContext int value. Due to introspection you can not return an int from getScope(), you must return a String.

Returns:
int representing the PageContext Scope for the tag

initialize

protected void initialize(boolean includeAttributes)
This method is used to initialize attributes and variables at various time during the tag handler lifecycle. This method is called with a value of true in the constructor method and the release method to initialize all class level attributes and variables. It is also called with a value of false in the doEndTag method to initialize only class level variables, since tag attribute values should be preserved. This method should be overriden in subclasses that contain variables and attributes.

Parameters:
includeAttributes - Set to true if attributes are to be set to default values.

loadBeanInstance

public void loadBeanInstance()
Loads an instance of the specified transformation bean (or class). First, the PageContext is searched for an instance of the bean using the ref, if not found then null is returned. If ref is not specified in the tag then the PageContext is searched with id. If an instance can not be found and createNewInstance is true, then a new instance of "theClass" will be created.


removeFromScope

public void removeFromScope()
If the "id" or "ref" are not null the tag will be removed from PageContext if it exists within the tag's specified scope.


searchContext

public java.lang.Object searchContext(java.lang.String var)
Searches the PageContext for the specified attribute.

Parameters:
var - the attribute to search for
Returns:
Object the attribute's value if found, otherwise null.

setVariableWithinScope

public void setVariableWithinScope()
If "id" is not null the tag will be added to the PageContext with tag's scope.


validate

public void validate(java.lang.Object obj,
                     java.lang.String item)
              throws java.lang.IllegalArgumentException
Validates whether or not an attribute is null. If the attribute is null, an IllegalArgumentException will be thrown.

Parameters:
obj - The attribute to be tested
item - The name of the attribute being tested
Throws:
java.lang.IllegalArgumentException - Thrown if obj was null.

applyAttributes

protected void applyAttributes()
                        throws javax.servlet.jsp.JspException
Called by the doStartTag method to set any variables or methods in the wrapped class. This method should be overriden in subclasses.

Throws:
javax.servlet.jsp.JspException - Thrown if a JspException occurs.

setWrappedClassName

public void setWrappedClassName(java.lang.String wrappedClassName)
Sets the name of the class being wrapped by the custom tag.

Parameters:
wrappedClassName - the name of the class being wrapped

setWrappedObject

public void setWrappedObject(java.lang.Object wrappedObject)
Sets an object instance of the class being wrapped by the custom tag.

Parameters:
wrappedObject - an instance of the wrapped class

getWrappedClassName

public java.lang.String getWrappedClassName()
Gets the name of the class being wrapped by the custom tag.

Returns:
String the name of the class being wrapped

getWrappedObject

public java.lang.Object getWrappedObject()
                                  throws javax.servlet.jsp.JspException
Gets an object instance of the class being wrapped by the custom tag. This Object should be cast to the appropriate Class before it can be used.

Returns:
Object an instance of the class being wrapped
Throws:
javax.servlet.jsp.JspException - Thrown if a JspException occurs.

getWrappedObject

public java.lang.Object getWrappedObject(boolean forceCreation)
                                  throws javax.servlet.jsp.JspException
Gets an object instance of the class being wrapped by the custom tag. This Object should be cast to the appropriate Class before it can be used.

Parameters:
forceCreation - create an instance of the wrapped class if one can not be found in the PageContext
Returns:
Object an instance of the class being wrapped
Throws:
javax.servlet.jsp.JspException - Thrown if a JspException occurs.

newInstance

public java.lang.Object newInstance()
                             throws javax.servlet.jsp.JspException
Creates a new instance of the wrapped class.

Returns:
an instance of the wrapped class that can be cast to the appropriate class
Throws:
javax.servlet.jsp.JspException - Thrown if a JspException occurs.
See Also:
setWrappedObject(java.lang.Object), getWrappedObject()

getBodyStrings

public java.util.Enumeration getBodyStrings()
Retrieves the body of a custom tag and returns an Enumeration of the elements. Lines are separated by the tab character, the newline character, the carriage-return character, and the form-feed character.

Returns:
java.util.Enumeration Enumeration of the body elements

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
This Method Overrides the javax.servlet.jsp.tagext.TagSupport doStartTag Method. An instance of the wrapped class is loaded from the PageContext or created if it can not be found if the instantiate is true.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
The doStart int return code.
Throws:
javax.servlet.jsp.JspException - Thrown if a JspException occurs.
See Also:
setInstantiate(boolean), TagSupport.doStartTag()

doCatch

public void doCatch(java.lang.Throwable t)
             throws java.lang.Throwable
This method implements the javax.servlet.jsp.tagext.TryCatchFinally doCatch method.

Specified by:
doCatch in interface javax.servlet.jsp.tagext.TryCatchFinally
Parameters:
t - The Throwable which was caught in this tag's lifecycle.
Throws:
java.lang.Throwable - Thrown if a Throwable occurs. The Throwable is rethrown.
See Also:
TryCatchFinally.doCatch(java.lang.Throwable)

doFinally

public void doFinally()
This method implements the javax.servlet.jsp.tagext.TryCatchFinally doFinally method. This method will clean up any per-invocation resources.

Specified by:
doFinally in interface javax.servlet.jsp.tagext.TryCatchFinally
See Also:
TryCatchFinally.doFinally()

release

public void release()
This method overrides the javax.servlet.jsp.tagext.TagSupport release method. This method will clean up any long term resources after all tag invocations are complete.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport
See Also:
TagSupport.release()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.