You can perform actions, such as read, update, and delete, on records
displayed in a data table. One way to perform an action 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".
- The Configure a RowAction dialog opens. Select
an action type:
- Clicking the row sends a request to the server with row
information sent as parameters. Select this action type for navigation
operations.
- Clicking the row submits the form to the server. Parameters
have to be set up manually. Select this action type for transactional
operations.
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 to which pages to go. See Creating Navigation for Faces JSP pages for more
information on navigation rules.
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.
- In the Quick Edit view for the Row Action, note the comment that is added
to the action, similar to the following comment:
// TODO Auto-generated method
// Get the index of the selected row
// int row = getRowAction1().getRowIndex();
//
// Copy key values from the selection to the request so they can be used in a database filter
// For example, if the table has a column "keyvalue" and there is an SDO object that uses the
// filter "request.keyvalue", then this code sets up the request so the filter will work
// correctly
// For V5.1 server use:
// Object keyvalue = getData().getDataObjectAccessBean(row).get("keyvalue");
// For V6 server use:
// Object keyvalue = ((DataObject)getData.get(row)).get("keyvalue");
//
// getRequestScope().put("keyvalue", keyvalue);
//
// Specify the return value (a string) which is used by the navigation map to determine
// the next page to display
- In the Row Action Properties view, you can navigate to the Details page.