|
Building Enterprise JSF Applications with Oracle JHeadstart for ADF (10.1.3)
Building
Enterprise JSF Applications with Oracle JHeadstart for ADF (10.1.3)
A step-by-step, end-to-end tutorial on how to be effective
immediately with J2EE application development using Oracle
tools. Author: Steve Muench, Oracle ADF Development Team Contributions from Steven Davelaar & Sandra Muller, JHeadstart
TeamDate: April 17, 2007
Abstract
There
is good chance you've heard that developing database-centric business
applications for the J2EE platform is a complex endeavor. Luckily, there is
hope. Over the past few years, analysts like Gartner Group coined the term
"J2EZ" for a class of tools and frameworks that make J2EE application
development easy. These so-called "J2EZ" tools target developers for whom time
to market, low implementation costs, and productivity are driving factors, by
providing a visual, declarative, and highly productive environment. This
document provides step-by-step instructions to evaluate what you can achieve
today using production versions of Oracle's offerings in this "J2EZ" space by
combining the 10.1.3 versions of Oracle's JDeveloper 10g IDE, the Oracle
Application Development Framework (ADF), and the Oracle JHeadstart 10g
Application Generator for Oracle ADF.
By following this tutorial,
you'll experience first-hand how Oracle JHeadstart 10g turbo-charges your
developer productivity for Oracle ADF-based web applications. You will build an
attractive, consistent, interactive, and skinnable web application with browse,
search, insert, update, and delete functionality against six related database
tables from the Oracle HR sample schema. Your application will feature single-
and multi-row editing, page-by-page scrolling, master/detail handling, tabbed
pages, dropdown lists, a pop-up list of values (LOV) window, a wizard, a
shuttle picker, a tree control and a graph. Since no Java coding is required to
implement the tutorial, even developers with minimal-to-no Java skills can
follow along. This is possible because Oracle ADF-powered J2EE applications
only require custom code to add application-specific business logic or to
augment default framework behavior.
Contents 1 Overview of Oracle ADF and Oracle JHeadstart
10g 2 Tutorial Setup 2.1 Download the Tutorial Files 2.2 Start with
JDeveloper 10g, Release 10.1.3.2 2.3 Install Oracle JHeadstart 10g 10.1.3.1
Using "Check for Updates" 2.4 Setup the Oracle HR Schema and Sample
Data 2.5 Define a JDeveloper Connection for the HR Schema 2.6 Set ADF Business Components Java Generation
Preferences 3 Creating a Default Web Application 3.1 Create and
Configure a New Workspace 3.2 Create Default ADF Business
Components 3.3 Generate Default Web
Tier with JHeadstart 3.4 Run the Application 3.5 Observe Default Application
Functionality 4 Change Layout Styles and Query
Behavior 4.1 Change How Employees Group Gets
Generated 4.2 Change How the Departments Group
Gets Generated 4.3 Change How the Jobs Group Gets
Generated 4.4 Change How the Countries Group Gets
Generated 4.5 Change How the Regions Group Gets
Generated 4.6 Regenerate and Run the Application 5 Create Department Manager List of Values (LOV)
5.1 Add Manager Name to Departments Query 5.2 Create a List of Values (LOV) Group 5.3 Use the LOV on ManagerName and Hide the
ManagerId 5.4 Regenerate and Run the Application 6 Creating a Wizard Including a Shuttle
Control 6.1 Add View Object Instances to the Data Model
to Support the Wizard and Shuttle 6.2 Create and Configure a New EmpWizard
Group 6.3 Create and Configure Three Item Regions
for the EmpWizard Group 6.4 Configure Subordinates Detail Group to Use
Shuttle 6.5 Regenerate and Run the Application 7 Using Stacked Tabs for Table Overflow
Items 8 Adding a Conditionally
Dependent Field 9 Generating a Graph and Summary Information 10 Using "Deep Linking" to Support
Targeted Hyperlinks 10.1 Configure the Job Group for Deep
Linking 10.2 Changing JobId to a Hyperlink Using the
JDeveloper Visual Editor 10.3 Run the Application to Test the JobId
Hyperlink 11 Preserving Customizations Using Generator Templates 11.1 Moving the Customization into a Generator
Template 11.2 Using the New Template for the JobId Column 11.3 Regenerate and Run the
Application 12 Applying
Custom Skins to Change Look and Feel 13 Adding a
Validation Rule and Customizing Error Reporting 13.1 Defining Some Declarative Validation
Rules 13.2 Rerunning the Application to See Validation Rules in Action 13.3 Declaratively Customizing the Way Errors are
Reported 14 Conclusion 14.1 No
Generated Java Code For Any Functionality in the Entire Tutorial! 14.2 Simplified
Multi-Lingual Applications with Message Files 14.3 J2EE Applications Give
Choice of Application Server 14.4 Useful Links for Additional Information on
JHeadstart, JDeveloper, and Oracle ADF 14.5 Now You Can Try On Your Own Schema Related Documents
1 Overview of Oracle ADF and Oracle JHeadstart
10g
On their own, the Oracle Application Development Framework
(ADF) together with the Oracle JDeveloper 10g IDE give developers a productive,
visual environment for building richly functional J2EE applications without
having to implement J2EE design patterns and low-level plumbing code by hand.
As its name implies, Oracle JHeadstart 10g offers a significant additional
productivity advantage in creating sophisticated web-based, J2EE business
applications. Standing squarely on the shoulders of the base Oracle ADF
framework, Oracle JHeadstart adds an additional capability for generating
fully-working JavaServer Faces (JSF) web tier for the data model exposed by
your ADF application module. The ADF web applications you generate with
JHeadstart leverage the powerful ADF Faces components for JSF so can easily
support multi-row editing, lists of values (LOVs) with validation, tree and
shuttle displays, and consistent search pages, among many other
features.
JHeadstart
automates creating and iteratively evolving the web tier of your ADF
application based on a declarative application definition. Once you've allowed
JHeadstart to generate the bulk of your application's web user interface, you
can spend your time using JDeveloper's productive environment to tailor the
results or to concentrate your effort on real showcase pages that need special
attention.
Like all Oracle
ADF-based applications, those leveraging Oracle JHeadstart are J2EE compliant
and therefore easy to deploy to any J2EE application server. They also inherit
Oracle ADF's implementation all of the best practice
J2EE design
patterns [3] required to implement robust, functional business
applications.
As we'll see in this step-by-step demo, the
JHeadstart Application Generator does not generate any Java code. Instead, it
generates web pages, ADF metadata describing the data needed on those pages,
JavaServer Faces (JSF) metadata describing the page flow, and translatable
message bundle files. We'll also see that all of the basic functionality
provided by the underlying Oracle ADF framework components in the demo does not
require any generated Java code either. We hope you'll walk away impressed by
what you can do without writing a single line of Java code using this powerful
combination of J2EE tools and frameworks from Oracle. Any lines of code that
you would eventually write in a real application would be squarely focused on
enhancing all of the built-in functionality provided with your own custom
business application logic.
| NOTE: |
Oracle JHeadstart 10g for ADF is
a separate extension for Oracle JDeveloper 10g for which a fully-functional
trial version is available for your evaluation purposes. Complete information
on pricing, support, and additional services available for JHeadstart 10g is
available in the JHeadstart Frequently Asked Questions
document on the
JHeadstart
Product Center [4] on OTN.
|
| TIP: |
After you've followed
the demo steps yourself, the same steps work well as a scripted demo you can
show to others to spread the good word about the many powerful features
provided by the combination of Oracle JDeveloper 10g, Oracle ADF, and Oracle
JHeadstart working together.
|
2 Tutorial Setup
This section outlines the steps you'll need
to follow to get your machine ready to go through this tutorial. We recommend
not skipping any steps in this section without reading them!
2.1 Download the Tutorial Files
If you are reading this tutorial online, download the
jhs-step-by-step.zip [5]
file that contains the database setup scripts. Extracting this zip file into
the root directory of your C:\ drive will create a
jhs-step-by-step directory. You can browse the
index.html page to read this same tutorial
offline. The database setup scripts (described more in
detail below) are in the hr_schema
subdirectory.
2.2 Start with
JDeveloper 10g, Release 10.1.3.2
This tutorial
requires Oracle JDeveloper 10g Studio Edition, release
10.1.3.2 Production. If you have a version of Oracle
JDeveloper installed, you can verify what version it is by selecting the
Help | About option from the main menu.
| NOTE: |
JHeadstart 10.1.3.1 will also work with JDeveloper release 10.1.3.1 Production.
JHeadstart 10.1.3.1 is not certified to work
with JDeveloper 10.1.3.0 Production.
|
If you need to download JDeveloper 10g Release
10.1.3.2 look for the correct version on this
JDeveloper
Downloads [6] page.
To install JDeveloper, create a convenient
directory (e.g. C:\jdev1013) and extract the
jdevstudio10132.zip file into this directory using the
standard Java jar utility, WinZip, or other zip-compatible
tool you prefer.
To start JDeveloper 10g, double-click on
jdeveloper.exe in the C:\jdev1013 folder
as shown in Figure 1. You can create a desktop shortcut for
C:\jdev1013\jdeveloper.exe to make launching JDeveloper
easier on future occasions.
 Figure 1: Launching
