Java Reference
In-Depth Information
6. If the validate() method returns a Catalog entity instance, the servlet
constructs a String that consists of an element valid with text set to false
and also consists of elements corresponding to the Catalog bean properties
journal , publisher , edition, title, and author . The String is returned to
the browser, which parses the String and finding a false value for the valid
element displays a validation message that the catalog id value specified is
false. The JavaScript in the Catalog entry form JSP also fills the form fields with
the values returned in the String and disables the Submit button.
7. If the catalog id is valid, a user may fill out the form and submit it, which
invokes the doPost method. In the doPost method of the servlet, the input
field values are retrieved and the remote business interface of the session
bean is looked up. The persist() method of the session bean is invoked
with the input form field values.
In the persist() method of the session bean, a new Catalog entity instance
is created from the input field values and the persist() method of the
EntityManager is invoked to persist the entity instance to the database.
Thus, a user did not have to fill out the form only to find later that a catalog
id is not valid. Ajax validates the catalog id value and displays a
validation message.
Setting the environment
We need to install Oracle Fusion Middleware 11 g (
technology/software/products/middleware/index.html ). We need to download
the following two components from the For Development section.
• Oracle WebLogic Server 11 g Rel 1 (10.3.2) Net Installer
• Oracle JDeveloper 11 g Rel 1 ( (JDeveloper + ADF)
First, install JDeveloper 11 g Studio Edition. Also install Oracle database 10 g /11 g /
XE (including the sample schemas). We shall be using the XE version in this chapter.
Create an Oracle database table CATALOG with the following SQL script:
CREATE TABLE Catalog(CatalogId VARCHAR(255), Journal VARCHAR(255),
Publisher Varchar(255), Edition VARCHAR(255), Title Varchar(255),
Author Varchar(255));
INSERT INTO Catalog VALUES('catalog1', 'Oracle Magazine', 'Oracle
Publishing', 'September-October 2009','Oracle Fusion Middleware 11g:
The Foundation for Innovation', 'David Baum');
INSERT INTO Catalog VALUES('catalog2', 'Oracle Magazine', 'Oracle
Publishing', 'September-October 2009', 'Put Your Arrays in a Bind',
'Mark Williams');
Search WWH ::

Custom Search