com.sas.servlet.beans
Interface TransformationInterface

All Known Subinterfaces:
CheckboxInterface, ChoiceboxInterface, FormInterface, HiddenInterface, ImageInterface, InputInterface, ListboxInterface, PasswordInterface, PushButtonInterface, RadioInterface, TableInterface, TableWriterInterface, TextAreaInterface, TextInterface, TreeControlInterface
All Known Implementing Classes:
BaseTransformation

public interface TransformationInterface
extends ComponentInterface

The interface that must be implemented 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.beans package contains generic interfaces 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.html. It is anticipated that languages other than HTML (such as XML, JavaScript, and DHTML) may implement the generic interfaces as well.

As an illustration consider the following JSP example (while this example is not complete, it should serve to demonstrate the use of a Transformation Bean)

Problem: Create a document using JSP that contains a drop-down list box (an HTML SELECT element) that allows the client to select a color.

Solution: Write a Java scriptlet in a JSP page that uses a SELECT Transformation Bean to create the HTML element. No knowledge of the underlying SELECT format is necessary. A collection of colors is created and used as a model to the Transformation Bean.

JSP Page:

 <html>
 <head>
 <title>Select Bean</title>
 </head>
 
 <body>
 <p>This example shows a simple drop-down combo box generated by the Select bean.</p>
 <%
    // Create a new select object
    com.sas.servlet.beans.SelectInterface select =
        new com.sas.servlet.beans.html.Select();

// Create the model com.sas.collection.StringCollection model = new com.sas.collection.StringCollection(); model.add("Red"); model.add("Green"); model.add("Orange");
// Set the model select.setModelInterface(model);
// Output the select select.write(out); %> </body> </html>

HTML output:

 <html>
 <head>
 <title>Select Bean</title>
 </head>
 
 <body>
 <p>This example shows a simple drop-down combo box generated by the Select bean.</p>
 <SELECT NAME="Select Box" SIZE=1>
 <OPTION VALUE="Red">Red
 <OPTION VALUE="Green">Green
 <OPTION VALUE="Orange">Orange
 </SELECT>
 </body>
 </html>
 

Live element:


Method Summary
 String getCustomAttributes()
          Gets the custom attributes
 String getDescription()
          Gets the description that will be used to describe this bean to the user.
 String getName()
          Gets the name that will be used to identify the content when it is submitted to the server
 Object getParent()
          Gets the parent object, such as the servlet
 com.sas.servlet.beans.HttpServletRequest getRequest()
          Gets the current request object.
 com.sas.servlet.beans.HttpServletResponse getResponse()
          Gets the current response object.
 void setCustomAttributes(String value)
          Sets any custom attributes.
 void setDescription(String value)
          Sets the description that will be used to describe this bean to the user.
 void setName(String value)
          Sets the name that will be used to identify the content when it is submitted to the server
 void setParent(Object parent)
          Sets the parent object, such as the servlet.
 void setRequest(com.sas.servlet.beans.HttpServletRequest request)
          Sets the request object.
 void setResponse(com.sas.servlet.beans.HttpServletResponse response)
          Sets the response object.
 void write(com.sas.servlet.beans.HttpServletRequest req, com.sas.servlet.beans.HttpServletResponse resp)
          Writes the transformed representation of the object.
 void write(OutputStream out)
          Writes the transformed representation of the object.
 void write(PrintWriter out)
          Writes the transformed representation of the object.
 void write(Writer out)
          Writes the transformed representation of the object.
 
Methods inherited from interface com.sas.ComponentInterface
addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, initialize, initializeComponent, isDesignTime, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues
 
Methods inherited from interface com.sas.ViewInterface
attachModel, detachModel, getModelInterface, getRequiredInterfaces, getViewInterfaceSupportInfo, refresh, removeInterfaceTraps, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsRequiredInterfaces, trapInterfaceEvents
 
Methods inherited from interface com.sas.ModelInterface
attachView, detachView
 
Methods inherited from interface com.sas.LinkPropertiesInterface
addLink, getLinkInfo, isLinked, queryLinks, queryLinks, removeAllLinks, removeLink, setLinkInfo
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface java.io.ObjectInputValidation
validateObject
 

Method Detail

setName

public void setName(String value)
Sets the name that will be used to identify the content when it is submitted to the server
Parameters:
value - The name

getName

public String getName()
Gets the name that will be used to identify the content when it is submitted to the server
Returns:
The name

setDescription

public void setDescription(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.
Parameters:
desc - The description

getDescription

public String getDescription()
Gets the description that will be used to describe this bean to the user.
Returns:
The description

write

public void write(PrintWriter out)
           throws IOException
Writes the transformed representation of the object. This method must be implemented by the Transformation Bean.
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

write

public void write(com.sas.servlet.beans.HttpServletRequest req,
                  com.sas.servlet.beans.HttpServletResponse resp)
           throws com.sas.servlet.beans.ServletException,
                  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.
Parameters:
req - The request object
resp - The response object
Throws:
javax.servlet.ServletException - Thrown if some type of servlet error occurs
IOException - Thrown if some type of I/O error occurs

write

public void write(Writer out)
           throws 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.
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

write

public void write(OutputStream out)
           throws 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.
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

setParent

public void setParent(Object parent)
Sets the parent object, such as the servlet. There may be cases where a Transformation Bean needs to get additional information from the parent class. If this is true, the parent must be set before calling the 'write' method. See the documentation for the Transformation Bean if the parent is required.
Parameters:
parent - The parent object

getParent

public Object getParent()
Gets the parent object, such as the servlet
Returns:
The parent object, or null if not set

setRequest

public void setRequest(com.sas.servlet.beans.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.
Parameters:
request - The request object

getRequest

public com.sas.servlet.beans.HttpServletRequest getRequest()
Gets the current request object.
Returns:
The request object

setResponse

public void setResponse(com.sas.servlet.beans.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.
Parameters:
response - The response object

getResponse

public com.sas.servlet.beans.HttpServletResponse getResponse()
Gets the current response object.
Returns:
The response object

setCustomAttributes

public void setCustomAttributes(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.
Parameters:
value - The custom attribute

getCustomAttributes

public String getCustomAttributes()
Gets the custom attributes
Returns:
The custom attributes


Version: 1.2.20000317.001 Formatted: 2000/07/06 15:57:33PM