Selector beans operate on a Java TableModel. Used with the Select bean you can query a database, receive a result set back and use the selector beans to process a subset of the result set. The ColumnSelector and RowSelector beans implement the ComboBoxModel which means they can extract data from a result set and pass it to a user interface such as a JList. You can also use them to get data from a user interface, put the data in a result set and then have a Select or ProcedureCall bean update the database.
Selector beans can also be used to work with arrays. For example, you could use the RowSelector bean to extract a row from a result set, do data conversion on the row, and pass the result as an array.
All selectors have properties that define the subset of TableModel data that they are operating on. For a CellSelector these identify the row and column indices that define the location of the cell within the source TableModel. For the other selectors, similar properties define the start row and/or column indices, and the maximum number of rows and/or columns to be selected.
The above properties are by default zero-based. That is, the first row or column is deemed to be row or column zero. Many navigation Java beans have a value property that is also zero-based, but in cases where a navigator value is one-based the selectors have a boolean property that can switch them to one-based operation.
These properties may be set at design-time in a visual builder, and/or modified at run-time by connecting them to visual Java beans that provide navigation, such a JList.
Data Conversion
To provide the maximum opportunity for connecting selectors to other Java beans, all selectors will attempt data conversion on request. For example, the source data might be numeric, but held in a character representation as a string. In this circumstance a selector will be able to return the value in any one of the numeric Java types, and accept values for update with the same flexibility. Data conversion will not always be possible, and numeric overflow might occur when converting numbers to forms using less memory. However, in many cases conversion will enable a connection that might not otherwise be possible.
Conversion is achieved using the data access properties which are available on all selectors. These properties are named after the data type that they return and accept, and have "getter" and "setter" methods. For example: int getInt() and void setInt(int value);
Data Changes
If the source TableModel for a selector changes, the selector will usually notify its listeners of the data change. But if rows are inserted or deleted prior to the rows that have been selected, the selector will adjust its rowNumber/startRowNumber property so that the rows selected remain the same.
There are a number of ways in which interested Java beans may be informed of changes to data currently targeted by a selector:
On change notification, listeners may retrieve the updated data using any of the available data accessors, provided that coercion between the source data type and the data type of the accessor is possible.
On change notification, data will normally be retrieved using the ComboBoxModel services supported by these selectors.
On change notification, data will normally be retrieved using the TableModel services supported by this selector.
If source data covered by the selector, or the selection criteria for the selector, are modified, then in theory all the data access properties might be deemed to have changed. In practice, notifying a property change event for all of that data access properties would be counter productive, since most listeners will only be interested in data of one type. However, some visual builders support the explicit binding of named properties, and to support these it is necessary to signal property change events. To allow for this without having to incur the overhead of many property change notifications for every data change, the NotificationType property may be customized to define which of the data access properties on a selector will be notified as changed.
Editing CellSelector Bean Properties
Editing ColumnSelector Bean Properties
Editing RowSelector Bean Properties
Editing CellRangeSelector Bean Properties
Using Selector Bean Data Access Properties