Passing parameters with data tables

From a data table, you can pass a parameter from one Faces JSP page to another using a data table row action to, for example, return a detailed page of data for a record that is selected in a data table. To do this, you can configure a data row action control to pass a parameter from a data table page to a record details page.

Note: You can also pass parameters by using a Link - Command or Link - Request component bound to a column of the data table.

To pass parameters using a data table row action:

  1. Add a row action control to your data table.

    1. In the Properties view of the data table, click

      Row actions in the list under the data table,

      h:dataTable. The action settings available display on the right:

    2. Click

      Add next to "Add an action that's performed when a row is clicked." A new column containing a row action control is added to the data table. The column's row action control is selected and you can see its attributes in the Properties view:

  2. (Optional) Set up navigation rules to identify which pages the actions can navigate to, see Adding navigation rules to JSF components.

  3. Add a parameter for the row action.

    1. In the Properties view, click

      Parameter in the list under the row action control,

      hx:commandExRowAction or

      hx:requestRowAction.

    2. Next to the Value column, click

      Add Parameter.

    3. Click within the

      Name field and type a name for the new parameter. It can correspond to a column of the data table, for example, customerID.

  4. You can give the new parameter a value or bind it to a field in your data object. In this case, bind the parameter to a data field.

    1. Click within the

      Value field for the new parameter, then click the Select Page Data button, . The Select Page Data Object page opens.

    2. To bind the parameter, select a relational record in the same relational record list that your data table is bound to, then click OK. For example, if there is a customers SDO, you might select the

      customerID relational record.

  5. Write a custom action for the row action control

    hx:commandExRowAction or

    hx:requestRowAction using the Quick Edit view.

    1. In the Properties view, click on the row action control.

    2. Click the Quick Edit view button, , next to the row action ID. The Quick Edit view opens.

    3. Click in the right-hand pane of the view to enter the code to define the new action.

    4. Add the parameter from the row action to the request scope so that the page that you navigate to can use this parameter. In the customers SDO, for example, where customerID is the name of the parameter and req_customerID is the request scope variable that is being set, enter the following line before return""; :

      getRequestScope().put("req_customerID", getRowAction2().getRowParameters().get("customerID"));

      Note: Using content assist, you can verify that the correct method names are being used. For example, you can type getReq and a box opens with a list of method names where you can then select getRequestScope(). The method names available to you are dependent on the objects on the page. If you have more than one row action on the page, using content assist allows you to see all the row actions without having to recall the exact ID from memory.

  6. (Optional) Run your page on a test server by right-clicking the page in the Enterprise Explorer view and selecting

    Run | Run on Server.

After you create the row action, the variable, as in the example, req_customerID, is available as a request parameter for the page to which this row action navigates. This value can be used in various ways, such as a filter condition for a relational record or displayed in a JSF output component.

 

Related concepts

Data table components