jaxcent
Class HtmlTable

java.lang.Object
  extended byjaxcent.JaxcentObject
      extended byjaxcent.JaxcentHtmlElement
          extended byjaxcent.HtmlTable

public class HtmlTable
extends JaxcentHtmlElement

The class HtmlTable corresponds to TABLE tags on the page.


Constructor Summary
HtmlTable(JaxcentPage page, SearchType searchType, java.lang.String str)
          Search for HTML element on page by specified search type and search string.
HtmlTable(JaxcentPage page, SearchType searchType, java.lang.String[] attributes, java.lang.String[] values)
          Create new HTML element on page using the specified attributes and values.
HtmlTable(JaxcentPage page, SearchType searchType, java.lang.String str, int index)
          Search for HTML Element on page by specified search type and search string, and search index.
HtmlTable(JaxcentPage page, SearchType searchType, java.lang.String tag, java.lang.String text)
          Create new HTML Element on page using the specified tag.
HtmlTable(JaxcentPage page, SearchType searchType, java.lang.String text, java.lang.String[] attributes, java.lang.String[] values)
          Create new HTML element on page using the specified text and attributes and values.
HtmlTable(JaxcentPage page, java.lang.String id)
          Search for HTML element on page by specified ID
 
Method Summary
 void addDeleteButtons(int firstRow, int lastRow, java.lang.String buttonHtml, java.lang.String buttonStyles)
          Add Delete button(s) to table rows.
 void deleteAllRows()
          Remove all Rows.
 void deleteFromBottom(int n)
          Remove N rows from bottom.
 void deleteFromTop(int n)
          Remove N rows from top.
 void deleteRow(int index)
          Delete the row at the specified index.
 void disableCellEditing(int firstRow, int firstCol, int lastRow, int lastCol)
          Disable table cells in-place editing.
 void enableCellEditing(int firstRow, int firstCol, int lastRow, int lastCol, boolean doubleClick, boolean allowHtmlInput, java.lang.String editorStyles)
          Make table cells editable in-place.
 int getBorder()
          Retrieve the "border" property
 java.lang.String getCaption()
          Retrieve the "caption" property
 java.lang.String getCellContent(int rowIndex, int cellIndex)
          Retrieve HTML content of a cell.
 int getCellPadding()
          Retrieve the "cellPadding" property
 int getCellSpacing()
          Retrieve the "cellSpacing" property
 java.lang.String getFrame()
          Retrieve the "frame" property
 int getNumRows()
          Returns the number of rows in the table.
 HtmlTableRow getRow(int index)
          Return the row at the specified index.
 java.lang.String[] getRowContent(int rowIndex, int cellIndex, int numCells)
          Retrieve HTML content of a row, starting at a given cellIndex and for a given number of cells.
 java.lang.String getRules()
          Retrieve the "rules" property
 java.lang.String[][] getTableContent(int rowIndex, int cellIndex, int numRows, int[] numCells)
          Retrieve HTML content of multiple rows, starting at a given cellIndex and for the specified number of cells from each row.
 java.lang.String getWidth()
          Retrieve the "width" property
 void includeInFormData(java.lang.String saveKeyName)
          Mark table for its data being sent along with form data.
 HtmlTableRow insertRow(int index, java.lang.String[] innerHTML)
          Insert a row in the table at the specified index.
 HtmlTableRow insertRow(int index, java.lang.String[] innerHTML, java.lang.String[][] attributes, java.lang.String[][] values)
          Insert a row in the table at the specified index, and set attributes of each new cell as specified.
protected  void onBlur()
          Override to handle the "blur" event
protected  void onCellEdited(int rowIndex, int cellIndex, java.lang.String oldContent, java.lang.String newContent)
          Override to handle cell in-place editing.
protected  void onClick()
          Override to handle the "click" event
protected  void onFocus()
          Override to handle the "focus" event
protected  void onMouseDown()
          Override to handle the "mouseDown" event
protected  void onMouseUp()
          Override to handle the "mouseUp" event