JDeveloper 10g on Windows
| NOTE: |
On Unix-based platforms,
run the ./jdev/bin/jdev shell script to launch JDeveloper
10g.
|
Upon starting JDeveloper 10g for the first time, the
Migrate User Settings alert may appear asking
"Would you like to migrate from a previous version of
JDeveloper?" If it does, just click (No) to
continue.
Dismiss the Tip of the Day dialog
if it appears by clicking (Close).
2.3 Install Oracle JHeadstart 10g 10.1.3.1
Using "Check for Updates"
Oracle JHeadstart is an Oracle
JDeveloper extension (or "plug-in") that you install using
JDeveloper's "Check for Updates" functionality. If anything about
these installation instructions doesn't work for you as indicated, check the
JHeadstart
10g Product Center [4] on OTN, under the Downloads
heading, for further assistance.
To install the JHeadstart 10g
Evaluation Version into your JDeveloper 10g 10.1.3 environment, perform the
steps below.
-
Run the "Check for Updates" wizard
With
JDeveloper 10.1.3 running, choose Help | Check for
Updates... from the main menu.
-
Select the Source for Extensions
In
Step 1 of 3: Source ensure that you have selected both the
Official Oracle Extensions and Updates as well as the
Open Source and Partners Extensions update centers, then
click (Next >).
-
Select the Oracle JHeadstart Evaluation Version Extension to
Install
In Step 2 of 3: Updates, as
shown in Figure 2 choose the Oracle
JHeadstart Evaluation Version 10.1.3.1.23 extension, then press
(Next >).
 Figure 2: Selecting the JHeadstart Evaluation Version Extension to Install
