Adding row actions when a row is clicked

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.

Add and configure a data table.

To add row action support for a data table:

  1. Select the data table.

  2. 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".

  3. The

    Configure a Row Action 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.

  4. To associate an action with the row:

    1. 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.

    2. Open the Quick Edit view for the Row Action to access the Java™ code for the action.

    3. Right-click on the right pane of Quick Edit.

    4. Click

      Insert Snippet. A menu of pre-coded actions opens.

    5. Select the action you want to associate with your data table.

  5. Add a navigation rule to define to which pages to go. See Adding navigation rules to JSF components 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.

  1. Add a row action column to your data table as described above.

  2. 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

  3. In the Row Action Properties view, you can navigate to the Details page.