com.sas.servlet.tbeans.tableview.html
Class CellContentsSimpleTemplateRenderer

com.sas.servlet.tbeans.tableview.html.CellContentsSimpleTemplateRenderer
All Implemented Interfaces:
TableCellContentsRenderer, TransformationInterface, java.io.Serializable

public class CellContentsSimpleTemplateRenderer
implements TableCellContentsRenderer

The CellContentsSimpleTemplateRenderer is a TransformationBean™ that generates the appropriate HTML 4.0 based on the contents of a SimpleTemplate. It allows a way to render the cell's content by substituting values from the TableView's model into the template string. The template string can contain any valid html. The substitution variables for the template string should be the NAME of the column.

The getCellContentsRendererComponent method will set the values and variable names from the TableView's model onto the valueDictionary.

The write method will actually call the format method and render its value to the output writer.

For example, assume we have 2 columns in our data model. The COLUMNNAME for column 1 is "Foo" and the COLUMNNAME for column 2 is "Bar". If you want to render the contents of the TableView such that the 1st column of the model is a URL and the 2nd column is the value to display, then you would sent the template string to be:

<a href="%Foo">%Bar</a>

There are other special keys which will also be added to the valueDictionary. These keys extend the flexibility and power that this special cell contents renderer allows in rendering a cell in the table. The special keys are:

  • VIEW_ROW_NUMBER - The row number in reference to the viewer of the current row being rendered.
  • VIEW_COLUMN_NUMBER - The column number in reference to the viewer of the current column being rendered.
  • MODEL_ROW_NUMBER - The row number in reference to the model of the current row being rendered.
  • MODEL_COLUMN_NUMBER - The column number in reference to the model of the current column being rendered.
  • CELL_ACTIONS - The valid actions for this given cell. The value is null if there are no actions.

    For More Information:

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

    Note: A snapshot of the AppDev Studio Developers Site is installed on your local Web server when you install AppDev Studio. To access the site from webAF, select Help -> Developer Site .

    See Also:
    Serialized Form

    Field Summary
     
    Fields inherited from class com.sas.util.SimpleTemplate
    _toStringCache, _toStringCacheClearedOnFormat, _toStringCachingEnabled, allowClassLoading, closec, closeStr, dirty, dmapNames, dmapValues, openc, openStr, RB_KEY, submit_string, temp_string_array, template_string, text_and_token_string_array, vdelimiter, writer
     
    Constructor Summary
    CellContentsSimpleTemplateRenderer()
              Default Constructor
    CellContentsSimpleTemplateRenderer(boolean allowClassLoading)
              Construct a CellContentsSimpleTemplateRenderer object with the specified template
    CellContentsSimpleTemplateRenderer(java.util.Map dictionary)
              Construct a CellContentsSimpleTemplateRenderer with the object that implements the java.util.Map interface.
    CellContentsSimpleTemplateRenderer(java.util.Map dictionary, boolean allowClassLoading)
              Construct a CellContentsSimpleTemplateRenderer with the object that implements the java.util.Map Interface.
    CellContentsSimpleTemplateRenderer(java.lang.String pattern)
              Construct a CellContentsSimpleTemplateRenderer object with the specified template
    CellContentsSimpleTemplateRenderer(java.lang.String pattern, boolean allowClassLoading)
              Construct a CellContentsSimpleTemplateRenderer object with the specified template
    CellContentsSimpleTemplateRenderer(java.lang.String pattern, char marker, char open, char close)
              Construct a CellContentsSimpleTemplateRenderer with the specified template.
    CellContentsSimpleTemplateRenderer(java.lang.String pattern, char marker, char open, char close, boolean allowClassLoading)
              Construct a CellContentsSimpleTemplateRenderer with the specified template.
    CellContentsSimpleTemplateRenderer(java.lang.String pattern, java.util.Map dictionary)
              Construct a CellContentsSimpleTemplateRenderer with the specified template and object that implements the java.util.Map interface.
    CellContentsSimpleTemplateRenderer(java.lang.String pattern, java.util.Map dictionary, char marker, char open, char close)
              Construct a CellContentsSimpleTemplateRenderer with the specified template and object that implements the java.util.Map Interface.
    CellContentsSimpleTemplateRenderer(java.lang.String pattern, java.util.Map dictionary, char marker, char open, char close, boolean allowClassLoading)
              Construct a CellContentsSimpleTemplateRenderer with the specified template and object that implements the java.util.Map Interface.
     
    Method Summary
     ActionList getActions()
              Gets the list of valid actions for this cell.
     TransformationInterface getCellContentsRendererComponent(AbstractBaseTableView viewer, java.lang.Object value, ActionList actions)
              Returns the tbean used for rendering the contents of the tableview's cell.
     java.lang.String getCustomAttributes()
              This method always returns null.
     java.lang.String getDescription()
              This method always returns null.
     java.lang.String getId()
              This method always returns null.
     com.sas.util.transforms.TransformInterface getInputTransform()
              Gets the input transformer to be used when loading values into the valueDictionary.
     java.util.Locale getLocale()
              Gets the locale.
     java.lang.String getName()
              This method always returns null.
     java.lang.String getNullTextString()
              Gets the String value to be written when the cell text is null.
     javax.servlet.http.HttpServletRequest getRequest()
              Gets the current request object.
     javax.servlet.http.HttpServletResponse getResponse()
              Gets the current response object.
     AbstractBaseTableView getTableView()
              Gets the instance of the AbstractBaseTableView containing this cell.
     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 isEncodeText()
              Gets the boolean indicating whether the cell text will be encoded using com.sas.util.Strings.quoteForXML.
     boolean isVisible()
              Returns whether or not the transformation bean should be written
     void setActions(ActionList actions)
              Sets the list of valid actions for this cell.
     void setCustomAttributes(java.lang.String value)
              This method is not implemented.
     void setDescription(java.lang.String value)
              This method is not implemented.
     void setEncodeText(boolean encodeText)
              Sets the boolean indicating whether the cell text will be encoded using com.sas.util.Strings.quoteForXML.
     void setId(java.lang.String value)
              This method is not implemented.
     void setInputTransform(com.sas.util.transforms.TransformInterface transform)
              Sets the input transformer to be used when loading values into the valueDictionary.
     void setLocale(java.util.Locale loc)
              Set the locale
     void setName(java.lang.String value)
              This method is not implemented.
     void setNullTextString(java.lang.String nullTextString)
              Sets the String value to be written when the cell text is null.
     void setRequest(javax.servlet.http.HttpServletRequest request)
              Sets the request object.
     void setResponse(javax.servlet.http.HttpServletResponse response)
              Sets the response object.
     void setTableView(AbstractBaseTableView viewer)
              Sets the instance of the AbstractBaseTableView containing this cell.
     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.
     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 transformed representation of the object.
     void write(java.io.Writer out)
              Writes the transformed representation of the object.
     
    Methods inherited from class com.sas.util.SimpleTemplate
    checkToStringCache, clearToStringCache, findVarDelimiter, format, format, format, format, format, format, formatValueObject, formatWith, formatWith, formatWith, formatWith, formatWith, formatWith, formatWith, formatWith, getClassLoading, getClose, getExtendedBeanInfo, getMarker, getNameDictionary, getNameDictionary, getNameDictionary, getNotFoundNames, getOpen, getTemplate, getTextAndTokens, getValue, getValueDictionary, getWriter, init, init, isToStringCacheClearedOnFormat, isToStringCachingEnabled, notFound, parseFields, parseStringTokens, parseToken, processText, setClassLoading, setClose, setMarker, setOpen, setTemplate, setTextAndTokens, setToStringCacheClearedOnFormat, setToStringCachingEnabled, setValueDictionary, setWriter, tokenizeField, tokenizeTemplate, updateNamesDictionary
     

    Constructor Detail

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer()
    Default Constructor


    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.lang.String pattern)
    Construct a CellContentsSimpleTemplateRenderer object with the specified template

    Parameters:
    pattern - specified template

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.lang.String pattern,
                                              java.util.Map dictionary)
    Construct a CellContentsSimpleTemplateRenderer with the specified template and object that implements the java.util.Map interface.

    Parameters:
    pattern - specified template
    dictionary - collection object that implements java.util.Map interface

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.lang.String pattern,
                                              java.util.Map dictionary,
                                              char marker,
                                              char open,
                                              char close)
    Construct a CellContentsSimpleTemplateRenderer with the specified template and object that implements the java.util.Map Interface.

    Parameters:
    pattern - specified template
    dictionary - colleciton object that implements java.util.Map interface
    marker - the character to used to mark template expansion strings in the template. The default is '%'
    open - the character to use instead of the default '(' to open expansion options after the marker/name
    close - the character to use instead of the default ')' to close expansion options after the marker/name

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.lang.String pattern,
                                              char marker,
                                              char open,
                                              char close)
    Construct a CellContentsSimpleTemplateRenderer with the specified template.

    Parameters:
    pattern - specified template
    marker - the character to used to mark template expansion strings in the template. The default is '%'
    open - the character to use instead of the default '(' to open expansion options after the marker/name
    close - the character to use instead of the default ')' to close expansion options after the marker/name

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.util.Map dictionary)
    Construct a CellContentsSimpleTemplateRenderer with the object that implements the java.util.Map interface.

    Parameters:
    dictionary - collection object that implements java.util.Map interface

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(boolean allowClassLoading)
    Construct a CellContentsSimpleTemplateRenderer object with the specified template

    Parameters:
    allowClassLoading - enable or disable the ability to load classes via the pattern

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.lang.String pattern,
                                              boolean allowClassLoading)
    Construct a CellContentsSimpleTemplateRenderer object with the specified template

    Parameters:
    pattern - specified template
    allowClassLoading - enable or disable the ability to load classes via the pattern

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.lang.String pattern,
                                              java.util.Map dictionary,
                                              char marker,
                                              char open,
                                              char close,
                                              boolean allowClassLoading)
    Construct a CellContentsSimpleTemplateRenderer with the specified template and object that implements the java.util.Map Interface.

    Parameters:
    pattern - specified template
    dictionary - object that implements java.util.Map interface
    marker - the character to used to mark template expansion strings in the template. The default is '%'
    open - the character to use instead of the default '(' to open expansion options after the marker/name
    close - the character to use instead of the default ')' to close expansion options after the marker/name
    allowClassLoading - enable or disable the ability to load classes via the pattern

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.lang.String pattern,
                                              char marker,
                                              char open,
                                              char close,
                                              boolean allowClassLoading)
    Construct a CellContentsSimpleTemplateRenderer with the specified template.

    Parameters:
    pattern - specified template
    marker - the character to used to mark template expansion strings in the template. The default is '%'
    open - the character to use instead of the default '(' to open expansion options after the marker/name
    close - the character to use instead of the default ')' to close expansion options after the marker/name
    allowClassLoading - enable or disable the ability to load classes via the pattern

    CellContentsSimpleTemplateRenderer

    public CellContentsSimpleTemplateRenderer(java.util.Map dictionary,
                                              boolean allowClassLoading)
    Construct a CellContentsSimpleTemplateRenderer with the object that implements the java.util.Map Interface.

    Parameters:
    dictionary - object that implements java.util.Map interface
    allowClassLoading - enable or disable the ability to load classes via the pattern
    Method Detail

    getCellContentsRendererComponent

    public TransformationInterface getCellContentsRendererComponent(AbstractBaseTableView viewer,
                                                                    java.lang.Object value,
                                                                    ActionList actions)
    Returns the tbean used for rendering the contents of the tableview's cell. This method is used to configure the contents renderer appropriately before writing out the component. This method will add the values from the TableView's model for the current row to the valueDictionary. If the valueDictionary has not set then it will create a new one.

    Specified by:
    getCellContentsRendererComponent in interface TableCellContentsRenderer
    Parameters:
    viewer - the instance of the tableview being written.
    value - the value to display as the cell's contents
    actions - an actionlist of all the valid actions for this cell
    Returns:
    the contents renderer for this cell

    write

    public void write(java.io.PrintWriter out)
               throws java.io.IOException
    Writes the transformed representation of the object. This overloaded version of 'write' will call the format() method and write its value to the PrintWriter. This method resets the request and response back to null at the end of the 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(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.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

    setId

    public void setId(java.lang.String value)
    This method is not implemented.

    Specified by:
    setId in interface TransformationInterface
    Parameters:
    value - Not used since this method is not implemented.

    getId

    public java.lang.String getId()
    This method always returns null. This method is not implemented.

    Specified by:
    getId in interface TransformationInterface
    Returns:
    null, method is not implemented

    setCustomAttributes

    public void setCustomAttributes(java.lang.String value)
    This method is not implemented.

    Specified by:
    setCustomAttributes in interface TransformationInterface
    Parameters:
    value - Not used since this method is not implemented.

    getCustomAttributes

    public java.lang.String getCustomAttributes()
    This method always returns null. This method is not implemented.

    Specified by:
    getCustomAttributes in interface TransformationInterface
    Returns:
    null, method is not implemented

    setDescription

    public void setDescription(java.lang.String value)
    This method is not implemented.

    Specified by:
    setDescription in interface TransformationInterface
    Parameters:
    value - Not used since this method is not implemented.

    getDescription

    public java.lang.String getDescription()
    This method always returns null. This method is not implemented.

    Specified by:
    getDescription in interface TransformationInterface
    Returns:
    null, method is not implemented

    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()
    Gets the locale.

    Specified by:
    getLocale in interface TransformationInterface
    Returns:
    an instance of java.util.Locale

    setNullTextString

    public void setNullTextString(java.lang.String nullTextString)
    Sets the String value to be written when the cell text is null. The default is null.

    Parameters:
    nullTextString - The String to be written when the text is null

    getNullTextString

    public java.lang.String getNullTextString()
    Gets the String value to be written when the cell text is null. The default is null.

    Returns:
    The String to be written when the text is null

    setEncodeText

    public void setEncodeText(boolean encodeText)
    Sets the boolean indicating whether the cell text will be encoded using com.sas.util.Strings.quoteForXML. The default is set to true.

    Parameters:
    encodeText - Flag indicating whether to set text encoding.

    isEncodeText

    public boolean isEncodeText()
    Gets the boolean indicating whether the cell text will be encoded using com.sas.util.Strings.quoteForXML. The default is set to True.

    Returns:
    True if the text is to be encoded.

    setName

    public void setName(java.lang.String value)
    This method is not implemented.

    Specified by:
    setName in interface TransformationInterface
    Parameters:
    value - Not used since this method is not implemented.

    getName

    public java.lang.String getName()
    This method always returns null. This method is not implemented.

    Specified by:
    getName in interface TransformationInterface
    Returns:
    null, method is not implemented

    setRequest

    public void setRequest(javax.servlet.http.HttpServletRequest request)
    Sets the request object.

    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:
    javax.servlet.http.HttpServletRequest

    setResponse

    public void setResponse(javax.servlet.http.HttpServletResponse response)
    Sets the response object.

    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:
    javax.servlet.http.HttpServletResponse

    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

    setActions

    public void setActions(ActionList actions)
    Sets the list of valid actions for this cell.

    Specified by:
    setActions in interface TableCellContentsRenderer
    Parameters:
    actions - an actionlist of all the valid actions for this cell

    getActions

    public ActionList getActions()
    Gets the list of valid actions for this cell.

    Specified by:
    getActions in interface TableCellContentsRenderer
    Returns:
    the actionlist of all the valid actions for this cell, or null if not set

    setTableView

    public void setTableView(AbstractBaseTableView viewer)
    Sets the instance of the AbstractBaseTableView containing this cell.

    Specified by:
    setTableView in interface TableCellContentsRenderer
    Parameters:
    tableview - an instance of AbstractBaseTableView containing this cell

    getTableView

    public AbstractBaseTableView getTableView()
    Gets the instance of the AbstractBaseTableView containing this cell.

    Specified by:
    getTableView in interface TableCellContentsRenderer
    Returns:
    the tableview containing this cell

    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.

    setInputTransform

    public void setInputTransform(com.sas.util.transforms.TransformInterface transform)
    Sets the input transformer to be used when loading values into the valueDictionary.

    Parameters:
    transform - The inputTransform

    getInputTransform

    public com.sas.util.transforms.TransformInterface getInputTransform()
    Gets the input transformer to be used when loading values into the valueDictionary.

    Returns:
    The inputTransform



    Copyright © 2009 SAS Institute Inc. All Rights Reserved.