protected  void onRowDeleted(int rowIndex)
          Override to handle row deletion.
 void setBorder(int value)
          Set the "border" property
 void setCaption(java.lang.String value)
          Set the "caption" property
 void setCellContent(int rowIndex, int cellIndex, java.lang.String html)
          Set HTML content of a cell.
 void setCellPadding(int value)
          Set the "cellPadding" property
 void setCellSpacing(int value)
          Set the "cellSpacing" property
 void setCellStyles(int firstRow, int firstCol, int lastRow, int lastCol, java.lang.String cellStyleAttributes)
          Set cell STYLE attributes of specified cells.
 void setFrame(java.lang.String value)
          Set the "frame" property
 void setRowContent(int rowIndex, int firstCellIndex, java.lang.String[] html)
          Replace HTML content of a row, starting at a given cell index.
 void setRules(java.lang.String value)
          Set the "rules" property
 void setTableContent(int firstRowIndex, int firstCellIndex, java.lang.String[][] html)
          Replace HTML content of table, starting at a given row/cell index.
 void setWidth(java.lang.String value)
          Set the "width" property
 void startCellEdit(int rowIndex, int cellIndex)
          If cell in-place editing has been enabled on a cell, start in-place cell editing programmatically (instead of upon user click or double-click.)
 
Methods inherited from class jaxcent.JaxcentHtmlElement
checkNodeExists, deleteElement, getAttribute, getID, getInnerText, getStyle, getTag, hide, insertAfter, insertAtBeginning, insertAtBeginning, insertAtEnd, insertAtEnd, insertBefore, onDragDrop, setAttribute, setCssClass, setDraggable, setEnabled, setInnerText, setStyle, setStyle, setStyle, setStyle, setVisible, show
 
Methods inherited from class jaxcent.JaxcentObject
addJavaScriptVerification, getId, getProperty, getSelectedIndex, getSelectedValue, setId, setProperty, setProperty, setProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlTable

public HtmlTable(JaxcentPage page,
                 java.lang.String id)
Search for HTML element on page by specified ID


HtmlTable

public HtmlTable(JaxcentPage page,
                 SearchType searchType,
                 java.lang.String str)
Search for HTML element on page by specified search type and search string. If the search returns multiple objects, use the first one.


HtmlTable

public HtmlTable(JaxcentPage page,
                 SearchType searchType,
                 java.lang.String str,
                 int index)
Search for HTML Element on page by specified search type and search string, and search index. The search is expected to return multiple results. The search index is 0-based, and specifies the index in the multiple results. This constructor is not for use with createNew.


HtmlTable

public HtmlTable(JaxcentPage page,
                 SearchType searchType,
                 java.lang.String tag,
                 java.lang.String text)
          throws Jaxception
Create new HTML Element on page using the specified tag. Search type must be createNew and tag must be "TABLE". If text is non null, the new element is populated with that text.


HtmlTable

public HtmlTable(JaxcentPage page,
                 SearchType searchType,
                 java.lang.String[] attributes,
                 java.lang.String[] values)
          throws Jaxception
Create new HTML element on page using the specified attributes and values. Search type must be createNew. Attributes and values arrays must have the same length.


HtmlTable

public HtmlTable(JaxcentPage page,
                 SearchType searchType,
                 java.lang.String text,
                 java.lang.String[] attributes,
                 java.lang.String[] values)
          throws Jaxception
Create new HTML element on page using the specified text and attributes and values. Search type must be createNew. Attributes and values arrays must have the same length.

Method Detail

onCellEdited

protected void onCellEdited(int rowIndex,
                            int cellIndex,
                            java.lang.String oldContent,
                            java.lang.String newContent)
Override to handle cell in-place editing.

See Also:
enableCellEditing(int, int, int, int, boolean, boolean, java.lang.String)

onRowDeleted

protected void onRowDeleted(int rowIndex)
Override to handle row deletion.

See Also:
addDeleteButtons(int, int, java.lang.String, java.lang.String)

onClick

protected void onClick()
Override to handle the "click" event


onMouseDown

protected void onMouseDown()
Override to handle the "mouseDown" event


onMouseUp

protected void onMouseUp()
Override to handle the "mouseUp" event


onFocus

protected void onFocus()
Override to handle the "focus" event


onBlur

protected void onBlur()
Override to handle the "blur" event


getNumRows

public int getNumRows()
               throws Jaxception
Returns the number of rows in the table.

Throws:
Jaxception

getRow

public HtmlTableRow getRow(int index)
                    throws Jaxception
Return the row at the specified index.

Throws:
Jaxception

deleteRow

public void deleteRow(int index)
               throws Jaxception
Delete the row at the specified index.

