com.sas.servlet.beans.wml
Class Table

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.BaseTable
                    |
                    +--com.sas.servlet.beans.wml.Table

public class Table
extends BaseTable

Transformation bean for creating WML tables. See the WMLBaseTable documentation for additional information.

The following example illustrates the use of the WML Table Transformation Bean. A new model that implements com.sas.table.StaticTableInterface will be created. In this case a com.sas.models.SimpleTable object will be used, but a com.sas.sasserver.dataset.DataSetInterface model can be used as well. Once the model is created the Table Transformation Bean can be used to represent the table (the WML-specific Table Transformation Bean will be used).

 // Create an instance of the SimpleTable object
 com.sas.models.SimpleTable weather = new com.sas.models.SimpleTable();
 weather.initialize();

// Define the columns for the model
// Add the column for the day weather.addColumn(1, java.lang.String.class, null); // Add the column for the daily forecast weather.addColumn(2, java.lang.String.class, null); // Add the column for the temperature weather.addColumn(3, java.lang.String.class, null); // Add the rows for Friday, Saturday, and Sunday weather.addRow(1, new Object[] { "Friday", "Sunny", new Double(76.2) } ); weather.addRow(2, new Object[] { "Saturday", "Cloudy", new Double(57.7) } ); weather.addRow(3, new Object[] { "Sunday", "Stormy", new Double(52.3) } );

Now that the model has been created the WML Table Transformation Bean can be used to read the data from the model and format the 2-dimensional table

Example: Use the default properties to format a table

JSP Page:

 

<% Response.setContentType("text/vnd.wap.wml") %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id='card1' title='WML Table' > <p> <% // Create the weather model (shown above) ...
// Create the Table Transformation Bean com.sas.servlet.beans.TableInterface table = new com.sas.servlet.beans.wml.Table();
// Set the model table.setModelInterface(weather);
// Output the table table.write(out); %> </p> </card> </wml>

WML output:

  <?xml version="1.0"?>
 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
 "http://www.wapforum.org/DTD/wml_1.1.xml">
 <wml>
 <card id="card1" title="WML Table">
 <p>
 <table columns="3" title="TABLE">
 <tr>
 <td>Friday</td>
 <td>Sunny</td>
 <td>76.2</td>
 </tr>
 <tr>
 <td>Saturday</td>
 <td>Cloudy</td>
 <td>57.7</td>
 </tr>
 <tr>
 <td>Sunday</td>
 <td>Stormy</td>
 <td>52.3</td>
 </tr>
 </table>
 </p>
 </card>
 </wml>
 

Browser WML Table:

table1.jpg

BaseTable

See Also:
Serialized Form

Field Summary
static String DEFAULT_BEGIN_ROW_FORMAT
          The format which is returned for getDefaultBeginRowFormat().
static String DEFAULT_COLUMN_HEADING_FORMAT
          The format which is returned for getDefaultColumnHeadingFormat().
static String DEFAULT_DATA_FORMAT
          The format which is returned for getDefaultDataFormat().
static String DEFAULT_END_ROW_FORMAT
          The format which is returned for getDefaultEndRowFormat().
 
Fields inherited from class com.sas.servlet.beans.BaseTable
MARKER, MARKER_ESC, MARKER_META, MARKER_META_ROWID
 
Constructor Summary
Table()
          Construct a new Table object
Table(int columns, ModelInterface model)
          Construct a new Table object with a maximum number of columns and a model
 
Method Summary
 String getAlign()
          Gets the alignment of the table return the alignment
 int getBorderWidth()
          Gets the width of the outer border around the table.
protected  String getCell(StaticTableInterface model, long row, int cell)
          Returns the string representation of the given cell from the current row in the table.
 int getCellSpacing()
          Gets the number of pixels between the border of each cell.
protected  int getColumnCount(StaticTableInterface model)
          Gets the number of columns in the current table
 int getColumns()
          Gets the maximum number of columns.
 String getDefaultBeginRowFormat()
          Gets the default format to begin a new table row.
 String getDefaultColumnFormat()
          Gets the default format to be applied to each data element in a row.
 String getDefaultColumnHeadingFormat()
          Gets the default format to be applied to each column heading.
 String getDefaultEndRowFormat()
          Gets the default format to end a table row.
 String getTitle()
          Gets the title of the table.
 int getWidth()
          Gets the width of the table in pixels.
 int getWidthPercentage()
          Gets the width of the table as a percentage
 void setAlign(String value)
          Sets the alignment of the table.
 void setColumns(int value)
          Sets the maximum number of columns to be displayed.
 void setTitle(String value)
          Sets the title of the table.
 void writeTableFooter(PrintWriter out)
          Writes the table footer which closes the "<table>" tag with
 void writeTableHeader(PrintWriter out)
          Writes the table header "<table>" as well as all the table attributes: columns, title and align
 
Methods inherited from class com.sas.servlet.beans.BaseTable
formatRow, getBeginRowFormat, getCellPadding, getColumnFormat, getColumnFormat, getColumnFormat, getColumnFormat, getColumnHeadingColumnFormat, getColumnHeadingColumnFormat, getColumnHeadingFormat, getColumnIndex, getColumnIndex, getColumnInfo, getEndRowFormat, getMaxRows, getRequiredInterfaces, getRowFormat, getRowFormat, getUseColumnHeadings, hasRepeatingFormats, isLastWriteTruncated, isMetaTag, rowExists, setBeginRowFormat, setBorderWidth, setCellPadding, setCellSpacing, setColumnFormat, setColumnFormat, setColumnFormat, setColumnFormat, setColumnFormat, setColumnHeadingColumnFormat, setColumnHeadingColumnFormat, setColumnHeadingFormat, setEndRowFormat, setMaxRows, setModelInterface, setRowFormat, setRowFormat, setUseColumnHeadings, setWidth, setWidthPercentage, write, writeColumnHeadings, writeColumnHeadings, writeColumnHeadings, writeRow, writeRow, writeRow, writeTable, writeTableFooter, writeTableFooter, writeTableHeader, writeTableHeader
 
Methods inherited from class com.sas.servlet.beans.BaseTransformation
getCustomAttributes, getDescription, getName, getParent, getRequest, getResponse, setCustomAttributes, setDescription, setName, setParent, setRequest, setResponse, toString, write, write, write
 
Methods inherited from class com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getExtendedBeanInfo, getLinkInfo, getModelInterface, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BEGIN_ROW_FORMAT

public static final String DEFAULT_BEGIN_ROW_FORMAT
The format which is returned for getDefaultBeginRowFormat(). The default format is <tr>

DEFAULT_DATA_FORMAT

public static final String DEFAULT_DATA_FORMAT
The format which is returned for getDefaultDataFormat(). The default format is <td>##</td>

DEFAULT_END_ROW_FORMAT

public static final String DEFAULT_END_ROW_FORMAT
The format which is returned for getDefaultEndRowFormat(). The default format is </tr>

DEFAULT_COLUMN_HEADING_FORMAT

public static final String DEFAULT_COLUMN_HEADING_FORMAT
The format which is returned for getDefaultColumnHeadingFormat(). The default format is <td><b>#META_NAME#</b></td>
Constructor Detail

Table

public Table()
Construct a new Table object

Table

public Table(int columns,
             ModelInterface model)
Construct a new Table object with a maximum number of columns and a model
Parameters:
columns - The maximum number of columns
Method Detail

setAlign

public void setAlign(String value)
Sets the alignment of the table.
Parameters:
value - The alignment of the table

setTitle

public void setTitle(String value)
Sets the title of the table.
Parameters:
value - The title of the table

setColumns

public void setColumns(int value)
Sets the maximum number of columns to be displayed.
Parameters:
value - The maximum number of columns

getAlign

public String getAlign()
Gets the alignment of the table return the alignment

getTitle

public String getTitle()
Gets the title of the table.
Returns:
the title of the table.

getColumns

public int getColumns()
Gets the maximum number of columns.
Returns:
the maximum number of columns.

getDefaultBeginRowFormat

public String getDefaultBeginRowFormat()
Gets the default format to begin a new table row.
Returns:
The default begin row format

getDefaultColumnFormat

public String getDefaultColumnFormat()
Gets the default format to be applied to each data element in a row.
Returns:
The default data format

getDefaultEndRowFormat

public String getDefaultEndRowFormat()
Gets the default format to end a table row.
Returns:
The default end row format

getDefaultColumnHeadingFormat

public String getDefaultColumnHeadingFormat()
Gets the default format to be applied to each column heading.
Returns:
The default column heading format

writeTableHeader

public void writeTableHeader(PrintWriter out)
                      throws IOException
Writes the table header "<table>" as well as all the table attributes: columns, title and align
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeTableFooter

public void writeTableFooter(PrintWriter out)
                      throws IOException
Writes the table footer which closes the "<table>" tag with
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

getColumnCount

protected int getColumnCount(StaticTableInterface model)
                      throws IOException
Gets the number of columns in the current table
Parameters:
model - The table model
Returns:
The number of columns
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
getColumnCount in class BaseTable

getCell

protected String getCell(StaticTableInterface model,
                         long row,
                         int cell)
                  throws IOException
Returns the string representation of the given cell from the current row in the table.
Parameters:
model - The table model
row - The 1-based row number
cell - The 1-based cell number
Returns:
The string representation of the cell
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
getCell in class BaseTable

getWidth

public int getWidth()
Gets the width of the table in pixels.
Returns:
width cannot be specified for WML Table. Therefore, getWidth will always return 0
Overrides:
getWidth in class BaseTable

getWidthPercentage

public int getWidthPercentage()
Gets the width of the table as a percentage
Returns:
widthPercentage cannot be specified for WML Table. Therefore, getWidthPercentage will always return 0
Overrides:
getWidthPercentage in class BaseTable

getCellSpacing

public int getCellSpacing()
Gets the number of pixels between the border of each cell.
Returns:
cellSpacing cannot be specified for WML Table. Therefore, getCellSpacing will always return 0
Overrides:
getCellSpacing in class BaseTable

getBorderWidth

public int getBorderWidth()
Gets the width of the outer border around the table.
Returns:
borderWidth cannot be specified for WML Table. Therefore, getBorderWidth will always return 0
Overrides:
getBorderWidth in class BaseTable


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