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:
-
HTMLFormConverter()
- Constructs a default HTMLFormConverter object.
-
addActionCompletedListener(ActionCompletedListener)
- Adds an ActionCompletedListener.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a PropertyChangeListener.
-
addSectionCompletedListener(SectionCompletedListener)
- Adds a SectionCompletedListener.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds the VetoableChangeListener.
-
convertToForms(RowData)
- Converts the specified rowdata to an array of forms (one-row HTML tables).
-
getAlignment()
- Returns the form alignment.
-
getBorderWidth()
- Returns the form border width.
-
getCaption()
- Returns the form caption.
-
getCellPadding()
- Returns the form cell padding in pixels.
-
getCellSpacing()
- Returns the form cell spacing in pixels.
-
getHeaderHyperlinks()
- Returns the form header's hyperlinks.
-
getObjectHyperlink(RowData, int)
- Returns the object's hyperlink at the specified column within the current row.
-
getObjectHyperlink(RowData, int, int)
- Returns the object's hyperlink at the specified row and column.
-
getWidth()
- Returns the form width in pixels or percent.
-
isWidthInPercent()
- Indicates if the form width is in percent or pixels.
-
removeActionCompletedListener(ActionCompletedListener)
- Removes this ActionCompletedListener from the internal list.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes the PropertyChangeListener from the internal list.
-
removeSectionCompletedListener(SectionCompletedListener)
- Removes this SectionCompletedListener from the internal list.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes the VetoableChangeListener from the internal list.
-
setAlignment(String)
- Sets the form alignment.
-
setBorderWidth(int)
- Sets the form border width in pixels.
-
setCaption(HTMLTableCaption)
-
Sets the form caption.
-
setCellPadding(int)
- Sets the form cell padding in pixels.
-
setCellSpacing(int)
- Sets the form cell spacing in pixels.
-
setHeaderHyperlinks(HTMLHyperlink[])
- Sets the form header's hyperlinks.
-
setObjectHyperlink(RowData, HTMLHyperlink, int)
- Sets the object's hyperlink at the specified column within the current row.
-
setObjectHyperlink(RowData, HTMLHyperlink, int, int)
- Sets the object's hyperlink at the specified row and column.
-
setWidth(int, boolean)
- Sets the form width in pixels or percent.
HTMLFormConverter
public HTMLFormConverter()
- Constructs a default HTMLFormConverter object.
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
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
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
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
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.
getAlignment
public String getAlignment()
- Returns the form alignment.
- Returns:
- The form alignment.
getBorderWidth
public int getBorderWidth()
- Returns the form border width.
- Returns:
- The width in pixels.
getCaption
public HTMLTableCaption getCaption()
- Returns the form caption.
- Returns:
- An HTMLTableCaption object that contains the form caption.
getCellPadding
public int getCellPadding()
- Returns the form cell padding in pixels.
- Returns:
- The cell padding.
getCellSpacing
public int getCellSpacing()
- Returns the form cell spacing in pixels.
- Returns:
- The cell spacing.
getHeaderHyperlinks
public HTMLHyperlink[] getHeaderHyperlinks()
- Returns the form header's hyperlinks.
- Returns:
- The hyperlinks.
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.
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.
getWidth
public int getWidth()
- Returns the form width in pixels or percent.
- Returns:
- The form width.
- See Also:
- isWidthInPercent
isWidthInPercent
public boolean isWidthInPercent()
- Indicates if the form width is in percent or pixels.
- Returns:
- True if percent, false if pixels.
- See Also:
- getWidth
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
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
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
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
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
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.
setCaption
public void setCaption(HTMLTableCaption caption) throws PropertyVetoException
- Sets the form caption.
- Parameters:
- caption - The caption text.
- Throws: PropertyVetoException
- If the change is vetoed.
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.
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.
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.
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.
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.
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