Throws:
Jaxception

insertRow

public HtmlTableRow insertRow(int index,
                              java.lang.String[] innerHTML)
                       throws Jaxception
Insert a row in the table at the specified index. If index is -1, the row is inserted at the end. The HTML content of the cells of the row are provided as a string array. Note that the HTML content is "inner" HTML, so the beginning and ending TD tags must not be part of the html.

Throws:
Jaxception

insertRow

public HtmlTableRow insertRow(int index,
                              java.lang.String[] innerHTML,
                              java.lang.String[][] attributes,
                              java.lang.String[][] values)
                       throws Jaxception
Insert a row in the table at the specified index, and set attributes of each new cell as specified. The attribute and value arrays are two dimensional. Their first dimension must be the same length as the "innerHTML" array. Their second dimensions must match with each other. To set style values, specify attribute strings starting with "style.", e.g. "style.color".

Throws:
Jaxception

deleteAllRows

public void deleteAllRows()
                   throws Jaxception
Remove all Rows. Useful before inserting new rows.

Throws:
Jaxception

deleteFromTop

public void deleteFromTop(int n)
                   throws Jaxception
Remove N rows from top. If N is negative, keep -N (abs N) rows, remove rest from top.

Throws:
Jaxception

deleteFromBottom

public void deleteFromBottom(int n)
                      throws Jaxception
Remove N rows from bottom. If N is negative, keep -N (abs N) rows, remove rest from bottom.

Throws:
Jaxception

enableCellEditing

public void enableCellEditing(int firstRow,
                              int firstCol,
                              int lastRow,
                              int lastCol,
                              boolean doubleClick,
                              boolean allowHtmlInput,
                              java.lang.String editorStyles)
                       throws Jaxception
Make table cells editable in-place. Click events cannot be received on table cells that have been made editable. Edits are completed by the ENTER key, cancelled by the ESC key. Completed cell edits can be detected by overriding the onCellEdited method.

Parameters:
firstRow - First row where cells are to be made editable. (0-based. -1 means last row.)
firstCol - First column where cells are to be made editable. (0-based. -1 means last cell.)
lastRow - Last row where cells are to be made editable. (0-based. -1 means last row.)
lastCol - Last column where cells are to be made editable. (0-based. -1 means last cell.)
doubleClick - False to enable editing on single-click, true to enable editing on double-clicks.
allowHtmlInput - If true, user can enter HTML input, e.g. <B>user-input</B> to enter bold text. If false, any < > & characters will be converted to escaped sequences.
editorStyles - Style attributes to be used on the editor. If null or empty, default of "border: 1px solid lightblue; backbround-color: lightyellow;" will be used.
Throws:
Jaxception
See Also:
onCellEdited(int, int, java.lang.String, java.lang.String)

disableCellEditing

public void disableCellEditing(int firstRow,
                               int firstCol,
                               int lastRow,
                               int lastCol)
                        throws Jaxception
Disable table cells in-place editing.

Throws:
Jaxception

addDeleteButtons

public void addDeleteButtons(int firstRow,
                             int lastRow,
                             java.lang.String buttonHtml,
                             java.lang.String buttonStyles)
                      throws Jaxception
Add Delete button(s) to table rows. Row deletes can be detected by overriding the onRowDeleted method.

Parameters:
firstRow - First row to add a delete button. (0-based. -1 means last row.)
lastRow - Last row to add a delete button. (0-based. -1 means last row.)
buttonHtml - Text on the button. Can contain HTML markup. If null or empty, defaults to "Delete".
buttonStyles - Style attributes to be used on the button. For instance, "color: red; font-size: 8px;"If null or empty, button is created with standard attributes.
Throws:
Jaxception
See Also:
onRowDeleted(int)

setCellContent

public void setCellContent(int rowIndex,
                           int cellIndex,
                           java.lang.String html)
                    throws Jaxception
Set HTML content of a cell. Table will be grown if required. Specify rowIndex/cellIndex as -1 to insert past last row/cell.

Throws:
Jaxception

setRowContent

public void setRowContent(int rowIndex,
                          int firstCellIndex,
                          java.lang.String[] html)
                   throws Jaxception
Replace HTML content of a row, starting at a given cell index. Table will be grown if required. Specify rowIndex -1 to insert after last row. Specify firstCellIndex as -1 to new cells at end of rows.

Throws:
Jaxception

