Preparing for Input
Now you can create an input form using JSF components. Begin by adding a Panel Grid component to the input.jsp page from the JSF HTML component library. Click Next in the Create PanelGrid Wizard. Select Create empty panel grid and specify 2 for the number of columns in the PanelGrid Options frame, and then click Finish. The components that will be added to the panel grid will be arranged in two columns.
Add an Output Label and Input Text component from the component palette in the panel grid. Similarly, add five more Output Label and Input Text components, add a Command Button component to the panel grid that will be used for submitting the form, and add an Output Text component to the panel grid for displaying a validation message that will indicate whether an ID value is valid (see Figure 3). Also specify values for the output labels and the command button components in the Property Inspector area.
Figure 3. Create a Form: Use the JDeveloper IDE's component palette to add five Output Label and Input Text components, a Command Button component, and an Output Text component to the panel grid.
At this point you need to create a JDBC connection with the Oracle database. To create this connection right-click the Database node in the Connections area, and select New Database Connection. Click Next when the Create Database Connection Wizard opens. Specify a connection name, and select the Connection Type as Oracle JDBC in the Type frame, and click Next.
For this example specify OE for both the username and password in the Authentication frame, and click Next. Then select the default connection settings in the Connection frame, and click Next. Click Test Connection in the Test frame to test the connection, and click Finish. You will see that a connection is added to the Connections area.
Add a resource-ref element to the web.xml file for the Oracle data source, and also add an ajax4jsf filter and filter mapping to web.xml. Be sure to also specify a listener class. The web.xml file is shown in Listing 1.
Next, you want to modify the JSF faces-config.xml configuration file. Add a navigation rule for navigating to the catalog.jsp page if a catalog entry gets created, and for navigating to the error.jsp page:
<?xml version="1.0" encoding="windows-1252"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"