< Previous | Next >

Lesson 1.4: Create a new record to display and update the database

In this lesson, you will create a page that allows users to create new classified ads and post them to the database.
First you will create a relational record to represent a new record in the database, and then create a visualization of the record on your page as a set of input fields.

To create a new relational record:

  1. Double-click the new_record.jsp file in the Enterprise Explorer view to open it.
  2. Delete the default text Insert content here.
  3. In the Palette view, click the Data and Services drawer to expand it.
  4. Drag the SDO Relational Record component from the Palette onto the blank content area. The Add Relational Record window opens.
    Note: If a warning message appears and says that a connection to your database could not be established, the server may still be running after testing the Web site. If this happens, click Cancel in each dialog and stop the server as explained in Lesson 1.3.
  5. In the Name field, type create_record.
  6. Under Create controls for, click Creating a new record.
  7. Make sure Add input/output controls to display the record on the web page is selected. The Add Relational Record window should look like this:
    Add Relational Record window.
  8. Click Next.
  9. In the Table box, expand W5SAMPLE and select ADS. Click Next.
  10. Click Next again. The Configure Data Controls page opens.
    Tip: The Configure Data Controls page helps you customize the visualization of your relational record. For example, you can change the columns, field labels, and submit button on your input form. After you finish these steps, a fully functional input form will be on the page.
  11. In the Fields to display section, clear the check box next to every field name except for the ones you want in your input form:
    • DESCRIPTION
    • ID
    • MAINCATEGORY
    • PHONE
    • PRICE
    • TITLE
  12. Rearrange the fields in the following order by clicking the Up or Down buttons:
    • ID
    • TITLE
    • DESCRIPTION
    • MAINCATEGORY
    • PRICE
    • PHONE
  13. Rename the labels as you like. For example, shorten the "Maincategory:" label to just "Category:" To rename the labels generated for the input fields, click a label from the Label column. The mouse icon turns into a cursor so you can type new text.
  14. Select MAINCATEGORY then click Options. The Options window opens.
  15. Make sure the Submit button option is selected.
  16. Type Post New Listing in the Label field. Then click OK. The Add Relational Record window should now look like this:
    Relational Record window.
  17. Click Finish to generate the input form. It should look like this:
    Input form.
    Note: The form has an Error Messages field. This does not mean that your project has errors; this field marks the place where errors will be displayed if there are any when the user submits the form.
  18. Save the page.
When your input form is submitted, the page will automatically add the new record to the database. In the next lesson, you will program the Post New Listing button to return to the all_records.jsp page so that you can immediately view the new record in the database.

Lesson checkpoint

You have completed Lesson 1.4. In this lesson, you created a page that allows users to create new classified ads and post them to the database.
< Previous | Next >

Feedback