setTableContent

public void setTableContent(int firstRowIndex,
                            int firstCellIndex,
                            java.lang.String[][] html)
                     throws Jaxception
Replace HTML content of table, starting at a given row/cell index. Table will be grown if required. Specify firstRowIndex -1 to insert after last row. Specify firstCellIndex as -1 to new cells at end of rows.

Throws:
Jaxception

setCellStyles

public void setCellStyles(int firstRow,
                          int firstCol,
                          int lastRow,
                          int lastCol,
                          java.lang.String cellStyleAttributes)
                   throws Jaxception
Set cell STYLE attributes of specified cells.

Throws:
Jaxception

getCellContent

public java.lang.String getCellContent(int rowIndex,
                                       int cellIndex)
                                throws Jaxception
Retrieve HTML content of a cell. Specify -1 for last row or cell.

Throws:
Jaxception

getRowContent

public java.lang.String[] getRowContent(int rowIndex,
                                        int cellIndex,
                                        int numCells)
                                 throws Jaxception
Retrieve HTML content of a row, starting at a given cellIndex and for a given number of cells. Specify cellIndex 0 and numCells -1 to retrieve entire row.

Throws:
Jaxception

getTableContent

public java.lang.String[][] getTableContent(int rowIndex,
                                            int cellIndex,
                                            int numRows,
                                            int[] numCells)
                                     throws Jaxception
Retrieve HTML content of multiple rows, starting at a given cellIndex and for the specified number of cells from each row. numCells can be null, indicating the contents are to be retrieved from each row, starting at cellIndex and until the end of the row. Otherwise, numCells can be an array of size "numRows", containing the number of cells to be retrieved from each row. Specify numRows -1 to retrieve until end of table, getCellContent( 0, 0, -1, null ) will retrieve contents of the entire table.

Throws:
Jaxception

startCellEdit

public void startCellEdit(int rowIndex,
                          int cellIndex)
                   throws Jaxception
If cell in-place editing has been enabled on a cell, start in-place cell editing programmatically (instead of upon user click or double-click.)

Throws:
Jaxception

includeInFormData

public void includeInFormData(java.lang.String saveKeyName)
Mark table for its data being sent along with form data. This will cause the table data to be included in the data map, as an array of arrays of strings. The data will be saved using the specified "name" as key. The name should not conflict with any form names.

The data will also be saved in the session, if auto-session-data is set. However, the "includeInFormData" setting will not be saved and the table will not be automatically populated at next visit. Resetting the "includeInFormData" setting, as well as populating the table from the session, can be done in the page constructor.


setBorder

public void setBorder(int value)
               throws Jaxception
Set the "border" property

Throws:
Jaxception

getBorder

public int getBorder()
              throws Jaxception
Retrieve the "border" property

Throws:
Jaxception

setCaption

public void setCaption(java.lang.String value)
                throws Jaxception
Set the "caption" property

Throws:
Jaxception

getCaption

public java.lang.String getCaption()
                            throws Jaxception
Retrieve the "caption" property

Throws:
Jaxception

setCellPadding

public void setCellPadding(int value)
                    throws Jaxception
Set the "cellPadding" property

Throws:
Jaxception

getCellPadding

public int getCellPadding()
                   throws Jaxception
Retrieve the "cellPadding" property

Throws:
Jaxception

setCellSpacing

public void setCellSpacing(int value)
                    throws Jaxception
Set the "cellSpacing" property

Throws:
Jaxception

getCellSpacing

public int getCellSpacing()
                   throws Jaxception
Retrieve the "cellSpacing" property

Throws:
Jaxception

setFrame

public void setFrame(java.lang.String value)
              throws Jaxception
Set the "frame" property

Throws:
Jaxception

getFrame

public java.lang.String getFrame()
                          throws Jaxception
Retrieve the "frame" property

Throws:
Jaxception

setRules

public void setRules(java.lang.String value)
              throws Jaxception
Set the "rules" property

Throws:
Jaxception

getRules

public java.lang.String getRules()
                          throws Jaxception
Retrieve the "rules" property

Throws:
Jaxception

setWidth

public void setWidth(java.lang.String value)
              throws Jaxception
Set the "width" property

Throws:
Jaxception

getWidth

public java.lang.String getWidth()
                          throws Jaxception
Retrieve the "width" property

Throws:
Jaxception