|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.as400.util.servlet.StringConverter com.ibm.as400.util.servlet.HTMLFormConverter
public class HTMLFormConverter extends StringConverter implements Serializable, HTMLConstants
The HTMLFormConverter class can be used to convert data from a RowData object to an array of HTML strings or forms.
Each row is converted to a String representation of a one-row HTML table tag that can then be used by a servlet to display the formatted row back to a browser. The one-row table contains the column headers and the data for the individual row.
HTMLFormConverter objects generate the following events:
The following example creates an HTMLFormConverter object and converts the row data to an array of forms (html strings).
// Create an HTMLFormConverter object. HTMLFormConverter converter = new HTMLFormConverter();
// Convert the row data.
// Assume the RowData object was created and initialized in a previous step. String[] html = converter.convert(rowdata);
The following examples creates an HTMLFormConverter object and converts the row data to an array of forms (one-row HTMLTable objects).
// Creates an HTMLFormConverter object. HTMLFormConverter converter = new HTMLFormConverter();
// Convert the row data. Assume the RowData object was created and initialized in a previous step. HTMLTable[] forms = converter.convertToForms(rowdata);
The following example creates an HTMLFormConverter object and sets the column header hyperlinks before doing the conversion.
// Create an HTMLFormConverter object with a border. HTMLFormConverter converter = new HTMLFormConverter(); converter.setBorderWidth(1);
// Create the rowdata. int numberOfColumns = 3; ListMetaData metadata = new ListMetaData(numberOfColumns); metadata.setColumnLabel(0, "Animal ID"); metadata.setColumnLabel(1, "Animal Name"); metadata.setColumnLabel(2, "Date of Birth"); ListRowData rowdata = new ListRowData(metadata);
// Add a row. Object[] data = { new Integer(123456), "Timberwolf", (new Date()).toString() }; rowdata.addRow(data);
// Create the header hyperlinks. HTMLHyperlink[] links = new HTMLHyperlink[numberOfColumns]; links[0] = new HTMLHyperlink("http://www.myZoo.com/IDList.html", "MyZoo Animal Identification List"); links[1] = new HTMLHyperlink("http://www.myZoo.com/animals.html", "MyZoo Animal List"); converter.setHeaderHyperlinks(links);
// Convert the rowdata. String[] html = converter.convert(rowdata); System.out.println(html[0]);
Here is the html output:
<table border="1"> <tr> <th><a href="http://www.myZoo.com/IDList.html">Animal ID</a></th> <td>123456</td> </tr> <tr> <th><a href="http://www.myZoo.com/animals.html">Animal Name</a></th> <td>Timberwolf</td> </tr> <tr> <th>Date of Birth</th> <td>Sun Mar 14 16:00:00 CDT 1999</td> </tr> </table>
Here is what the form will look like in the browser:
Animal ID | 123456 |
---|---|
Animal Name | Timberwolf |
Date of Birth | Sun Mar 14 16:00:00 CDT 1999 |
Modifier and Type | Field and Description |
---|
Fields inherited from interface com.ibm.as400.util.html.HTMLConstants |
---|
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CAPITALS, CENTER, CIRCLE, DISC, JUSTIFY, LARGE_ROMAN, LEFT, LOWER_CASE, LTR, MIDDLE, NUMBERS, RIGHT, RTL, SMALL_ROMAN, SQUARE, TARGET_BLANK, TARGET_PARENT, TARGET_SELF, TARGET_TOP, TEXTTOP, TOP |
Constructor and Description |
---|
HTMLFormConverter()
Constructs a default HTMLFormConverter object. |
Modifier and Type | Method and Description |
---|---|
void |
addActionCompletedListener(ActionCompletedListener listener)
Adds an ActionCompletedListener. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener. |
void |
addSectionCompletedListener(SectionCompletedListener listener)
Adds a SectionCompletedListener. |
void |
addVetoableChangeListener(VetoableChangeListener listener)
Adds the VetoableChangeListener. |
HTMLTable[] |
convertToForms(RowData rowdata)
Converts the specified rowdata to an array of forms (one-row HTML tables). |
String |
getAlignment()
Returns the form alignment. |
int |
getBorderWidth()
Returns the form border width. |
HTMLTableCaption |
getCaption()
Returns the form caption. |
int |
getCellPadding()
Returns the form cell padding in pixels. |
int |
getCellSpacing()
Returns the form cell spacing in pixels. |
String |
getDirection()
Returns the form text interpretation direction. |
HTMLHyperlink[] |
getHeaderHyperlinks()
Returns the form header's hyperlinks. |
String |
getLanguage()
Returns the language of the form. |
HTMLHyperlink |
getObjectHyperlink(RowData rowdata,
int column)
Returns the object's hyperlink at the specified column within the current row. |
HTMLHyperlink |
getObjectHyperlink(RowData rowdata,
int row,
int column)
Returns the object's hyperlink at the specified row and column. |
int |
getWidth()
Returns the form width in pixels or percent. |
boolean |
isWidthInPercent()
Indicates if the form width is in percent or pixels. |
void |
removeActionCompletedListener(ActionCompletedListener listener)
Removes this ActionCompletedListener from the internal list. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes the PropertyChangeListener from the internal list. |
void |
removeSectionCompletedListener(SectionCompletedListener listener)
Removes this SectionCompletedListener from the internal list. |
void |
removeVetoableChangeListener(VetoableChangeListener listener)
Removes the VetoableChangeListener from the internal list. |
void |
setAlignment(String alignment)
Sets the form alignment. |
void |
setBorderWidth(int borderWidth)
Sets the form border width in pixels. |
void |
setCaption(HTMLTableCaption caption)
Sets the form caption. |
void |
setCellPadding(int cellPadding)
Sets the form cell padding in pixels. |
void |
setCellSpacing(int cellSpacing)
Sets the form cell spacing in pixels. |
void |
setDirection(String dir)
Sets the form text interpretation direction. |
void |
setHeaderHyperlinks(HTMLHyperlink[] links)
Sets the form header's hyperlinks. |
void |
setLanguage(String lang)
Sets the language of the form. |
void |
setObjectHyperlink(RowData rowdata,
HTMLHyperlink link,
int column)
Sets the object's hyperlink at the specified column within the current row. |
void |
setObjectHyperlink(RowData rowdata,
HTMLHyperlink link,
int row,
int column)
Sets the object's hyperlink at the specified row and column. |
void |
setWidth(int width,
boolean widthInPercent)
Sets the form width in pixels or percent. |
Methods inherited from class com.ibm.as400.util.servlet.StringConverter |
---|
convert |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HTMLFormConverter()
Method Detail |
---|
public void addActionCompletedListener(ActionCompletedListener listener)
listener
- The ActionCompletedListener.removeActionCompletedListener(com.ibm.as400.access.ActionCompletedListener)
public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addSectionCompletedListener(SectionCompletedListener listener)
listener
- The SectionCompletedListener.removeSectionCompletedListener(com.ibm.as400.util.servlet.SectionCompletedListener)
public void addVetoableChangeListener(VetoableChangeListener listener)
listener
- The VetoableChangeListener.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public HTMLTable[] convertToForms(RowData rowdata) throws PropertyVetoException, RowDataException
rowdata
- The row data.PropertyVetoException
- If a change is vetoed.RowDataException
- If a row data error occurs.public String getAlignment()
public int getBorderWidth()
public HTMLTableCaption getCaption()
public int getCellPadding()
public int getCellSpacing()
public String getDirection()
public HTMLHyperlink[] getHeaderHyperlinks()
public String getLanguage()
public HTMLHyperlink getObjectHyperlink(RowData rowdata, int column)
rowdata
- The RowData object that contains the data.column
- The column number (0-based).public HTMLHyperlink getObjectHyperlink(RowData rowdata, int row, int column)
rowdata
- The RowData object that contains the data.row
- The row number (0-based).column
- The column number (0-based).public int getWidth()
isWidthInPercent()
public boolean isWidthInPercent()
getWidth()
public void removeActionCompletedListener(ActionCompletedListener listener)
listener
- The ActionCompletedListener.addActionCompletedListener(com.ibm.as400.access.ActionCompletedListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void removeSectionCompletedListener(SectionCompletedListener listener)
listener
- The SectionCompltedListener.addSectionCompletedListener(com.ibm.as400.util.servlet.SectionCompletedListener)
public void removeVetoableChangeListener(VetoableChangeListener listener)
listener
- The VetoableChangeListener.addVetoableChangeListener(java.beans.VetoableChangeListener)
public void setAlignment(String alignment) throws PropertyVetoException
alignment
- The form alignment. One of the following constants
defined in HTMLConstants: CENTER, LEFT, or RIGHT.PropertyVetoException
- If the change is vetoed.HTMLConstants
public void setBorderWidth(int borderWidth) throws PropertyVetoException
borderWidth
- The border width in pixels.PropertyVetoException
- If the change is vetoed.public void setCaption(HTMLTableCaption caption) throws PropertyVetoException
caption
- The caption text.PropertyVetoException
- If the change is vetoed.public void setCellPadding(int cellPadding) throws PropertyVetoException
cellPadding
- The cell padding in pixels.PropertyVetoException
- If the change is vetoed.public void setCellSpacing(int cellSpacing) throws PropertyVetoException
cellSpacing
- The cell spacing in pixels.PropertyVetoException
- If the change is vetoed.public void setDirection(String dir) throws PropertyVetoException
dir
- The direction of text interpretation. One of the following constants
defined in HTMLConstants: LTR or RTLPropertyVetoException
- If the change is vetoed.HTMLConstants
public void setHeaderHyperlinks(HTMLHyperlink[] links) throws PropertyVetoException
links
- The hyperlinks.PropertyVetoException
- If the change is vetoed.public void setLanguage(String lang) throws PropertyVetoException
lang
- The language. Example language tags include:
en and en-US.PropertyVetoException
- If the change is vetoed.public void setObjectHyperlink(RowData rowdata, HTMLHyperlink link, int column) throws RowDataException
rowdata
- The RowData object that contains the data.link
- The hyperlink.column
- The column number (0-based).RowDataException
- If a row data error occurs.public void setObjectHyperlink(RowData rowdata, HTMLHyperlink link, int row, int column) throws RowDataException
rowdata
- The RowData object that contains the data.link
- The hyperlink.row
- The row number (0-based).column
- The column number (0-based).RowDataException
- If a row data error occurs.public void setWidth(int width, boolean widthInPercent) throws PropertyVetoException
width
- The form width.widthInPercent
- true if the width is specified as a percent; false if the width is specified in pixels.PropertyVetoException
- If the change is vetoed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |