|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sas.Component | +--com.sas.servlet.beans.BaseTransformation | +--com.sas.servlet.beans.BaseTable | +--com.sas.servlet.beans.wml.Table
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:
BaseTable
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.BaseTransformation |
getCustomAttributes,
getDescription,
getName,
getParent,
getRequest,
getResponse,
setCustomAttributes,
setDescription,
setName,
setParent,
setRequest,
setResponse,
toString,
write,
write,
write |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final String DEFAULT_BEGIN_ROW_FORMAT
public static final String DEFAULT_DATA_FORMAT
public static final String DEFAULT_END_ROW_FORMAT
public static final String DEFAULT_COLUMN_HEADING_FORMAT
Constructor Detail |
public Table()
public Table(int columns, ModelInterface model)
columns
- The maximum number of columnsMethod Detail |
public void setAlign(String value)
value
- The alignment of the tablepublic void setTitle(String value)
value
- The title of the tablepublic void setColumns(int value)
value
- The maximum number of columnspublic String getAlign()
public String getTitle()
public int getColumns()
public String getDefaultBeginRowFormat()
public String getDefaultColumnFormat()
public String getDefaultEndRowFormat()
public String getDefaultColumnHeadingFormat()
public void writeTableHeader(PrintWriter out) throws IOException
out
- The output streampublic void writeTableFooter(PrintWriter out) throws IOException
out
- The output streamprotected int getColumnCount(StaticTableInterface model) throws IOException
model
- The table modelprotected String getCell(StaticTableInterface model, long row, int cell) throws IOException
model
- The table modelrow
- The 1-based row numbercell
- The 1-based cell numberpublic int getWidth()
public int getWidthPercentage()
public int getCellSpacing()
public int getBorderWidth()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |