Pass a parameter to another page
The allcustomers.jsp file lists every row in the database. In this section, you add a link to this file that sends the user to the detail page. That link also indicates which record to display on the detail page. In the next section, you will create a second page that displays the details from a single database row. .
Add the link to the allcustomers.jsp file
- Open the allcustomers.jsp file.
- In the Palette view, click the Enhanced Faces Components drawer to open it.
- From the Enhanced Faces Components drawer, select the Link component.
- With the Link component selected in the Palette view, click directly on the
{lastName}text field. The Configure URL window opens. - In the URL field of the Configure URL window, type the following file name
exactly as shown:
updatecustomer.faces
This is the name of the page that you will create in the next section to show only one row in the database, but with afacesextension rather than ajspextension. - Leave the Label field blank. Without a label specified here, the link will use the text of the last name field as the text for the link.
- Click OK.
Tip:
If you see a link next to the
{lastName} text field named "Link
label," you did not place the link directly onto the
{lastName} text field. Choose Edit >
Undo and try again.
- Save the page.
The page should now look like Figure 25.
Figure 25. allcustomers.jsp with a link to updatecustomer.jsp
Next, you must specify which record will be displayed on the updatecustomer.jsp page. To send this information to that page, you need to specify an HTTP request parameter for the link that 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.
- Click directly on the link icon of the link component that you just added to
the
{lastName}text field.
Tip:
The link icon itself (
), not the text field, 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 field. Do not
double-click the link icon.
- Without moving the selection away from the link icon, open the Properties view, which is usually at the bottom of the workbench. If you cannot find the Properties view, choose Window > Show View > Properties.
- In the Properties view, select the Parameter tab, directly below the hx:outputLinkEx tab. If you can't find the Parameter tab, be sure that you have clicked directly on the icon to select it.
- Click Add Parameter. A new parameter named
Name0is added to the list of parameters. - Click the Name column and type this text as the new name of the
parameter:
CID
- Click the Value column.
- Click the Select Page Data Object button (
) to open the Select
Page Data Object window. - Under Data Objects, click the + (plus) symbol to expand customers - Customer[].
- Click customerId.
The Select Page Data Object window should now look like Figure 26.
Figure 26. Select Page Data Object window, showing the value of the parameter to be added to the link
- Click OK.
- Save the page.
The value of the link's CID parameter is
now bound to the value of the customer_id field. When the user clicks on the
link, the runtime code invokes the updatecustomer.jsp file and makes the
customer ID number available to the onPreRender()
function of the related JSF handler.
In the next section, you create the Web page for the updatecustomer.jsp file. Later, you set up the JSF handler to receive the parameter and to show only the customer with that ID number.