-
Acknowledge the Legal Agreement
Read and acknowledge the Oracle Technology Network license for the
evaluation version of Oracle JHeadstart by clicking (I
Agree). JDeveloper begins the download of the selected
updates...
-
Exit and Restart
JDeveloper
When the download is completed, on the
Summary page of the wizard, click
(Finish). The Confirm Exit alert
appears because you need to exit and restart JDeveloper to install the service
update. Click (Yes) to exit. On Windows,
JDeveloper will exit and automatically restart. On Mac, Linux, or
other platforms, JDeveloper will exit and you will need to launch it
again.
-
Acknowledge the Installation
Alerts
When JDeveloper restarts, you may see
the Confirm Overwrite alert, making you aware that the
automatic installer will be replacing a file in your JDeveloper
installation. This is expected, so check the Skip this Message Next
Time checkbox, and click (Yes) to continue.
When the Migrate User Settings alert appears, click
(No) to continue.
-
Acknowledge the Successful Installation Alert
After the installation is completed, you'll see the alert shown in
Figure 3 confirming the successful installation.
Press (OK) to continue.
 Figure 3: Acknowledging the Successful Install of
JHeadstart
-
Rename the
Velocity Version 1.3 JAR File
As noted in the successful
installation alert in Figure 3, you must perform one
manual step of renaming a file that is supplied with JDeveloper. This
step is required because the JHeadstart extension provides a later version of
this library than the one that ships with JDeveloper. To rename this
file, do the following:
-
Exit from
JDeveloper
Choose File | Exit
to exit JDeveloper.
-
Rename the
velocity-dep-1.3.jar File in the Windows Explorer
As
shown in Figure 4, find the
velocity-dep-1.3.jar in the
C:\jdev1013\jdev\lib directory, and use the
Rename option on the right-mouse menu to rename
it to velocity-dep-1.3.jar_old.
 Figure 4: Renaming
