< Previous | Next >

Lesson 1.5: Program the Submit button

When your input form is submitted, the page will automatically add the new record to the database. In this lesson, you will program the Post New Listing submit button to return to the all_records.jsp page so that you can immediately view the new record in the database.

To program the submit button:

  1. In the new_record.jsp file, right-click the Post New Listing button you created in the form on the Web page and select Properties. The hx:commandExButton tab is displayed in the Properties view.
  2. Click Add Rule. The Add Navigation Rule window opens.
  3. From the Page drop down, select all_records.jsp then click OK.
  4. Save the page.
Prevent duplicate keys
Important:

Since the ID column is a primary key in the ADS table, you cannot add records with an ID value that already exists in the table. In Module 2, you will see how to use automatic key generation to automatically create a new unused key for each new record.

Until then, you must enter an unused ID number in this page to add a new record. The records that come with the database use ID numbers from 1 to 24, so you can enter any number above 24 as a primary key. Be sure not to duplicate keys if you enter more than one record.

Lesson checkpoint

You have completed Lesson 1.5. In this lesson you learned to program a command button and to bind data to an input field by dragging and dropping a JSF widget from the palette onto a Web page.
< Previous | Next >

Feedback