public class HTMLFormConverter extends StringConverter implements java.io.Serializable, HTMLConstants
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 | 
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(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener. 
 | 
void | 
addSectionCompletedListener(SectionCompletedListener listener)
Adds a SectionCompletedListener. 
 | 
void | 
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds the VetoableChangeListener. 
 | 
HTMLTable[] | 
convertToForms(RowData rowdata)
Converts the specified rowdata to an array of forms (one-row HTML tables). 
 | 
java.lang.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. 
 | 
java.lang.String | 
getDirection()
Returns the form text interpretation direction. 
 | 
HTMLHyperlink[] | 
getHeaderHyperlinks()
Returns the form header's hyperlinks. 
 | 
java.lang.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(java.beans.PropertyChangeListener listener)
Removes the PropertyChangeListener from the internal list. 
 | 
void | 
removeSectionCompletedListener(SectionCompletedListener listener)
Removes this SectionCompletedListener from the internal list. 
 | 
void | 
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes the VetoableChangeListener from the internal list. 
 | 
void | 
setAlignment(java.lang.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(java.lang.String dir)
Sets the form text interpretation direction. 
 | 
void | 
setHeaderHyperlinks(HTMLHyperlink[] links)
Sets the form header's hyperlinks. 
 | 
void | 
setLanguage(java.lang.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. 
 | 
convertpublic HTMLFormConverter()
public void addActionCompletedListener(ActionCompletedListener listener)
listener - The ActionCompletedListener.removeActionCompletedListener(com.ibm.as400.access.ActionCompletedListener)public void addPropertyChangeListener(java.beans.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(java.beans.VetoableChangeListener listener)
listener - The VetoableChangeListener.removeVetoableChangeListener(java.beans.VetoableChangeListener)public HTMLTable[] convertToForms(RowData rowdata) throws java.beans.PropertyVetoException, RowDataException
rowdata - The row data.java.beans.PropertyVetoException - If a change is vetoed.RowDataException - If a row data error occurs.public java.lang.String getAlignment()
public int getBorderWidth()
public HTMLTableCaption getCaption()
public int getCellPadding()
public int getCellSpacing()
public java.lang.String getDirection()
public HTMLHyperlink[] getHeaderHyperlinks()
public java.lang.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(java.beans.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(java.beans.VetoableChangeListener listener)
listener - The VetoableChangeListener.addVetoableChangeListener(java.beans.VetoableChangeListener)public void setAlignment(java.lang.String alignment)
                  throws java.beans.PropertyVetoException
alignment - The form alignment.  One of the following constants
  defined in HTMLConstants:  CENTER, LEFT, or RIGHT.java.beans.PropertyVetoException - If the change is vetoed.HTMLConstantspublic void setBorderWidth(int borderWidth)
                    throws java.beans.PropertyVetoException
borderWidth - The border width in pixels.java.beans.PropertyVetoException - If the change is vetoed.public void setCaption(HTMLTableCaption caption) throws java.beans.PropertyVetoException
caption - The caption text.java.beans.PropertyVetoException - If the change is vetoed.public void setCellPadding(int cellPadding)
                    throws java.beans.PropertyVetoException
cellPadding - The cell padding in pixels.java.beans.PropertyVetoException - If the change is vetoed.public void setCellSpacing(int cellSpacing)
                    throws java.beans.PropertyVetoException
cellSpacing - The cell spacing in pixels.java.beans.PropertyVetoException - If the change is vetoed.public void setDirection(java.lang.String dir)
                  throws java.beans.PropertyVetoException
dir - The direction of text interpretation.  One of the following constants
             defined in HTMLConstants:  LTR or RTLjava.beans.PropertyVetoException - If the change is vetoed.HTMLConstantspublic void setHeaderHyperlinks(HTMLHyperlink[] links) throws java.beans.PropertyVetoException
links - The hyperlinks.java.beans.PropertyVetoException - If the change is vetoed.public void setLanguage(java.lang.String lang)
                 throws java.beans.PropertyVetoException
lang - The language.  Example language tags include:
  en and en-US.java.beans.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 java.beans.PropertyVetoException
width - The form width.widthInPercent - true if the width is specified as a percent; false if the width is specified in pixels.java.beans.PropertyVetoException - If the change is vetoed.