com.ibm.as400.util.servlet
Class HTMLTableConverter
- java.lang.Object
-
- com.ibm.as400.util.servlet.StringConverter
-
- com.ibm.as400.util.servlet.HTMLTableConverter
-
- All Implemented Interfaces:
- java.io.Serializable
public class HTMLTableConverter extends StringConverter implements java.io.Serializable
The HTMLTableConverter class can be used to convert the data from a RowData object to a single HTML table for a selected group or page of row data, an array of strings or HTML tables. Each resulting HTML table then can be used by a servlet to display the rowdata to a browser.HTMLTableConverter objects generate the following events:
- ActionCompletedEvent
- SectionCompletedEvent
- PropertyChangeEvent
- VetoableChangeEvent
The following example creates an HTMLTableConverter object and does the conversion.
// Create an HTMLTableConverter object. HTMLTableConverter converter = new HTMLTableConverter(); // Setup the table tag with a maximum of 25 rows/table. HTMLTable table = new HTMLTable(); converter.setMaximumTableSize(25); converter.setTable(table); // Convert the row data. // Assume the RowData object was created and initialized in a previous step. String[] html = converter.convert(rowdata);
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description HTMLTableConverter()
Constructs a default HTMLTableConverter object.
-
Method Summary
Methods 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
convertToTable(RowData rowdata, int page)
Converts the row data specified by rowdata at the specified page into an HTMLTable object when using the maximum table size.HTMLTable[]
convertToTables(RowData rowdata)
Converts the row data specified by rowdata into an array of HTMLTable objects.HTMLHyperlink[]
getHeaderHyperlinks()
Returns the table header's hyperlinks.int
getMaximumTableSize()
Returns the maximum number of rows in a table.HTMLHyperlink
getObjectHyperlink(RowData rowdata, int column)
Returns the object hyperlink for the current row's specified column.HTMLHyperlink
getObjectHyperlink(RowData rowdata, int row, int column)
Returns the object's hyperlink at the specified row and column.HTMLTable
getTable()
Returns the default HTML table.boolean
isUseMetaData()
Indicates whether the table header is created using the metadata.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
setHeaderHyperlinks(HTMLHyperlink[] links)
Sets the table header's hyperlinks.void
setMaximumTableSize(int size)
Sets the maximum number of rows in a table.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 row object's hyperlink specified by row and column.void
setTable(HTMLTable table)
Sets the default HTML table to be used during conversion.void
setUseMetaData(boolean useMetaData)
Sets whether the table header is created using the metadata.-
Methods inherited from class com.ibm.as400.util.servlet.StringConverter
convert
-
-
-
-
Constructor Detail
-
HTMLTableConverter
public HTMLTableConverter()
Constructs a default HTMLTableConverter object.
-
-
Method Detail
-
addActionCompletedListener
public void addActionCompletedListener(ActionCompletedListener listener)
Adds an ActionCompletedListener. The specified ActionCompletedListener's actionCompleted method is called each time the table conversion is complete and all the row data is converted. The ActionCompletedListener object is added to a list of ActionCompletedListeners managed by this class; it can be removed with removeActionCompletedListener.- Parameters:
listener
- The ActionCompletedListener.- See Also:
removeActionCompletedListener(com.ibm.as400.access.ActionCompletedListener)
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.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(java.beans.PropertyChangeListener)
-
addSectionCompletedListener
public void addSectionCompletedListener(SectionCompletedListener listener)
Adds a SectionCompletedListener. The specified SectionCompletedListener's sectionCompleted method is called each time the conversion for a single table 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(com.ibm.as400.util.servlet.SectionCompletedListener)
-
addVetoableChangeListener
public void addVetoableChangeListener(java.beans.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(java.beans.VetoableChangeListener)
-
convertToTables
public HTMLTable[] convertToTables(RowData rowdata) throws java.beans.PropertyVetoException, RowDataException
Converts the row data specified by rowdata into an array of HTMLTable objects.- Parameters:
rowdata
- The RowData object that contains the row data.- Returns:
- An array of HTMLTable objects.
- Throws:
java.beans.PropertyVetoException
- If a change is vetoed.RowDataException
- If a row data error occurs.
-
convertToTable
public HTMLTable convertToTable(RowData rowdata, int page) throws java.beans.PropertyVetoException, RowDataException
Converts the row data specified by rowdata at the specified page into an HTMLTable object when using the maximum table size.- Parameters:
rowdata
- The RowData object that contains the row data.page
- The specific page of the row data.- Returns:
- An HTMLTable object.
- Throws:
java.beans.PropertyVetoException
- If a change is vetoed.RowDataException
- If a row data error occurs.
-
getHeaderHyperlinks
public HTMLHyperlink[] getHeaderHyperlinks()
Returns the table header's hyperlinks.- Returns:
- The hyperlinks.
-
getMaximumTableSize
public int getMaximumTableSize()
Returns the maximum number of rows in a table. The default maximum size is 0 (no maximum).- Returns:
- The maximum size.
-
getObjectHyperlink
public HTMLHyperlink getObjectHyperlink(RowData rowdata, int column)
Returns the object hyperlink for the current row's specified column.- 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.
-
getTable
public HTMLTable getTable()
Returns the default HTML table.- Returns:
- The table.
-
isUseMetaData
public boolean isUseMetaData()
Indicates whether the table header is created using the metadata. Default value is false (use existing table header).- Returns:
- true if the metadata is used; false otherwise.
-
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(com.ibm.as400.access.ActionCompletedListener)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.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(java.beans.PropertyChangeListener)
-
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 SectionCompletedListener.- See Also:
addSectionCompletedListener(com.ibm.as400.util.servlet.SectionCompletedListener)
-
removeVetoableChangeListener
public void removeVetoableChangeListener(java.beans.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(java.beans.VetoableChangeListener)
-
setHeaderHyperlinks
public void setHeaderHyperlinks(HTMLHyperlink[] links) throws java.beans.PropertyVetoException
Sets the table header's hyperlinks.- Parameters:
links
- The hyperlinks.- Throws:
java.beans.PropertyVetoException
- If a change is vetoed.
-
setMaximumTableSize
public void setMaximumTableSize(int size) throws java.beans.PropertyVetoException
Sets the maximum number of rows in a table. The default value is 0 (no maximum).- Parameters:
size
- The maximum size.- Throws:
java.beans.PropertyVetoException
- If a 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. The hyperlink is a property of the data object that can be used to link the data object to an Uniform Resource Identifier (URI).- Parameters:
rowdata
- The RowData object that contains the rowdata.link
- The hyperlink tag.column
- The column number (0-based).- Throws:
RowDataException
- If a row data exception occurs.
-
setObjectHyperlink
public void setObjectHyperlink(RowData rowdata, HTMLHyperlink link, int row, int column) throws RowDataException
Sets the row object's hyperlink specified by row and column. The hyperlink is a property of the data object that can be used to link the data object to an Uniform Resource Identifier (URI).- Parameters:
rowdata
- The RowData object that contains the row data.link
- The hyperlink tag.row
- The row number (0-based).column
- The column number (0-based).- Throws:
RowDataException
- If a row data exception occurs.
-
setTable
public void setTable(HTMLTable table) throws java.beans.PropertyVetoException
Sets the default HTML table to be used during conversion. The default table's column headers must be set. The setUseMetaData method can also be used to set the column headers based on the metadata.- Parameters:
table
- The HTML table.- Throws:
java.beans.PropertyVetoException
- If the change is vetoed.- See Also:
setUseMetaData(boolean)
-
setUseMetaData
public void setUseMetaData(boolean useMetaData)
Sets whether the table header is created using the metadata. Default value is false (use existing table header).- Parameters:
useMetaData
- true if the metadata is used; false otherwise.
-
-