com.sas.servlet.tbeans
Class BaseTransformation

com.sas.servlet.tbeans.BaseTransformation
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.lang.ObjectDataInterface, RenderableInterface, TransformationInterface, com.sas.util.WriteToPrintWriterInterface, java.io.Serializable
Direct Known Subclasses:
AppliedFilters, BaseActionTransformation, BaseButton, BaseCompositeTransformation, BaseFormElement, BaseImage, BaseIPage, BaseLogin, BaseMenuBar, BaseTreeView, DefaultCellContentsRenderer, DefaultCellContentsRenderer, Form, PropertyEditorContainer, WebMDDBView

public abstract class BaseTransformation
implements TransformationInterface, RenderableInterface, com.sas.beans.PropertyChangeSource, com.sas.util.WriteToPrintWriterInterface

The base object for all Transformation Beans. "Transformation Bean" is the name given to a Java component which consumes data from either a model or via property sets and transforms the data into a different representation that will be streamed to a client (or other consumer). A very common type of Transformation Bean will be one that consumes data from a webAF model (such as DataSetInterface) and represents the data in HTML (such as a TABLE).

Transformation Beans are intended to be used by servlet developers and JSP (Java ServerPages) writers.

The com.sas.servlet.tbeans package contains generic interfaces and base classes that define different types of beans. The final implementation will be language-specific, with the classes residing in a sub-package such as com.sas.servlet.beans.form.html.

For More Information:

Visit the AppDev Studio Developer's Site to access step-by-step examples, white papers and additional usage information at http://support.sas.com/rnd/appdev/.

Examples for this class may be found on the Examples Site.

JSP custom tags provide an alternative to using the TransformationBeans™. Visit the Custom Tag Library Reference for additional information on these custom tags.

See Also:
Serialized Form

Constructor Summary
BaseTransformation()
          Default Constructor
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener for this TransformationBean
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener for this TransformationBean
 void cleanUpResources()
          This method releases all of the necessary resources that were needed by the transformation bean to render itself.
 void firePropertyChange(java.beans.PropertyChangeEvent evt)
          Fire a property change event
 void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
          Fire a property change event
 void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
          Fire a property change event
 void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Fire a property change event
 java.lang.String getCustomAttributes()
          Gets the custom attributes
 java.lang.String getDescription()
          Gets the description that will be used to describe this bean to the user.
 java.lang.String getId()
          Gets the id.
 com.sas.util.transforms.TransformInterface getInputTransform()
          Retrieve the input transformer that's used when setObjectData gets called.
 java.util.Locale getLocale()
          Get the locale
 java.lang.String getName()
          Deprecated. Use getId method instead
 java.lang.Object getObjectData()
          Retrieve the Object stored in the Object model.
 java.lang.String getObjectDataProperty()
          Retrieve the property name of the value that gets set when setObjectData gets called.
 com.sas.util.transforms.TransformInterface getOutputTransform()
          Retrieve the output transformer that's used when getObjectData gets called.
 javax.servlet.http.HttpServletRequest getRequest()
          Gets the current request object.
 javax.servlet.http.HttpServletResponse getResponse()
          Gets the current response object.
 java.lang.String getTagEpilog()
          Returns a string to be written after to any tag information
 java.lang.String getTagProlog()
          Returns a string to be written prior to any tag information
 boolean hasListeners(java.lang.String propertyName)
          Check for listeners on the property.
 boolean isCleanUpResourcesOn()
          Return whether the request and response will automatically be set to null once a TransformationBean is rendered.
 boolean isVisible()
          Returns whether or not the transformation bean should be written
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener for this TransformationBean
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener for this TransformationBean
 void setCleanUpResourcesOn(boolean b)
          Set the flag that indicates whether the request and response objects should be set to null once the TransformationBean is rendered.
 void setCustomAttributes(java.lang.String value)
          Sets any custom attributes.
 void setDescription(java.lang.String value)
          Sets the description that will be used to describe this bean to the user.
 void setId(java.lang.String value)
          Sets the id.
 void setInputTransform(com.sas.util.transforms.TransformInterface transform)
          Sets the input transformer to be used when setObjectData method gets called.
 void setLocale(java.util.Locale loc)
          Set the locale
