All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.util.servlet.HTMLFormConverter

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


Constructor Index

 o HTMLFormConverter()
Constructs a default HTMLFormConverter object.

Method Index

 o addActionCompletedListener(ActionCompletedListener)
Adds an ActionCompletedListener.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a PropertyChangeListener.
 o addSectionCompletedListener(SectionCompletedListener)
Adds a SectionCompletedListener.
 o addVetoableChangeListener(VetoableChangeListener)
Adds the VetoableChangeListener.
 o convertToForms(RowData)
Converts the specified rowdata to an array of forms (one-row HTML tables).
 o getAlignment()
Returns the form alignment.
 o getBorderWidth()
Returns the form border width.
 o getCaption()
Returns the form caption.
 o getCellPadding()
Returns the form cell padding in pixels.
 o getCellSpacing()
Returns the form cell spacing in pixels.
 o getHeaderHyperlinks()
Returns the form header's hyperlinks.
 o getObjectHyperlink(RowData, int)
Returns the object's hyperlink at the specified column within the current row.
 o getObjectHyperlink(RowData, int, int)
Returns the object's hyperlink at the specified row and column.
 o getWidth()
Returns the form width in pixels or percent.
 o isWidthInPercent()
Indicates if the form width is in percent or pixels.
 o removeActionCompletedListener(ActionCompletedListener)
Removes this ActionCompletedListener from the internal list.
 o removePropertyChangeListener(PropertyChangeListener)
Removes the PropertyChangeListener from the internal list.
 o removeSectionCompletedListener(SectionCompletedListener)
Removes this SectionCompletedListener from the internal list.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes the VetoableChangeListener from the internal list.
 o setAlignment(String)
Sets the form alignment.
 o setBorderWidth(int)
Sets the form border width in pixels.
 o setCaption(HTMLTableCaption)
Sets the form caption.
 o setCellPadding(int)
Sets the form cell padding in pixels.
 o setCellSpacing(int)
Sets the form cell spacing in pixels.
 o setHeaderHyperlinks(HTMLHyperlink[])
Sets the form header's hyperlinks.
 o setObjectHyperlink(RowData, HTMLHyperlink, int)
Sets the object's hyperlink at the specified column within the current row.
 o setObjectHyperlink(RowData, HTMLHyperlink, int, int)
Sets the object's hyperlink at the specified row and column.
 o setWidth(int, boolean)
Sets the form width in pixels or percent.

Constructors

 o HTMLFormConverter
 public HTMLFormConverter()
Constructs a default HTMLFormConverter object.

Methods

 o addActionCompletedListener
 public void addActionCompletedListener(ActionCompletedListener listener)
Adds an ActionCompletedListener. The specified ActionCompletedListener's actionCompleted method is called each time the form conversion is complete. The ActionCompletedListener object is added to an internal list of ActionCompletedListeners; it can be removed with removeActionCompletedListener.

Parameters:
listener - The ActionCompletedListener.
See Also:
removeActionCompletedListener
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange method is called each time the value of any bound property is changed.

Parameters:
listener - The PropertyChangeListener.
See Also:
removePropertyChangeListener
 o addSectionCompletedListener
 public void addSectionCompletedListener(SectionCompletedListener listener)
Adds a SectionCompletedListener. The specified SectionCompletedListener's sectionCompleted method is called each time the conversion of a single row to a form is complete. The SectionCompletedListener object is added to an internal list of SectionCompletedListeners; it can be removed with removeSectionCompletedListener.

Parameters:
listener - The SectionCompletedListener.
See Also:
removeSectionCompletedListener
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds the VetoableChangeListener. The specified VetoableChangeListener's vetoableChange method is called each time the value of any constrained property is changed.

Parameters:
listener - The VetoableChangeListener.
See Also:
removeVetoableChangeListener
 o convertToForms
 public HTMLTable[] convertToForms(RowData rowdata) throws PropertyVetoException, RowDataException
Converts the specified rowdata to an array of forms (one-row HTML tables). Each form is a one-row HTML table with the column headers and the data of the individual row.

Parameters:
rowdata - The row data.
Returns:
An array of HTML tables.
Throws: PropertyVetoException
If a change is vetoed.
Throws: RowDataException
If a row data error occurs.
 o getAlignment
 public String getAlignment()
Returns the form alignment.

Returns:
The form alignment.
 o getBorderWidth
 public int getBorderWidth()
Returns the form border width.

Returns:
The width in pixels.
 o getCaption
 public HTMLTableCaption getCaption()
Returns the form caption.

Returns:
An HTMLTableCaption object that contains the form caption.
 o getCellPadding
 public int getCellPadding()
Returns the form cell padding in pixels.

Returns:
The cell padding.
 o getCellSpacing
 public int getCellSpacing()
Returns the form cell spacing in pixels.

Returns:
The cell spacing.
 o getHeaderHyperlinks
 public HTMLHyperlink[] getHeaderHyperlinks()
