< Previous | Next >

Lesson 7: Pass a parameter to another page

The file allcustomers.jsp lists every row in the database. In the next exercise, you will create a second page that displays the details from one row in the database. In this exercise, you will add a link on the file allcustomers.jsp that sends the user to the detail page. That link also indicates which record to display on the detail page.

Add the parameter to the link

Next, you must specify which record will be displayed on the updatecustomer.jsp page. To send this information to that page, you specify an HTTP request parameter for the link you just added. HTTP request parameters are name-value pairs of plain text that are sent over the Internet by way of the HTTP protocol. Request parameters are an efficient way to send and receive simple data between programs within an application.
  1. Click directly on the link icon of the link control you just added to the {LASTNAME} control.

    The link icon itself, , not the text control, must be selected before you can continue. You have the link selected correctly if it is lightly shaded and the selection box is surrounding the link icon and the text control. Do not double click the link icon.

  2. Without moving the selection away from the link icon, open the Properties view.

    The Properties view is usually at the bottom of the workbench. If you can't find the Properties view, click Window > Show View > Properties.

  3. In the Properties view, click the Parameter tab, directly below the hx:outputLinkEx tab.

    If you can't find the Parameter tab, be sure you have clicked directly on the icon to select it.

  4. Click Add Parameter. A new parameter named Name0 is added to the list of parameters.
  5. Click the cell holding Name0 and replace the name with the following text as the new name of the parameter:
    CID
  6. Click the cell holding Value0 to highlight it.
  7. Click the Select Page Data Object button. The Select Page Data Object window opens.
  8. Under Data Objects, expand Data.
  9. Expand customers - Customer[].
  10. Click CUSTOMERID - CUSTOMERID.

    The Select Page Data Object window looks like this:

    Select page data object window

  11. Click OK.
  12. Save and close the page.

Now, the value of the CID parameter for the link is bound to the value of the customer_id field. When the user clicks the link, the runtime code invokes the file updatecustomer.jsp and makes the customer ID number available to the onPreRender function of the related JSF handler.

In the next lesson, you will create the web page for the file updatecustomer.jsp, and later, you will set up the JSF handler to receive the parameter and to show only the customer with that ID number.

< Previous | Next >

Feedback