protected  void setLocaleDependentProperties(java.util.Locale loc)
          Sets the locale dependent properties.
 void setName(java.lang.String value)
          Deprecated. Use setId method instead
 void setObjectData(java.lang.Object value)
          Sets the Object stored in the Object model.
 void setObjectDataProperty(java.lang.String property)
          Sets the property name for the value to be set when setObjectData method gets called.
 void setOutputTransform(com.sas.util.transforms.TransformInterface transform)
          Sets the output transformer to be used when getObjectData method gets called.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Sets the request object.
 void setResponse(javax.servlet.http.HttpServletResponse response)
          Sets the response object.
 void setTagEpilog(java.lang.String epilog)
          Sets a string to be written after to any tag information
 void setTagProlog(java.lang.String prolog)
          Sets a string to be written prior to any tag information
 void setVisible(boolean b)
          Sets the visibility parameter for a tbean.
 java.lang.String toString()
          Returns a string representation of this transformation bean.
 void write(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Writes the transformed representation of the object.
 void write(java.io.OutputStream out)
          Writes the transformed representation of the object.
 void write(java.io.PrintWriter out)
          Writes the custom attributes of the object.
 void write(java.io.Writer out)
          Writes the transformed representation of the object.
 

Constructor Detail

BaseTransformation

public BaseTransformation()
Default Constructor

Method Detail

setId

public void setId(java.lang.String value)
Sets the id.

Specified by:
setId in interface TransformationInterface
Parameters:
value - The id

getId

public java.lang.String getId()
Gets the id.

Specified by:
getId in interface TransformationInterface
Returns:
id The ID

setName

public void setName(java.lang.String value)
Deprecated. Use setId method instead

Sets the name that will be used to identify the content when it is submitted to the server

Specified by:
setName in interface TransformationInterface
Parameters:
value - The name
See Also:
setId(java.lang.String)

getName

public java.lang.String getName()
Deprecated. Use getId method instead

Gets the name that will be used to identify the content when it is submitted to the server

Specified by:
getName in interface TransformationInterface
Returns:
The name
See Also:
getId()

setDescription

public void setDescription(java.lang.String value)
Sets the description that will be used to describe this bean to the user. This will be used when performing client-side validation of forms, for example. The default value is the name of the bean.

Specified by:
setDescription in interface TransformationInterface
Parameters:
desc - The description

getDescription

public java.lang.String getDescription()
Gets the description that will be used to describe this bean to the user.

Specified by:
getDescription in interface TransformationInterface
Returns:
The description

write

public void write(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  java.io.IOException
Writes the transformed representation of the object. This overloaded version of 'write' will set the request and response objects, get the PrintWriter from the response, and call the write(PrintWriter) method.

Specified by:
write in interface TransformationInterface
Parameters:
req - The request object
resp - The response object
Throws:
javax.servlet.ServletException - Thrown if some type of servlet error occurs
java.io.IOException - Thrown if some type of I/O error occurs

write

public void write(java.io.Writer out)
           throws java.io.IOException
Writes the transformed representation of the object. This overloaded version of 'write' will create a new PrintWriter using the given Writer and call the write(PrintWriter) method.

Specified by:
write in interface TransformationInterface
Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

write

public void write(java.io.PrintWriter out)
           throws java.io.IOException
Writes the custom attributes of the object. All transformation beans should overwrite this method and call SUPER.

Specified by:
write in interface TransformationInterface
Specified by:
write in interface com.sas.util.WriteToPrintWriterInterface
Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Writes the transformed representation of the object. This overloaded version of 'write' will create a new PrintWriter using the given OutputStream and call the write(PrintWriter) method.

Specified by:
write in interface TransformationInterface
Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Sets the request object. There may be cases where a Transformation Bean needs to get additional information from the request, such as a parameter value. If this is true, the request must be set before calling the 'write' method. See the documentation for the Transformation Bean if the request is required.

Specified by:
setRequest in interface TransformationInterface
Parameters:
request - The request object

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Gets the current request object.

Specified by:
getRequest in interface TransformationInterface
Returns:
The request object

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Sets the response object. There may be cases where a Transformation Bean needs to set additional information on the response. If this is true the response must be set before calling the 'write' method. See the documentation for the Transaction Bean if the response is required.

Specified by:
setResponse in interface TransformationInterface
Parameters:
response - The response object

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Gets the current response object.

Specified by:
getResponse in interface TransformationInterface
Returns:
The response object

toString

public java.lang.String toString()
Returns a string representation of this transformation bean. A new StringWriter will be created and the write(PrintWriter) method will be invoked. The contents of the StringWriter will be returned, which will contain the output from the Transaction Bean.

Note that the toString() method on this class and subclasses calls the write method, which may have undesirable side effects. The request and response objects are set to null, and these objects are often necessary for the proper functioning of the subsequest write method. Actions on the ActionProvider will not work. Debuggers often use toString() to show the value of a variable, and this may cause unexpected behavior while debugging

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the object

setCustomAttributes

public void setCustomAttributes(java.lang.String value)
Sets any custom attributes. Custom attributes can be passed if the interface does not define properties that create the desired attributes. For example, if a new attribute NEWSTUFF is added in later versions of an HTML specification that attribute can be specified here as NEWSTUFF="value". Any number of attributes can be specified in the string.

Specified by:
setCustomAttributes in interface TransformationInterface
Parameters:
value - The custom attribute

getCustomAttributes

public java.lang.String getCustomAttributes()
Gets the custom attributes

Specified by:
getCustomAttributes in interface TransformationInterface
Returns:
The custom attributes

getTagProlog

public java.lang.String getTagProlog()
Returns a string to be written prior to any tag information

Specified by:
getTagProlog in interface TransformationInterface
Returns:
string to be written prior to any tag information
See Also:
TransformationInterface.setTagProlog(String)

setTagProlog

public void setTagProlog(java.lang.String prolog)
Sets a string to be written prior to any tag information

Specified by:
setTagProlog in interface TransformationInterface
Parameters:
prolog - string to be written prior to any tag information

getTagEpilog

public java.lang.String getTagEpilog()
Returns a string to be written after to any tag information

Specified by:
getTagEpilog in interface TransformationInterface
Returns:
string to be written after to any tag information

setTagEpilog

public void setTagEpilog(java.lang.String epilog)
Sets a string to be written after to any tag information

Specified by:
setTagEpilog in interface TransformationInterface
Parameters:
epilog - string to be written after to any tag information

setLocale

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

Specified by:
setLocale in interface TransformationInterface
Parameters:
locale -

getLocale

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

Specified by:
getLocale in interface TransformationInterface
Returns:
The locale.

setLocaleDependentProperties

protected void setLocaleDependentProperties(java.util.Locale loc)
Sets the locale dependent properties. Not operational at this level.

Parameters:
localProperties - the locale dependent properties.

setObjectData

public void setObjectData(java.lang.Object value)
Sets the Object stored in the Object model. For the ChoiceBox, sets the selectedItem associated with the choicebox

Specified by:
setObjectData in interface com.sas.lang.ObjectDataInterface
Parameters:
value - The selectedItem

getObjectData

public java.lang.Object getObjectData()
Retrieve the Object stored in the Object model. For the ChoiceBox, gets the selectedItem associated with the choicebox

Specified by:
getObjectData in interface com.sas.lang.ObjectDataInterface
Returns:
The selectedItem

setObjectDataProperty

public void setObjectDataProperty(java.lang.String property)
Sets the property name for the value to be set when setObjectData method gets called.

Specified by:
setObjectDataProperty in interface RenderableInterface
Parameters:
property - The objectDataProperty

getObjectDataProperty

public java.lang.String getObjectDataProperty()
Retrieve the property name of the value that gets set when setObjectData gets called.

Specified by:
getObjectDataProperty in interface RenderableInterface
Returns:
The objectDataProperty

setInputTransform

public void setInputTransform(com.sas.util.transforms.TransformInterface transform)
Sets the input transformer to be used when setObjectData method gets called.

Specified by:
setInputTransform in interface RenderableInterface
Parameters:
transform - The inputTransform

getInputTransform

public com.sas.util.transforms.TransformInterface getInputTransform()
Retrieve the input transformer that's used when setObjectData gets called.

Specified by:
getInputTransform in interface RenderableInterface
Returns:
The inputTransform

setOutputTransform

public void setOutputTransform(com.sas.util.transforms.TransformInterface transform)
Sets the output transformer to be used when getObjectData method gets called.

Specified by:
setOutputTransform in interface RenderableInterface
Parameters:
transform - The outputTransform

getOutputTransform

public com.sas.util.transforms.TransformInterface getOutputTransform()
Retrieve the output transformer that's used when getObjectData gets called.

Specified by:
getOutputTransform in interface RenderableInterface
Returns:
The outputTransform

setVisible

public void setVisible(boolean b)
Sets the visibility parameter for a tbean.

Specified by:
setVisible in interface TransformationInterface
Parameters:
b - true to display the tbean, false otherwise.

isVisible

public boolean isVisible()
Returns whether or not the transformation bean should be written

Specified by:
isVisible in interface TransformationInterface
Returns:
true if the tbean should be visible, false otherwise.

setCleanUpResourcesOn

public void setCleanUpResourcesOn(boolean b)
Set the flag that indicates whether the request and response objects should be set to null once the TransformationBean is rendered. The flag is true by default. This flag allows an application to control this setting in cases where the cleanup should be delayed.

Parameters:
b - set to true by default
See Also:
isCleanUpResourcesOn()

isCleanUpResourcesOn

public boolean isCleanUpResourcesOn()
Return whether the request and response will automatically be set to null once a TransformationBean is rendered.

Returns:
true returned by default
See Also:
#setCleanupResourcesOn(boolean)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener for this TransformationBean

Specified by:
addPropertyChangeListener in interface com.sas.beans.PropertyChangeSource
Parameters:
listener - The listener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener for this TransformationBean

Specified by:
removePropertyChangeListener in interface com.sas.beans.PropertyChangeSource
Parameters:
listener - The listener

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener for this TransformationBean

Parameters:
listener - The listener
propertyName - The property

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener for this TransformationBean

Parameters:
listener - The listener
propertyName - The property

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
Fire a property change event

Parameters:
propertyName - Name of the property
oldValue - Old value of property
newValue - New value of property

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               int oldValue,
                               int newValue)
Fire a property change event

Parameters:
propertyName - Name of the property
oldValue - Old value of property
newValue - New value of property

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               boolean oldValue,
                               boolean newValue)
Fire a property change event

Parameters:
propertyName - Name of the property
oldValue - Old value of property
newValue - New value of property

firePropertyChange

public void firePropertyChange(java.beans.PropertyChangeEvent evt)
Fire a property change event

Parameters:
propertyName - Name of the property
evt - The PropertyChangeEvent to fire

hasListeners

public boolean hasListeners(java.lang.String propertyName)
Check for listeners on the property.

Parameters:
propertyName - Name of the property to check
Returns:
True if the property has listeners.

cleanUpResources

public void cleanUpResources()
This method releases all of the necessary resources that were needed by the transformation bean to render itself. These resources include fields such as request and response. This method calls the setRequest and setResponse methods with a null value.




Copyright © 2009 SAS Institute Inc. All Rights Reserved.