velocity-dep-1.3.jar to
velocity-dep-1.3.jar_old in Windows Explorer
-
Restart JDeveloper
After renaming the
jar file as indicated above, you can restart JDeveloper 10g 10.1.3 to
continue.
2.4 Setup the Oracle HR Schema and Sample
Data
The demo steps are based on the standard Oracle sample
HR schema of human resources information. For your
convenience, this tutorial comes with the SQL scripts to create the HR schema
tables if you didn't install the sample schemas when you installed your
database.
2.4.1 Create the HR Schema If
Necessary
If you don't already have an HR user
account created in your database, you can follow these steps to create
it.
C:\jhs-step-by-step> sqlplus /nolog
SQL> connect sys as sysdba
SQL> create user hr identified by hr;
created.
SQL> alter user hr default tablespace users;
altered.
SQL> grant connect, resource to hr;
SQL> connect hr/hr
connected.
SQL> quit
2.4.2 Create the HR
Schema Sample Tables
In the hr_schema
subdirectory of this tutorial, you'll find the hr.sql
script. This script drops, recreates, and repopulates all the tables in the
HR sample schema. Change directory to the hr_schema
subdirectory, and run the script as the HR user, with the
command:
C:\jhs-step-by-step> cd hr_schema
C:\jhs-step-by-step\hr_schema> sqlplus hr/hr @hr.sql
| NOTE: |
If you are using an Oracle 9i database, you can
ignore the error you'll receive at the end for the PURGE
RECYCLEBIN command. That command is specific to Oracle
10g.
|
2.5 Define a JDeveloper Connection for the HR Schema
Select
View | Connection Navigator to show the
Connection Navigator and follow these steps:
-
Create a New
Database Connection
Click on the
Database folder, and select New Database
Connection... from the right-mouse menu as shown in
Figure 5.
 Figure 5: Defining a New Database Connection
-
Enter a Connection Name
On
step 1 of the wizard, as shown in Figure 6, provide a
connection name of hr and click
(Next>).
 Figure 6: Naming
Your Connection
-
Provide the Username and Password Details
On step 2, provide the username and password information for the hr
connection. Make sure to check the Deploy Password option
as shown in Figure 7, then press
(Next>).
| NOTE: |
It's OK to deploy the
password in the connection definition since it gets saved in an encrypted
format. |
 Figure 7: Providing
Username/Password for the Connection
-
Provide Host, Port, and SID Information
In step 3, provide the host, port, and SID information for the database
where you've installed the HR schema tables. The defaults shown in
Figure 8 are right for a default Oracle database
installation on the current machine. You may have to change the settings if
you're database is on another machine or has a different SID. Press
(Next>) when done with this step.
 Figure 8: Providing Database Connection
Details
-
Test the Connection
As shown in
Figure 9, click the (Test Connection)
button to test the connection. If you don't see the "Success!" message, press
(<Back) and double-check the information you've
provided on the previous wizard pages. When you see "Success!", click
(Finish) to complete the process of defining a
connection.
 Figure 9: Testing the Database
