Adding a selection column to a table
You can add the ability for users to select one or more rows of your data table, and then perform actions on those rows.
Add and configure a data table.
- Select the data table.
- On the
Row actions tab of the Properties view for the data table, click
Add next to "Add selection column to the table." A new column on the left side of the data table is added. This column contains a check box. (Note that the
Add button changes to
Remove in case you want to remove the row selection column later.)
- Select the checkbox in the new column.
- On the Properties view for inputRowSelect:
- You can set properties and styles on the check box or choose new images to use instead of the default check box.
- Click
Add next to "Add selection toolbar" to add a selection toolbar to the footer of the data table. (You can also move the toolbar to the header.) With the selection toolbar, the user can select rows.
- Click
Add next to "Add selection combo box" to add a selection combo box to the footer of the data table. (You can also move the combo box to the header.) With the selection combo box, the user can select all or none of the rows.
- You have several options for binding the row selection component:
- An object that implements Collection (for example, AbstractList). When the page is submitted, the Collection will contain Map objects whose contents are defined by the Parameter tab. To implement this option, click the Parameter tab under inputRowSelect to add a parameter that associates the row select column with your data source. This also identifies the selected rows. After the Properties view for inputRowSelect parameters opens, click Add Parameter to add a parameter. Then, select the default parameter name to give it a new name. Select the value of the parameter and click the button that displays next to the value to display the Select Page Data Object dialog. In this dialog, select the field that is the primary key of the data table's data source and click OK. The row select is bound to the data source.
- A Boolean[] or boolean[] option. This array corresponds to the rows of the dataTable. The first row corresponds to [0].
- An Integer[] or int[] option in which the array contains the indexes of the selected rows. The array length is modified as required by the row selection component. The index can be used to access a particular row of the data bound to the dataTable.
- A Boolean option for times when you are binding to a column of the list of data bound to the data table (dataTable).
- Add one or more buttons to perform actions on the selected rows.
- Drag a Button - Command component (or Link - Command component) from the palette to the page.
- On the
Display options tab of the Properties view for the button, enter the label for the button in the
Button label field.
- Specify any other attributes for your button.
- Associate an action with a button by using the Quick Edit view for the button.
- To add a pre-coded action, such as Go To Page or Add Form, right-click the right pane of the Quick Edit view and select an action from the
Insert Snippet menu.
Restriction: In a Relational Record List, the update and delete pre-coded actions are not available.
- To code your own action, left-click the right pane of the Quick Edit view, delete the default code and add your own code.
- For examples of using an action to pass a parameter, see Passing parameters with a data table or Passing parameters between JSP pages.
The inputRowSelect component needs to have its value bound to one of the following object types. The value binding must be set to a non-null object. The RowSelect value is typically stored in a Java™ Bean. Note that the first three options in the following list of options perform more efficiently as the dataTable reloads the list object and makes it available to the action code. The value is used for both rendering and posting back.
- Boolean - Works with a property of the list object
<h:dataTable value="#{pc_opage.myList}" var="varmyList"> <h:column> <hx:inputRowSelect value="#{varmyList.selected}> </h:column> </h:dataTable>
- Boolean[] or boolean[] - an array matching the list. If isSelected[4] is true, the the fifth element of the list was selected.
<h:dataTable value="#{pc_opage.myList}" var="varmyList"> <h:column> <hx:inputRowSelect value="#{pc_opage.isSelected}> </h:dataTable>
- Integer[] or int[] - an array which contains the indexes of the selected elements of the list.
<h:dataTable value="#{pc_opage.myList}" var="varmyList"> <h:column> <hx:inputRowSelect value="#{pc_opage.selected}> <h:column> </h:dataTable>
- Collection - Collection object (for example, ArrayList) which contains Map objects. Each Map has the set of name/value pairs defined by the parameter child tags for each selected element.
<h:dataTable value="#{pc_opage.myList}" var="varmyList"> <h:column> <hx:inputRowSelect value="#{pc_opage.selected}> <h:column> </h:dataTable>