Associating row actions with a data table
You can perform actions, such as read, update, and delete, on records displayed in a data table. One way to perform these actions is to add row action support. When you add a row action to a data table, it is added as a new column. The user can then click anywhere on that row to perform an action on it.
To add row action support for 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 an action that's performed when a row is clicked." A row action is added as a new column on the data table. The end user will then be able to click anywhere on that row to perform an action on it.
- To associate an action with the row:
- Select the row action icon in the Row Action column. (Make sure you do not accidentally select the column header or the column.) The Row Action Properties view (commandExRowAction) opens.
- Open the Quick Edit view for the Row Action to access the Java code for the action.
- Right-click on the right pane of Quick Edit.
- Click Insert Snippet. A menu of pre-coded actions opens.
- Select the action you want to associate with your data table.
- Add a navigation rule to define any pages to go to. See Creating Navigation for Faces JSP pages for more information on navigation rules.
- Optionally, add one or more parameters to be passed to the forwarding page in order to identify the row that was acted upon. For example, you can add a parameter that is bound to the primary key field.
Example: This scenario makes two values from the selected data table row available at run time, and then passes them to a "Details" page. You start with a data table bound to a Relational Record List from a database such as Cloudscape or DB2, or a bean value of typejava.util.List containing java.util.Map objects. You then create parameters associated with the row action.
- Add a row action column to your data table as described above.
- On the Parameter tab of the Row Action Properties view (commandExRowAction), add two parameters and bind them to variable values associated with the data table. In this example, the parameter named adid is bound to the variable varadlist_ads.ID and the parameter named catid is bound to the variable varadlist_ads.CATEGORY. When the row is clicked, the values of these 2 fields for the selected row are forwarded to the next page. The next page can use these forwarded values to identify the selected record and retrieve more information about that record.
- In the Row Action Properties view, you can navigate to the Details page.
You can also create actions for selected data records by enabling Row Selection for your data table, and associating actions to the command event of the Command - Button components. See Related Tasks below for links to other row actions.
Related concepts
JavaServer Faces
Data table components
Related tasks
Creating Faces applications - overview
Adding a data table
Enabling row selection for a data table
Adding row category support to a data table
Adding row edit to a data table
parameter from one Faces JSP page to another. Several Faces components, such as command buttons or command hyperlinks, can help you do this">Passing parameters with a data table
Passing parameters between JSP files
Creating navigation for Faces JSP files
footer. A header is displayed along the top of the data table and a footer along the bottom of the data table. You can drag other Faces components to the header and footer. For example, if you want a title for the table and an image next to the title, you can drag an Output component and an Image component to the header.">Adding a header and footer to Faces JSP files
Related reference
Faces components reference
Faces attributes reference