Oracle9i Lite Developer's Guide for Web-to-Go
Part No. A97671-01
By using a sample application, this tutorial shows you how to create, deploy, and use a BC4J application.
The tutorial is organized according to the following topics:
Oracle's BC4J (Business Components for Java) is a part of Oracle9i JDeveloper's IDE (Integrated Development Environment), giving Java developers the tools to create and manage reusable Java components.
BC4J offers a standards-based, server-side Java and XML framework for developers who build and deploy reusable business components for high-performance Internet applications, such as e-commerce and business-to-business systems. Applications which are created by using BC4J comprise five basic framework components, namely, Entity Objects, Associations, View Objects, View Links, and Application Modules. Each of these components is interrelated to the other components, thereby enabling you to establish views into database tables. You can combine, filter, and sort data as needed.
When used in application development, BC4J automatically generates database-oriented components, enabling Web-To-Go developers to focus on the business logic instead of spending their time on database-related components during business application development.
The sample BC4J application which is used in this tutorial stores its items in a relational database. It maintains employee details.
Before you start developing business components in Java, you must ensure that the development computer meets the requirements specified below.
Table 6-1 lists configuration and installation requirements for the development computer.
Table 6-1 Development Computer Requirements
|Windows NT/2000/XP User Login||The Windows NT/2000/XP login user must have Administrator privileges on the development computer|
|Installed Java Components||Java Development Kit 1.3.1 or higher|
|Installed Oracle Components||
Mobile Server or Mobile Development Kit (Oracle9i Lite CD-ROM)
Oracle 8.1.7 or higher
Oracle9i JDeveloper, Release 9.0.3
Note:The BC4J tutorial is shipped with the Mobile Development Kit as a JAR file named 9iLite_BC4J_Tutorial.jar. The file is located in the directory <Oracle_Home>\mobile\sdk\wtgsdk\src\. You can use this JAR file to publish the BC4J tutorial to the Mobile Server and then continue with the rest of the tutorial by following the steps in Section 6.7, "Deploying the Sample Application". If you want to develop the same application (as packaged in 9iLite_BC4J_Tutorial.jar), follow the steps from Section 6.2, "Developing the Application" to Section 6.6, "Running the BC4J Application on the Mobile Client for Web-To-Go" then continue to Section 6.7, "Deploying the Sample Application".
This section enables you to develop the BC4J application for Oracle9i Lite in phases.
To develop the BC4J application, you must perform the following tasks.
Create a database connection.
Create the BC4J component.
Configure the BC4J component to use the WTGJdbc connection.
Build and deploy the BC4J component as a simple archive.
Write the JSP application to access the BC4J component.
Deploy the JSP application as a simple archive.
Deploy the BC4J component into the Mobile Server.
To create the database connection, perform the following steps.
In the Oracle9i JDeveloper project workspace, right-click on the "Connections" icon and click the "Connections" menu. The "Connection Manager Wizard" appears.
Figure 6-1 displays the Connection Manager Wizard.
Figure 6-1 Connection Manager Wizard
Click New. The Connection dialog box appears.
Figure 6-2 displays the Connection dialog box which enables you to specify database connections for "tutorialConn" and "WTGJdbc".
Figure 6-2 Connection Dialog Box
You must create two database connections: "tutorialConn" and "WTGJdbc" respectively. The "tutorialConn" connection connects to the primary Oracle database using "oracle.jdbc.driver.OracleDriver" for development and testing of the application. The "WTGJdbc" connection connects to the Oracle Lite database using "oracle.lite.web.WTGJdbcDriver". You can change the connection from "tutorialConn" to "WTGJdbc" before deploying the application as a simple archive. The "WTGJdbc" connection is used during application deployment and uses a different driver.
To create a database connection for "tutorialConn", enter data in the Connections dialog box as specified in the following table.
Table 6-2 lists values that you must specify for "tutorialConn" in the Connections dialog box.
Table 6-2 tutorialConn Connection Requirements
|SID||Your Database SID|
To create a database connection for "WTGJdbc", enter data in the Connections dialog box as specified in the following table.
Table 6-3 lists values that you must specify for "WTGJdbc" in the Connections dialog box.
Table 6-3 WTGJdbc Connection Requirements
|Select a JDBC Driver||Other JDBC|
Note:In the Connection dialog box, you must enter values for fields only as specified in Table 1-2 and Table 1-3. Retain all other values as default values.
Click "Test Connection" to test the "tutorialConn" database connection. The system displays a message stating that the database connection is successful.
Click "OK". The database connection is now created.
Using Oracle9i JDeveloper, you can create the BC4J component named "tutorialapp".
To create the BC4J component named "tutorialapp", perform the following steps.
In Oracle9i JDeveloper, select New from the File menu. In the New dialog box that appears, "Projects" in the left panel and "Empty Project" in the right panel are pre-selected as the defaults. Click OK. Oracle9i JDeveloper creates a new empty project named "Project.jpr".
Rename "Project.jpr" to "tutorialapp.jpr", which creates a new project by that name.
Right click "tutorialapp.jpr" in the Oracle9i JDeveloper workspace. Select the "New Business Components Package..." The "Business Components Package Wizard, Welcome" dialog box appears. Click Next.
Figure 6-3 displays the "Business Components Package Wizard, Welcome" dialog box.
Figure 6-3 The Business Components Package Wizard, Welcome Dialog Box
The "Business Components Package Wizard, Step 1 of 3: Package Name" dialog box appears, as illustrated in Figure 6-4. In the Package Name field, enter tutapp. Then, click Next.
Figure 6-4 Business Components Package Wizard, Step 1 of 3: Package Name
Figure 6-5 Business Components Package Wizard, Step 2 of 3: Connection
Table 6-4 Values for Business Components Package Wizard, Step 2 of 3: Connection
In the "Business Components Project Wizard, Step 3 of 3: Business Components" dialog box, select "EMP" from the list displayed in the left panel and move it to the "Selected" list, as illustrated by the example in Figure 6-6. Click "Finish".
Figure 6-6 Business Components Package Wizard, Step 3 of 3: Business Components Dialog Box
At this stage, Oracle9i JDeveloper creates the BC4J component named "tutorialapp".
To configure the BC4J component to use the WTGJdbc connection, perform the following steps.
Right-click on the "TutorialappModule" and double-click on the "Configurations..." option. The Configuration Manager appears.
In the Oracle Business Component Configuration dialog box, click "Edit". Choose "WTGJdbc" as the JDBC connection.
Click "OK". The BC4J component is now configured to use the WTGJdbc connection.
To build and deploy the BC4J component as a simple archive, perform the following steps.
Right-click the "tutorialapp.jpr" file and select the "Create Business Components Deployment Profiles" option. The Deployment Wizard appears.
Select the "Simple Archive Files" option from the list displayed and move it to the "Selected" list.
Under the Selected platform - Simple Archive Files section, select the "Deploy" check box.
Click "OK". The system creates two "jar" files namely "tutorialapp.jar" and "tutorialappCommonCS.jar".
To write the JSP application that will access the BC4J component, perform the following steps.
In Oracle9i JDeveloper, select the "Empty Project" option under the File menu. The system automatically creates a new empty project called "MyProject.jpr".
Under the File menu, select the "Rename..." option and rename "MyProject.jpr" to "tutorialclientapp.jpr".
Click the "tutorialclientapp.jpr" file in the Oracle9i JDeveloper workspace. Click the File menu and select "New". Click the "Web Tier" option and select "Business Components JSP Application". Click OK. The "Business Components JSP Application Wizard" appears.
Click "New...". The "BC4J Client Data Model Definition Wizard" appears. Click Next. The "BC4J Client Data Model Definition Wizard: Step 1 of 2: Definition" appears, as illustrated in Figure 6-7.
Figure 6-7 BC4J Client Data Model Definition Wizard, Step 1 of 2: Definition
Verify the default selected values and click Next. "TutappModule" appears as the default Definition Name in the "BC4J Client Data Model Definition Wizard - Step 2 of 2: Definition Name" dialog box. Click Next.
Click Finish. The "Business Components JSP Application Wizard" dialog box appears. Click Next.
In the "Business Components JSP Application Wizard - Step 1 of 3: Data Definition" dialog box, select "TutappModule" as the data model definition, as illustrated in Figure 6-8. Click Next.
Figure 6-8 Business Components JSP Application Wizard - Step 1 of 3: Data Definition
Accept the default selections and click Next in the two dialog boxes that appear: "Business Components JSP Application Wizard - Step 2 of 3: View Object Forms" and "Business Components JSP Application Wizard - Step 3 of 3: View Link Form". Click Finish when the Summary window appears.
To deploy the JSP application as a simple archive, perform the following steps.
In Oracle9i JDeveloper, click the tutorialclientapp.jpr file and select the tutappclient_jpr_war.deploy file.
Select "Deploy to WAR file". The file tutappclient_jpr_war.war gets created. To get the deployed location, check the "Deployment Log" text area in Oracle9i JDeveloper.
To package the JSP application, perform the following steps.
Create a sub-directory called "bc4jtutapp" under the following location: &fmv435;\Mobile\Sdk\wtgsdk\root
Unzip the tutappclient_jpr_war.war file into the "bc4jtutapp" directory.
Edit all of the JSP files to delete the following:
<%@page language="Java"errorpage="errorpage.jsp" ContentType="text/html;charset=windows-1252"%>
Edit Emp.xml and change:
to the following:
Edit EmpView.xml and change:
to the following:
Using the Command Prompt window, run the Packaging Wizard and provide the screen inputs that are listed and described in Table 6-5.
Table 6-5 Packaging Wizard Input Details
|Application||Application Name||BC4J 9iLite Tutorial Application|
|Application||Description||BC4J 9iLite Tutorial Application|
|Application||Application Classpath||no input|
|Application||Local Application Directory||&fmv436;\Mobile\Sdk\wtgsdk\root\bc4jtutapp|
|Files||The Packaging Wizard loads all files in a directory under the Local Application Directory.||NA|
Table 6-6 lists the servlet names and their corresponding classes that are created in the Packaging Wizard by default.
Table 6-6 Servlet Names and Classes
|Screen||Servlet Name||Servlet Class|
Table 6-7 lists Server side and Client side Database values that you must specify in the Packaging Wizard.
Table 6-7 Database Values
|Database||Server side Database User Name||scott|
|Database||Number of Connections||0|
|Database||Share Connections||Do not select this check box|
|Database||Client side Database Name||Client DB|
Under the Snapshots section, click "Import...". You can now connect to the Oracle Database by providing the following values in the "Connect to Database" dialog box.
Table 6-8 lists values that you must specify in the Connect to Database dialog box.
Table 6-8 Connect to Database Window Description
After specifying the Database Connection values, select "Emp" from the list of tables.
Click "Edit" and change the weight to "1" from "0".
You must retain the default values for Roles, Sequences, DDLs, and Registry fields.
Package the application into a JAR file.
To configure the JSP application from the Control Center, perform the following steps.
Using the Command Prompt window, enter "webtogo-d0" to start the Mobile Server.
Using the following URL, browse the local host:
Login into the Mobile Server using the administrator username and password.
Click "Control Center".
Click the "Application" tab and then publish the JAR file you created.
Click the "Users" tab, and create a new user called "tutorial". Enter "tutorial" as the password. Assign "Users" as the privilege for the new user.
Click the "Applications" tab.
Click the "BC4J 9iLite Tutorial Application" link.
Under the "Database Connectivity" section, in the "Database Password" field, enter "tiger".
Click "Access" to provide user access to the "BC4J 9iLite Tutorial Application".
To test the BC4J application, login to the Mobile Server as a "tutorial" user. In the "tutorial" workspace, double-click the "BC4J 9iLite Tutorial Application". The Business Components JSP Application window appears. Click "EmpView" and browse through the employee table records.
To run the BC4J application on the Mobile Client for Web-To-Go, perform the following steps.
Using the following URL, check the Database Server's IP address setup:
Download and install the Mobile client for Web-To-Go with BC4J support.
Using the following URL, check the local host in the client machine:
http://localhost in client machine
Log in to the client machine using "tutorial" as the username and password.
After the client machine synchronizes the application and data from the server, click the "BC4J 9iLite Tutorial Application" link to test the application on the client machine.
To deploy the sample application, perform the following steps.
Log in to the database as a system user. Run the "bc4j.sql" script if the SCOTT schema does not exist already.
Publish the 9iLite_BC4J_Tutorial.jar file, which is found under
into the Mobile Server by using the Control Center and entering the following virtual path:
Click "Control Center" and choose the "Applications" tab.
Click the "9iLite BC4J Application".
Choose the "Properties" link, and enter "tiger" as the database password. Click Save.
Create a user called "tutorial" with "user" as the privilege, in case the user "tutorial" doesn't exist already.
Provide user access to the user named "tutorial" to the "9iLite BC4J Application".
Using the following URL, browse the client machine with BC4J support.
Download and install the Web-To-Go Mobile client.
Start the Web-To-Go client if it is not started already.
Log in to the Web-To-Client with "tutorial" as the username and password.
Upon completion of the Synchronization process, the system displays the "9iLite BC4J Application" link.
Click the "9iLite BC4J Application" link to access the BC4J tutorial application.