Connection
2.6 Set ADF Business Components Java Generation
Preferences
By default, the ADF Business Components design time is
configured to generate skeleton Java classes where developers could eventually
write their code. Producing these skeleton classes by default is not required,
and there is an IDE preference to control it. If you don't generate them by
default, you can easily add them on a case-by-case basis should custom Java
code ever become required for a given component type.
In order to
better understand what ADF application functionality requires Java code and
what does not, it's useful to set the ADF Business Components Java generation
preferences at the IDE level so that the wizards and editors create no custom
Java classes by default. By doing this, at the end of the demo we can see what
Java classes actually are part of our working, finished application to get a
better understanding of what combined, built-in functionality Oracle ADF and
Oracle JHeadstart 10g provide.
To change this preference, select
Tools | Preferences... from the JDeveloper main menu
and click on the Business Components category.
Uncheck any of the checked boxes in the panel at the right
as shown in Figure 10, then click
(OK).
 Figure 10: Setting
ADF Business Components to Generate No Java by Default3 Creating a Default Web Application
In this section we will:
- Create a
new workspace,
- Create the ADF Business
Components to handle our backend database access, and
- Generate a default set of web pages with
JHeadstart
Then, we'll run the
application inside JDeveloper 10g to see what default behavior we get before
starting to iteratively modify the application to further tailor it to work
like our end users want.
3.1 Create and
Configure a New Workspace
-
Create a new Application Workspace
Choose File | New... from the JDeveloper
main menu, and double-click the Application icon in the
General category of the New Gallery. In the
Create Application dialog, select the application template
named Web Application [JSF, ADF BC] as shown in
Figure 11. To make it easier to follow along in this
tutorial, please enter the Application Name
(MyDemo), Directory Name
(C:\MyDemo), and Application Package
Prefix (mydemo) exactly as shown. By doing this
you'll make it easiest to follow this tutorial's step-by-step
instructions.
 Figure 11: Creating a New
Application Workspace
When you click (OK) to create the workspace,
JDeveloper will create your new MyDemo workspace that will
contain two (initially empty) projects named Model and
ViewController.
-
Give Your Web Application a Meaningful Web Context Root
Name
Select the ViewController
project still selected in the Application Navigator, and choose
Project Properties... from the right-mouse menu.
Visit the J2EE Application category and notice that the
default web context root name is
MyDemo-ViewController-context-root. The J2EE web context
root name is the first part of your application's web URL that users will see,
so having a short, meaningful name is preferable to this long default name. So
let's set the J2EE Web Context Root to just
“MyDemo” instead. Technically, this step is optional, but it
gives your application a nicer-looking runtime URL and it's nice to know where
you would change it for your own applications.
-
Simplify Running the Application By Changing a Project
Setting
While still in the Project
Properties dialog, to make it easier to quickly run the application,
disable JDeveloper's default behavior of trying to run the current
file. To do this, do the following:
- Visit
the Run/Debug category
- Select the
Default configuration in the Run
Configurations list
- Click
(Edit...)
- Uncheck the checkbox Attempt to Run the
Active File before Default.
- Click
(OK) to dismiss the Edit Run
Configuration
dialog.
Finally,
click (OK) to dismiss the Project
Properties dialog, saving your changes.
3.2 Create Default ADF Business
Components
The ADF Business Components handle all of the database
access for you in a way that is cleanly separated from the user interface. The
application module provides the transactional component
clients use to browse and modify view object data. The view
object performs SQL queries and coordinates with entity objects to
handle updates. The entity object encapsulates business
domain data and validation for rows in a table. In this step we'll use wizards
to create all three types of components based on existing tables in the
database.
-
Create Default
Business Components for Tables in HR Schema
-
Run the Business
Components from Tables Wizard
Select your
Model project and choose New... from
the right-mouse menu. In the New Gallery, expand the
Business Tier node, select the Business
Components category, and choose Business Components from
Tables.
-
Set the Database
Connection to Use
When the Initialize
Business Components Project dialog appears, select the name of the
HR connection you defined above as shown in
Figure 12.
 Figure 12: Selecting the HR
Connection to Work With
-
Create Entity Objects for Selected HR Tables
On the Step 1 of 5: Entity Objects page of the
wizard, if it is not already checked, toggle the
Auto-Query checkbox to see all of the available
tables.
As shown in Figure 13 shuttle the six
tables COUNTRIES, DEPARTMENTS,
EMPLOYEES, JOBS,
LOCATIONS, and REGIONS tables into the
Selected list, and enter the Package
name of mydemo.model.entities in which to create the entity
objects.
| TIP: |
Providing a different package name for each
different kind of ADF Business Component helps make your model project more
manageable. |
 Figure 13: Selecting Tables for
