public interface Table extends Element
Table
interface represents a table defined in a form, integration service or workflow job.
Individual tables can be accessed via the Tables
interface.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SORT_DIRECTION_ASCENDING
A constant for sort direction ascending for use with the sort() methods
|
static java.lang.String |
SORT_DIRECTION_DESCENDING
A constant for sort direction descending for use with the sort() methods
|
Modifier and Type | Method and Description |
---|---|
void |
copyTable(Table fromTable,
boolean removeExistingRows)
Optionally removes all existing rows and then copies rows from the table specified by
fromTable . |
boolean |
deleteRow()
Deletes the current row (see
getCurrentRow() ) in the table. |
boolean |
deleteRow(int row)
Deletes the specified row in the table.
|
TableRowIterator |
fetchTable()
Loads data into the table from the external resource specified as the backing resource, and sets the first row
as the current row (see
getCurrentRow() ). |
TableRowIterator |
fetchTable(boolean noUpdate)
Loads data into the table from the external resource specified as the backing resource, and sets the first row
as the current row (see
getCurrentRow() ). |
int |
findRow(TableColumn column,
java.lang.Object value)
Returns the first row number with the specified column value, or -1 if no match is found.
|
TableRowIterator |
findRows(java.util.Map<java.lang.String,java.lang.Object> parms)
Returns a row iterator object containing all rows that match the search criteria specified by
parms . |
TableColumn |
getColumn(java.lang.String columnName)
Returns the specified table column or null if the column does not exist.
|
TableColumn[] |
getColumns()
Returns an array of all columns in the table.
|
java.lang.Object |
getColumnValueOnRow(TableColumn column,
int row)
Returns an
Object representing the value of the table cell at the specified column and row. |
int |
getCurrentRow()
Returns the row number for the table's current row.
|
int |
getRowCount()
Returns the number of rows in the table.
|
TableRowIterator |
getRows()
Returns a row iterator object that can be used to traverse all table rows
|
TableColumn[] |
getSortColumns()
Returns an
Array of all the columns that are currently sorted. |
java.lang.String[] |
getSortDirections()
Returns an
Array of all the directions that are currently sorted. |
int |
insertRow()
Inserts a new row into the table and sets this row as the current row of the table (see
getCurrentRow() ). |
boolean |
isRowDeletedByUser()
Returns true if the current row (see
getCurrentRow() ) is marked as deleted by the user. |
boolean |
isRowDeletedByUser(int row)
Returns true if the specified row is marked as deleted by the user.
|
boolean |
isRowEmpty()
Returns true if the current row (see
getCurrentRow() ) is marked as empty. |
boolean |
isRowEmpty(int row)
Returns true if the specified row is marked as empty.
|
boolean |
isRowInserted()
Returns true if the current row (see
getCurrentRow() ) has been inserted. |
boolean |
isRowInserted(int row)
Returns true if the specified row has been inserted.
|
boolean |
isRowModified()
Returns true if the current row (see
getCurrentRow() ) has been modified. |
boolean |
isRowModified(int row)
Returns true if the specified row has been modified.
|
boolean |
isRowSelected()
Returns true if the current row (see
getCurrentRow() ) is marked as selected |
boolean |
isRowSelected(int row)
Returns true if the specified row is marked as selected.
|
void |
loadFromJSON(java.lang.String jsonString)
Loads rows from a JSON string into the table.
|
void |
replaceTable(Table fromTable)
Removes all existing rows and copies rows from the table specified by
fromTable . |
void |
resetTable()
Removes all rows from the table and resets the current row (see
getCurrentRow() ). |
void |
setColumnValueOnRow(TableColumn column,
int row,
java.lang.Object value)
Sets a value for the table cell at the specified column and row.
|
void |
setCurrentRow(int row)
Sets the table's current row.
|
void |
setRowDeletedByUser(boolean deleted)
Sets the deleted by the user status for the current row (see
getCurrentRow() ). |
void |
setRowDeletedByUser(int row,
boolean deleted)
Sets the deleted by the user status for the specified row.
|
void |
setRowEmpty(boolean empty)
Sets the empty status for the current row (see
getCurrentRow() ). |
void |
setRowEmpty(int row,
boolean empty)
Sets the empty status for the specified row.
|
void |
setRowSelected(boolean selected)
Sets the selected flag for the current row (see
getCurrentRow() ). |
void |
setRowSelected(int row,
boolean selected)
Sets the selected flag for the specified row.
|
void |
sort(TableColumn column)
Sorts the table rows using the single column specified by
column in ascending order. |
void |
sort(TableColumn[] columns)
Sorts the table rows using multiple columns in ascending order.
|
void |
sort(TableColumn[] columns,
java.lang.String[] directions)
Sorts the table rows using multiple columns.
|
void |
sort(TableColumn column,
java.lang.String direction)
Sorts the table rows using the single column specified by
column in the order
specified by direction . |
java.lang.String |
toJSON()
Returns a JSON string representing all rows in the table in the following format:
|
java.lang.String |
toJSON(boolean excludeNullValues)
Returns a JSON string representing all rows in the table, this is the same as
toJSON() but additionally provides
an option on how null values in table columns are handled. |
void |
updateTable()
Updates the external resource specified as the backing resource for the table with the table data,
deleting, inserting, and updating rows as required.
|
getElementName, getElementType
static final java.lang.String SORT_DIRECTION_ASCENDING
static final java.lang.String SORT_DIRECTION_DESCENDING
TableRowIterator fetchTable() throws com.ebasetech.xi.exceptions.FormRuntimeException
getCurrentRow()
). All internal row numbers are reset.
Javascript example:
var orders = tables.ORDERS; var rows = orders.fetchTable(); while (rows.next()) { orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate; }
com.ebasetech.xi.exceptions.FormRuntimeException
updateTable()
TableRowIterator fetchTable(boolean noUpdate) throws com.ebasetech.xi.exceptions.FormRuntimeException
getCurrentRow()
). All internal row numbers are reset.
The noUpdate
flag provides an optional optimization. When this flag is set to true, the amount of memory
required to support the table content data is reduced by about 50%; however, it is not possible to use the updateTable()
method.
It is recommended that this option should be used for all read only tables.
Javascript example:
var orders = tables.ORDERS; var rows = orders.fetchTable(true); while (rows.next()) { orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate; }
noUpdate
- when true indicates that the table will not be updated with updateTable()
com.ebasetech.xi.exceptions.FormRuntimeException
updateTable()
void updateTable() throws com.ebasetech.xi.exceptions.FormRuntimeException
getCurrentRow()
) may be changed by this command.
Javascript example:
tables.ORDERS.updateTable();
com.ebasetech.xi.exceptions.FormRuntimeException
fetchTable()
void replaceTable(Table fromTable) throws com.ebasetech.xi.exceptions.FormRuntimeException
fromTable
.
This method is equivalent to calling copyTable(fromTable, true)
.
Rows flagged as empty in fromTable
are ignored.
Any rows in fromTable
that have been deleted using the deleteRow()
method are ignored.
All other rows are copied.
All columns having the same name in each table are copied e.g. if T1 has columns A, B, C, D and T2 has
columns B, C, X, Y, T1.replaceTable(T2)
will result in data from columns B and C being copied.
Any other columns in T1 will be set to null or the column's default value.
The current row (see getCurrentRow()
) is set to the first row after the copy.
The table specified by fromTable
is unaffected and is not changed in any way.
Javascript example:
tables.ORDERS.replaceTable(tables.ORDERS_SAVE);
fromTable
- the source table from which rows are copiedcom.ebasetech.xi.exceptions.FormRuntimeException
fetchTable()
void copyTable(Table fromTable, boolean removeExistingRows) throws com.ebasetech.xi.exceptions.FormRuntimeException
fromTable
.
Rows flagged as empty in fromTable
are ignored.
Any rows in fromTable
that have been deleted using the deleteRow()
method are ignored.
All other rows are copied.
All columns having the same name in each table are copied e.g. if T1 has columns A, B, C, D and T2 has
columns B, C, X, Y, T1.copyTable(T2, true)
will result in data from columns B and C being copied.
Any other columns in T1 will be set to null or the column's default value.
The current row (see getCurrentRow()
) is set to the first row after the copy.
The table specified by fromTable
is unaffected and is not changed in any way.
Javascript example:
tables.ORDERS.copyTable(tables.ORDERS_SAVE, false);
fromTable
- the source table from which rows are copiedremoveExistingRows
- if true, all existing rows are removed from the table prior to copyingcom.ebasetech.xi.exceptions.FormRuntimeException
fetchTable()
void resetTable()
getCurrentRow()
).
Javascript example:
tables.ORDERS.resetTable();Note that resetTable() will not result in the deletion of records from a backing resource specified for the table e.g. a Database Resource. i.e. any subsequent
updateTable()
method will not remove these rows from the attached resource. To remove all
rows from the table and the backing resource use:
var t1 = tables.MyTable; var rows = t1.rows; while (rows.next()) { t1.deleteRow(); } t1.updateTable();
replaceTable(Table)
,
updateTable()
TableRowIterator getRows()
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate; }
fetchTable()
int getRowCount()
fetchTable()
TableColumn getColumn(java.lang.String columnName)
columnName
is a valid Java name,
the column can more easily be accessed as tableName.columnName
e.g. T1.COL1
, however use
of this method is the only way to access column names that are not valid Java names.
Javascript example:
var col = tables.ORDERS.getColumn("2XX");
TableColumn[] getColumns()
Javascript example:
var cols = tables.ORDERS.getColumns(); for each (var col in cols) { log(col.elementName + ": " + col.value); }
boolean deleteRow()
getCurrentRow()
) in the table.
When the table is backed by an external resource such as a database,
the row will be deleted from this resource when a subsequent updateTable()
method is invoked.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (shouldDeleteOrder()) { orders.deleteRow(); } }
boolean isRowSelected()
getCurrentRow()
) is marked as selected
A row can be marked as selected by:
setRowSelected(boolean)
or setRowSelected(int, boolean)
method
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowSelected()) { .. } }
boolean isRowDeletedByUser()
getCurrentRow()
) is marked as deleted by the user.
A row can be marked as deleted by the user by:
setRowDeletedByUser(boolean)
or setRowDeletedByUser(int, boolean)
method
deleteRow()
or deleteRow(int)
methods are not marked
as deleted by the user.
Note that the deleted by the user status is removed when updateTable()
is called.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowDeletedByUser()) { .. } }
boolean isRowInserted()
getCurrentRow()
) has been inserted.
Note that the inserted status is removed when updateTable()
is called.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowInserted()) { .. } }
boolean isRowEmpty()
getCurrentRow()
) is marked as empty.
A row is marked as empty when:
setRowEmpty(boolean)
or setRowEmpty(int, boolean)
is called
updateTable()
method.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowEmpty()) { .. } }
boolean isRowModified()
getCurrentRow()
) has been modified.
Note that inserted or deleted rows will always return false.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowModified()) { .. } }
boolean deleteRow(int row)
When the table is backed by an external resource such as a database,
the row will be deleted from this resource when a subsequent updateTable()
method is invoked.
Javascript example:
var deleted = tables.ORDERS.deleteRow(rowNum);
row
- numberboolean isRowSelected(int row)
IllegalArgumentException
if row
is not a valid row number.
A row can be marked as selected by:
setRowSelected(boolean)
or setRowSelected(int, boolean)
method
Javascript example:
if (tables.ORDERS.isRowSelected(rowNum)) { .. }
row
- numberboolean isRowDeletedByUser(int row)
IllegalArgumentException
if row
is not a valid row number.
A row can be marked as deleted by the user by:
setRowDeletedByUser(boolean)
or setRowDeletedByUser(int, boolean)
method
deleteRow()
or deleteRow(int)
methods are not marked
as deleted by the user.
Note that the deleted by the user status is removed when updateTable()
is called.
Javascript example:
if (tables.ORDERS.isRowDeletedByUser(rowNum)) { .. }
row
- numberboolean isRowInserted(int row)
IllegalArgumentException
if row
is not a valid row number.
Note that the inserted status is removed when updateTable()
is called.
Javascript example:
if (orders.isRowInserted(rowNum)) { .. }
row
- numberboolean isRowEmpty(int row)
IllegalArgumentException
if row
is not a valid row number.
A row is marked as empty when:
setRowEmpty(boolean)
or setRowEmpty(int, boolean)
is called
updateTable()
method.
Javascript example:
if (orders.isRowEmpty(rowNum)) { .. }
row
- numberupdateTable()
boolean isRowModified(int row)
IllegalArgumentException
if row
is not a valid row number. Note that inserted or deleted rows will always return false.
Javascript example:
if (orders.isRowModified(rowNum)) { .. }
row
- numbervoid setRowSelected(boolean selected)
getCurrentRow()
).
The selected status can be displayed to the user by adding a select column checkbox to a Table Control.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.setRowSelected(false); }
selected
- isRowSelected()
void setRowSelected(int row, boolean selected)
IllegalArgumentException
if row
is not a valid row number.
The selected status can be displayed to the user by adding a select column checkbox to a Table Control.
Javascript example:
tables.ORDERS.setRowSelected(rowNum, false);
row
- numberselected
- isRowSelected(int)
void setRowDeletedByUser(boolean deleted)
getCurrentRow()
).
Note that the deleted by the user status is removed when updateTable()
is called.
The deleted by the user status can be displayed to the user by adding a delete column checkbox to a Table Control.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.setRowDeletedByUser(false); }
deleted
- isRowDeletedByUser()
void setRowDeletedByUser(int row, boolean deleted)
IllegalArgumentException
if row
is not a valid row number. Note that the deleted by the user status is removed when updateTable()
is called.
The deleted by the user status can be displayed to the user by adding a delete column checkbox to a Table Control.
Javascript example:
tables.ORDERS.setRowDeletedByUser(rowNum, false);
row
- numberdeleted
- isRowDeletedByUser(int)
void setRowEmpty(boolean empty)
getCurrentRow()
). Rows marked as empty are ignored by the updateTable()
method.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.setRowEmpty(false); }
empty
- isRowEmpty()
void setRowEmpty(int row, boolean empty)
updateTable()
method.
Throws an IllegalArgumentException
if row
is not a valid row number.
Javascript example:
tables.ORDERS.setRowEmpty(rowNum, false);
row
- numberempty
- isRowEmpty(int)
int insertRow()
getCurrentRow()
).
The columns in the row are initialized with their default values or null as appropriate.
Inserted rows are displayed at the bottom of a Table Control.
Javascript example:
var newRowNum = tables.ORDERS.insertRow();
int findRow(TableColumn column, java.lang.Object value)
Javascript example:
var row = tables.ORDERS.findRow(tables.ORDERS.ORDER_ID, fields.SEARCH_ORDER_ID.value); if (row != -1) { tables.ORDERS.setCurrentRow(row); }
column
- table columnvalue
- the value of the table column, should be the same type as the underlying column object (see Field.getValue()
)findRows(Map)
TableRowIterator findRows(java.util.Map<java.lang.String,java.lang.Object> parms)
parms
.
Javascript example:
var searchParms = {}; searchParms.CUSTOMER_TYPE = "Internal"; searchParms.RATING = 4; var rows = tables.CUSTOMERS.findRows(searchParms); while (rows.next()) { .. }
parms
- a Map of key/value pairs where key is a column name and value is the corresponding value.
In Javascript, an Object can be used where key is a column name and value is the corresponding value
which should be the same type as the underlying column object (see Field.getValue()
).findRow(TableColumn, Object)
int getCurrentRow()
The current row represents an important concept - a current row exists for all tables that are not empty.
All references to table columns and their values which do not explicitly specify a row number are interpreted as
referring to the corresponding table cell for the column on the current row. For example, in the following line
of code, values for the ORDER_VAT
and ORDER_VALUE
columns are obtained from the current row.
orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate;The current row is set by the system as follows:
TableRowIterator
,
the current row is set each time the next()
or previous()
method is invoked.
When all rows have been processed by the TableRowIterator
, the current row is returned to its original value.
If all rows are not processed by the TableRowIterator
, the current row remains set to the row at the break point.insertRow()
method, or the user clicking the add row button, both set the current row to the new rowfetchTable()
method sets the first row as the current rowsort(TableColumn)
methods, sets the first row as the current rowupdateTable()
may reset the current row depending on circumstancesvoid setCurrentRow(int row)
getCurrentRow()
void sort(TableColumn[] columns, java.lang.String[] directions)
Javascript example:
tables.ORDERS.sort( [tables.ORDERS.DELIVERY_DATE, tables.ORDERS.QUANTITY], [Table.SORT_DIRECTION_DESCENDING, Table.SORT_DIRECTION_ASCENDING] );
columns
- an array of table columnsdirections
- an array of directions where each direction is either "asc" or "desc"
(static constants Table.SORT_DIRECTION_ASCENDING
or Table.SORT_DIRECTION_DESCENDING
can be used).
The sort direction at position n is applied to the column at position n.
The number of directions must match the number of columns.void sort(TableColumn[] columns)
Javascript example:
tables.ORDERS.sort( [tables.ORDERS.DELIVERY_DATE, tables.ORDERS.QUANTITY] );
columns
- an array of table columnsvoid sort(TableColumn column, java.lang.String direction)
column
in the order
specified by direction
.
Javascript example:
tables.ORDERS.sort(tables.ORDERS.DELIVERY_DATE, Table.SORT_DIRECTION_DESCENDING);
column
- the table columndirection
- either "asc" or "desc" (static constants Table.SORT_DIRECTION_ASCENDING
and Table.SORT_DIRECTION_DESCENDING
can be used)void sort(TableColumn column)
column
in ascending order.
Javascript example:
tables.ORDERS.sort(tables.ORDERS.DELIVERY_DATE);
column
- the table columnjava.lang.Object getColumnValueOnRow(TableColumn column, int row)
Object
representing the value of the table cell at the specified column and row.
See Field.getValue()
for documentation on which object types are returned for each column type.
Javascript examples:
tables.ORDERS.getColumnValueOnRow(tables.ORDERS.ORDER_VALUE, rowNum);
column
- the table columnrow
- row numberField.getValue()
void setColumnValueOnRow(TableColumn column, int row, java.lang.Object value)
Field.setValue(Object)
for
documentation on which object types can be used with each column type.
Javascript examples:
tables.ORDERS.setColumnValueOnRow(tables.ORDERS.ORDER_VALUE, rowNum, 25.13);
column
- the table columnrow
- row numbervalue
- the value object, see Field.setValue(Object)
TableColumn[] getSortColumns()
Array
of all the columns that are currently sorted.
This can be useful to reestablish a sort order created by the user after a fetchtable.
See getSortDirections()
for documentation on sort directions
See sort(TableColumn[])
for documentation on sorting columns
Javascript examples:
var sortColumns = tables.ORDERS.getSortColumns(); var sortDirections = tables.ORDERS.getSortDirections(); tables.ORDERS.fetchTable(); tables.ORDERS.sort(sortColumns, sortDirections);
getSortDirections()
,
sort(TableColumn[], String[])
java.lang.String[] getSortDirections()
Array
of all the directions that are currently sorted. The position of the sort in the Array
matches the position of the column name within the Array
returned from getSortColumns()
.
This can be useful to reestablish a sort order created by the user after a fetchtable.
The sort order directions are defined as SORT_DIRECTION_ASCENDING
or SORT_DIRECTION_DESCENDING
.
See getSortDirections()
for documentation on sort directions
See sort(TableColumn[], String[])
for documentation on sorting columns
Javascript examples:
var sortColumns = tables.ORDERS.getSortColumns(); var sortDirections = tables.ORDERS.getSortDirections(); tables.ORDERS.fetchTable(); tables.ORDERS.sort(sortColumns, sortDirections);
getSortColumns()
,
sort(TableColumn[], String[])
java.lang.String toJSON()
{ rows: [ {Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}, {Name:Jones, Age:45, StartDate:1459961000000} ] }The JSON string contains a single "rows" property which contains an array of table rows where each row contains columnName:value property pairs where the value for each column is the same as its value property, see
Field.getValue()
.
Columns with null values are included with an explicit "null" value. See toJSON(boolean)
which includes an option to exclude columns with a null value.
Examples:
// 1. send to REST web service var ordersJson = tables.ORDERS.toJSON(); services.rest.put("http://example.com/rest/orders", ordersJson); // 2. convert to Javascript object var ordersJson = tables.ORDERS.toJSON(); var ordersObj = JSON.parse(ordersJson); var order1Value = ordersObj.rows[0].orderValue; var order2Id = ordersObj.rows[1].orderId; for each (var order in ordersObj.rows) { var id = order.orderId; var orderDate = order.orderDate; }
toJSON(boolean)
,
loadFromJSON(String)
java.lang.String toJSON(boolean excludeNullValues)
toJSON()
but additionally provides
an option on how null values in table columns are handled. Columns with a null value can either be omitted or included as value "null".
{ rows: [ {Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}, {Name:Jones, Age:null, StartDate:null} ] }The JSON string contains a single "rows" property which contains an array of table rows where each row contains columnName:value property pairs where the value for each column is the same as its value property, see
Field.getValue()
.
when excludeNullValues
is true, columns with null values are omitted.
When excludeNullValues
is false, columns with null values are included with value "null" - see example above;
Examples:
// 1. send to REST web service var ordersJson = tables.ORDERS.toJSON(true); services.rest.put("http://example.com/rest/orders", ordersJson); // 2. convert to Javascript object var ordersJson = tables.ORDERS.toJSON(true); var ordersObj = JSON.parse(ordersJson); var order1Value = ordersObj.rows[0].orderValue; var order2Id = ordersObj.rows[1].orderId; for each (var order in ordersObj.rows) { var id = order.orderId; var orderDate = order.orderDate; }
excludeNullValues
- when true, columns with null values are omitted; when false, columns with null values are included with value "null"toJSON()
,
loadFromJSON(String)
void loadFromJSON(java.lang.String jsonString)
"{ rows: [ {Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}, {Name:Jones, Age:45, StartDate: null} ] }"This represents a Javascript object with a single "rows" property which contains an array of table rows where each row contains columnName:value property pairs. Any value that can be specified for a column's value property can be used, see
Field.setValue(Object)
.
Columns with null values can be either excluded completely or "null" can be specified as the column value as per the example above. The toJSON()
methods
can be used to generate a JSON string with this format from an existing table.
This method does not delete any existing rows that might exist in the table. If this is required resetTable()
should be called first.
Examples:
var jsonString = "{rows:[{Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}]}" tables.ORDERS.loadFromJSON(jsonString); tables.ORDERS.control.scrollToTop(); //scroll to the top of the table
jsonString
- formatted JSON string containing table row datatoJSON()
,
toJSON(boolean)