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:
- Double-click the new_record.jsp file in
the Enterprise Explorer view to open it.
- Delete the default text Insert content here.
- In the Palette view, click the Data and Services drawer
to expand it.
- 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.
- In the Name field, type create_record.
- Under Create controls for, click Creating
a new record.
- 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:
- Click Next.
- In the Table box, expand W5SAMPLE and select
ADS. Click Next.
- 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.
- 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
- Rearrange the fields in the following order by clicking the Up
or Down buttons:
- ID
- TITLE
- DESCRIPTION
- MAINCATEGORY
- PRICE
- PHONE
- 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.
- Select MAINCATEGORY then click Options.
The Options window opens.
- Make sure the Submit button option is selected.
- Type Post New Listing in the Label field.
Then click OK. The Add Relational Record window should
now look like this:
- Click Finish to generate the input form.
It should look like this:
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.
- 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.