Which to Create Entity Objects
-
Create Updateable View Objects for All Entity
Objects
On the Step 2 of 5: Updateable View
Objects page of the wizard, enter a Package
name of mydemo.model.queries as shown in
Figure 14, and shuttle all of the available entity
object names into the Selected list in order to create
default view objects for them.
 Figure 14: Creating Updateable View Objects for All Entity Objects
-
Skip Past the Read-Only View Objects
Panel
As shown in Figure 15,
just skip past the Step 3 of 4: Read-Only View Objects
page of the wizard since we don't need any read-only view objects for this
demo.
 Figure 15: Skipping the Read-Only View
Objects Panel
-
Give Your Application Module Component a Meaningful
Name
On the Step 4 of 5: Application
Module page of the wizard, as shown in Figure 16
enter a package name of mydemo.model and choose a meaningful
name for your application module like HRModule, then click
(Finish) to create all of your business components.
 Figure 16: Naming the Application Module
| NOTE: |
For a more detailed explanation of this step, see the "Setting Up
the Business Components Package" section in Chapter 2. Getting
Started from the
JHeadstart
Developer's Guide [10]. |
-
Organize Your Application Navigator
After creating your default set of business components in the
mydemo.model, mydemo.model.entities and
mydemo.model.queries packages, your Application Navigator may
look like what you see in Figure 17. The Flat
Level control in the Application Navigator toolbar controls how many
levels of dot-separated package names should be flatted for presentation in the
tree. The Sort by Type toggle button switches between
sorting your components:
- Alphabetically,
and
- By component type, then
alphabetically.
 Figure 17: Model Project in the Application Navigator with Default Flat Level of 3
and Sorted Alphabetically
For example, if you set the
Flat Level to 1 and enable the
Sort by Type toggle button, your navigator will change to
look like what you see in Figure 18.
 Figure 18: Model Project in the Application
Navigator with Flat Level 1 and Sorted By Type
-
Add Five-level Master/Detail to the Application
Module's Data Model
In the Application Navigator,
inside your Model project find the
HRModule component. It's in the
mydemo.model package. Edit the HRModule
application module by double-clicking it. This will open the
Application Module Editor. Visit the Data
Model panel, and as shown in Figure 19
you'll see both the list of Available View Objects from
the current project, and the named, master/detail-coordinated
usages of those view objects in this application module's
Data Model. The view object usages in the data model are
also known as view object instances since at runtime they
represent an instance of the reusable view object component.
 Figure 19: Initial HRModule Data Model