Returns the form header's hyperlinks.

Returns:
The hyperlinks.
 o getObjectHyperlink
 public HTMLHyperlink getObjectHyperlink(RowData rowdata,
                                         int column)
Returns the object's hyperlink at the specified column within the current row.

Parameters:
rowdata - The RowData object that contains the data.
column - The column number (0-based).
Returns:
The hyperlink.
 o getObjectHyperlink
 public HTMLHyperlink getObjectHyperlink(RowData rowdata,
                                         int row,
                                         int column)
Returns the object's hyperlink at the specified row and column.

Parameters:
rowdata - The RowData object that contains the data.
row - The row number (0-based).
column - The column number (0-based).
Returns:
The hyperlink.
 o getWidth
 public int getWidth()
Returns the form width in pixels or percent.

Returns:
The form width.
See Also:
isWidthInPercent
 o isWidthInPercent
 public boolean isWidthInPercent()
Indicates if the form width is in percent or pixels.

Returns:
True if percent, false if pixels.
See Also:
getWidth
 o removeActionCompletedListener
 public void removeActionCompletedListener(ActionCompletedListener listener)
Removes this ActionCompletedListener from the internal list. If the ActionCompletedListener is not on the list, nothing is done.

Parameters:
listener - The ActionCompletedListener.
See Also:
addActionCompletedListener
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the PropertyChangeListener from the internal list. If the PropertyChangeListener is not on the list, nothing is done.

Parameters:
listener - The PropertyChangeListener.
See Also:
addPropertyChangeListener
 o removeSectionCompletedListener
 public void removeSectionCompletedListener(SectionCompletedListener listener)
Removes this SectionCompletedListener from the internal list. If the SectionCompletedListener is not on the list, nothing is done.

Parameters:
listener - The SectionCompltedListener.
See Also:
addSectionCompletedListener
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes the VetoableChangeListener from the internal list. If the VetoableChangeListener is not on the list, nothing is done.

Parameters:
listener - The VetoableChangeListener.
See Also:
addVetoableChangeListener
 o setAlignment
 public void setAlignment(String alignment) throws PropertyVetoException
Sets the form alignment. The default value is LEFT.

Parameters:
alignment - The form alignment. One of the following constants defined in HTMLConstants: CENTER, LEFT, or RIGHT.
Throws: PropertyVetoException
If the change is vetoed.
See Also:
HTMLConstants
 o setBorderWidth
 public void setBorderWidth(int borderWidth) throws PropertyVetoException
Sets the form border width in pixels. A value of zero indicates no border. The default value is zero.

Parameters:
borderWidth - The border width in pixels.
Throws: PropertyVetoException
If the change is vetoed.
 o setCaption
 public void setCaption(HTMLTableCaption caption) throws PropertyVetoException
Sets the form caption.

Parameters:
caption - The caption text.
Throws: PropertyVetoException
If the change is vetoed.
 o setCellPadding
 public void setCellPadding(int cellPadding) throws PropertyVetoException
Sets the form cell padding in pixels. The cell padding is the spacing between data in the form and the border of the form cell. The default value is zero (browser default used).

Parameters:
cellPadding - The cell padding in pixels.
Throws: PropertyVetoException
If the change is vetoed.
 o setCellSpacing
 public void setCellSpacing(int cellSpacing) throws PropertyVetoException
Sets the form cell spacing in pixels. The cell spacing is the spacing between the form cells. The default value is zero (browser default used).

Parameters:
cellSpacing - The cell spacing in pixels.
Throws: PropertyVetoException
If the change is vetoed.
 o setHeaderHyperlinks
 public void setHeaderHyperlinks(HTMLHyperlink links[]) throws PropertyVetoException
Sets the form header's hyperlinks.

Parameters:
links - The hyperlinks.
Throws: PropertyVetoException
If the change is vetoed.
 o setObjectHyperlink
 public void setObjectHyperlink(RowData rowdata,
                                HTMLHyperlink link,
                                int column) throws RowDataException
Sets the object's hyperlink at the specified column within the current row.

Parameters:
rowdata - The RowData object that contains the data.
link - The hyperlink.
column - The column number (0-based).
Throws: RowDataException
If a row data error occurs.
 o setObjectHyperlink
 public void setObjectHyperlink(RowData rowdata,
                                HTMLHyperlink link,
                                int row,
                                int column) throws RowDataException
Sets the object's hyperlink at the specified row and column.

Parameters:
rowdata - The RowData object that contains the data.
link - The hyperlink.
row - The row number (0-based).
column - The column number (0-based).
Throws: RowDataException
If a row data error occurs.
 o setWidth
 public void setWidth(int width,
                      boolean widthInPercent) throws PropertyVetoException
Sets the form width in pixels or percent.

Parameters:
width - The form width.
widthInPercent - true if the width is specified as a percent; false if the width is specified in pixels.
Throws: PropertyVetoException
If the change is vetoed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index