We're going to
modify the default data model to add nested view object usages in order to get
a 5-level deep nesting of region → country → location → department → employee.
We start by adding a LocationsView view object
instance as a child/detail of CountriesView2, by doing the
following:
- In the
Data Model tree control, select the existing view instance
CountriesView2 that will become the new master (for the
next-level detail we're about to add).
- Expand
the
CountriesView view object in the Available
View Objects list
- Select the
LocationsView view object that is indented under
CountriesView in the Available View
Objects list. This indenting means that it is an
available detail view for any instance of a
CountriesView master in the data model.
- Click the (>) button to shuttle a new
LocationsView3 instance into the data model as detail of the
existing, selected
CountriesView2.
We can
repeat the process to add an instance of DepartmentsView as
a detail of the LocationsView3, and then again to add an
instance of EmployeesView as a detail of the
DepartmentsView4.
When finished adding the three
extra levels, your application module's data model will look like what you see
in Figure 20. Click (OK) to save your
changes.
 Figure 20: Default Application Module
Modified to Have Five-Level Master/Detail
3.3 Generate Default Web
Tier with JHeadstart
The Oracle JHeadstart extension for
JDeveloper uses metadata to capture the high-level definition of the layout and
features of your desired web application. The JHeadstart application generator then uses
that application definition metadata to generate the set of web pages that
comprise your web application user interface. In this section we'll enable our
project to use JHeadstart, ask JHeadstart to create a default application
definition metadata file, and then kick off the JHeadstart application generator to see
what kind of web application we get before proceeding to tailor the output
further in subsequent steps of the tutorial.
-
Enable JHeadstart
on the ViewController Project
Select the
ViewController project in the navigator and choose
Enable JHeadstart on this Project from the
right-mouse menu. Click (Next>) from the welcome
page, then click (Finish) to proceed with enabling
JHeadstart.
As shown in Figure 21, after
clicking (Finish) the first time the wizard will proceed
to create a number of necessary files and configure your project appropriately
to contain them. Each step it performs is listed in the text box in this panel
of the wizard. When done, click (Finish) again to close
the wizard. Then, click the Save All button in the
JDeveloper main toolbar to save all the changes.
 Figure 21: Enabling JHeadstart on ViewController
Project
-
Create the Default JHeadstart Application
Definition
Select the ViewController
project in the navigator, and choose the New JHeadstart
Application Definition item from the right-mouse menu. After
clicking (Next>) to leave the welcome screen, on the
next panel as shown in Figure 22, select the
HRModuleDataControl to use, leave the Create
default Groups for all Data Collections checkbox checked, and click
(Next>) again.
 Figure 22: Selecting the Application Module (Data Control) to Use
On the
following panel, take the defaults for the service/application name as shown in
Figure 23 , and click (Next
>).
 Figure 23: Choosing a JHeadstart Service/Application Name
On the next
panel, take the defaults for the default layout styles as shown in
Figure 24.
Before proceeding, take a
moment to notice the option to Generate LOV's instead of dropdown
lists?. While we won't enable this preference for this tutorial,
it's worth remembering that this option may be useful to you when you try the
Oracle JHeadstart Evaluation Edition on a subset of your own production schema.
JHeadstart can generate foreign key lookups as dropdown lists or as pop-up
list-of-values (LOV) windows. Dropdown lists are more appropriate for
smaller-sized lists of choices (e.g. less than 100 rows), while pop-up LOV
windows are more appropriate to select an foreign key value when many choices
exist and your end user might need to perform a search to find what they are
looking for.
Now, click (Next >) to
continue.
 Figure 24: Choosing Default Layout
Styles
On the final panel click (Finish) to create the new
application definition file. As shown in Figure 25
the wizard will display each of the steps it performs. When done, click
(Finish) again to close the wizard.
 Figure 25: Creating the Default Application
Definition File
-
Save Your Changes
Click the
Save All button in the JDeveloper main toolbar to
save all the changes.
-
Observe the
Default Application Definition
To view the JHeadstart
application definition you just created, select the
ViewController project and choose Edit
JHeadstart Application Definition from the right-mouse menu.
This opens the JHeadstart Application Definition Editor, which is a modeless window that you can
keep open while you continue to work with the main JDeveloper window.
Notice that JHeadstart has used the hierarchical structure of the
application module's data model to create the default application definition
for the web tier. In practice you will end up iteratively changing the default
application definition, but having a nice default definition to start with is a
big plus as we'll see.
As shown in
Figure 26, you can see the 5-level nesting of the
view object instances for regions, countries, locations, departments, employees
. You also notice that the JHeadstart New Application
Definition wizard has created you a rich set of default lookup
definitions (called domains) where foreign key
relationships exist in the base business component model. These domains are
referenced by items in the application definition for which drop-down lists
will be generated for the end-user to select a valid choice.
 Figure 26: Application Definition Editor Showing
Default Structure
-
Generate the Application
To run the
JHeadstart application generator, select your ViewController project in
the Application Navigator and choose Run JHeadstart Application
Generator from the right-mouse menu as shown in
Figure 27.
 Figure 27: Running the JHeadstart Application Generator for the First Time
During the
generation process, the JHeadstart Application Generator
log window tab will display the detailed progress, including errors (if any),
warnings, and informational messages. Figure 28
shows what this log window tab should look like after your first successful
generation run. If you should see entries in an Errors
category, which would appear at the top of the list with a "red ball" icon, the
message always gives helpful details about how to correct the problem. Note
that even when you see a few Warnings, these are
suggestions of "next steps" you need to do as the developer or best-practices
suggestions that the Generator cannot do automatically. Scrolling through the
messages in the Information section gives you an idea of
the amount of work that the JHeadstart application generator is saving you. In this case,
it has generated twenty-two (22) JSF pages and their corresponding declarative
databinding metadata, along with numerous other declarative artifacts that
support the application!
For your convenience, on future runs of
the JHeadstart application generator, in addition to the right-mouse menu option we
picked here, you can also just click on the Run JHeadstart
Application Generator toolbar button ( ) at the top of the JHeadstart Application Definition Editor
window. Both actions do the same thing.
 Figure 28: Warnings and Informational Messages
in the JHeadstart Application Generator Log Window
| NOTE: |
If you did get errors in the JDeveloper log, make sure
that you did not forget to do the setup step Rename the Velocity Version 1.3 JAR File above. If you did forget, exit JDeveloper,
perform the task recommended in that step, restart JDeveloper, and then try
running the JHeadstart application generator again.
|
3.4 Run the Application
Run the
ViewController project by selecting it in the application
navigator and then pressing F11 (or
clicking on the toolbar run icon ). JDeveloper will launch your default browser,
startup the embedded OC4J container with your web application deployed, and
show you the initial page of the application that will look like what you see
in Figure 29.
 Figure 29: Initial
JHeadstart-Generated Web Application
| TIP: |
If
instead of seeing the initial application page you see
some kind of timeout error in your browser as shown in
Figure 30, then you'll need to change a configuration
property of JDeveloper's embedded J2EE container (OC4J) to avoid this problem.
This typically occurs when you are on a network using DHCP to get a
dynamically-assigned IP address.
 Figure 30: Running Web App in JDeveloper Times Out in Browser
Before changing
the necessary setting, terminate the currently running embedded server by
selecting the Run | Terminate > Embedded OC4J
Server.
Next, select the Tools |
Embedded OC4J Server Preferences... main menu item in JDeveloper,
and change the Host Name of IP Address Used to Refer to Embedded
OC4J setting to Specify Host Name, and enter a
hostname of localhost as shown in
Figure 31. Then, try rerunning the application and it
should work this time.
 Figure 31: Changing
IDE Preference for Embedded OC4J Host Name |
3.5 Observe Default Application
Functionality
By playing with the default application yourself,
you can experience some of the built-in features that Oracle ADF and JHeadstart
support by default, and which the Oracle JHeadstart Application Generator
generates for you based on your declarative application definition file.
Highlights of these features include:
-
Switch Between
Top-Level Application Functionality with Tabs

- Browse Data and Drill-Down to Details or Related
Information

-
Automatic "Breadcrumbs" Provide User Hierarchical
Navigation Assistance

-
Create and Edit Data for Any Table Out of the
Box

-
Insert, Update, and Delete Multiple Rows on a Page

-
Select Related Data from Automatically Created
Lookups

-
Scroll Through Data Without Refreshing Entire
Page

-
Rapidly Find Data Using Quick Search
Region

-
Search More Precisely Using Advanced Search
Region

-
Easily Set Optional Fields to Null Using Drop-Down
Lists

-
Avoid Accidentally Losing Pending Changes When
Switching Top-Level Application Function

-
Never Wonder Whether Changes are Saved with Positive
User Feedback

4 Change Layout Styles and Query
Behavior
In this step of the demo, we'll change a number of
declarative application definition properties about the
Employees, Departments,
Jobs, and Regions groups to affect how
the JHeadstart application generator generates the web tier pages. We'll wait until making
them all before re-running the application generator.
To make the
changes described here, make sure you have the JHeadstart Application Definition Editor open. If
you don't, just select your ViewController project and
select Edit JHeadstart Application Definition from
the right-mouse menu.
| NOTE: |
Since the JHeadstart
Application Definition Editor dialog is modeless, you can keep it
| |