Use JDeveloper 11g ADF with ADF DVT Components
Introduction to ADF Data Visualization Components - Graphs,
Gauge, Maps, Pivot Table and Gantt
In this tutorial, you use the DVT components
in Oracle ADF to build some graphical representations of data, such as Pie Charts,
Gauges, Gantt charts and Geographical maps. You also explore the use of a pivot
table.
45 minutes
This tutorial covers the following sections:
Place
the cursor over this icon to load and view all the screenshots for this tutorial.
(Caution: This action loads all screenshots simultaneously, so response time
may be slow depending on your Internet connection.)
Note: Alternatively, you can place the cursor over
an individual icon in the following steps to load and view only the screenshot
associated with that step. You can hide an individual screenshot by clicking
it.
ADF Data Visualization components are
a set of rich interactive ADF Faces components that provide significant graphical
and tabular capabilities for analyzing data. After having performed the prerequisites
section, this tutorial shows you how to use the ADF DVT components to graphically
represent data.
Back to Topic List
After building a master-detail page,
you will experiment with some advanced features by adding graphical data to
your application. You add new tabs to the page and use dedicated ADF DVT components.
You will use a predefined application model, which is based on ADF Business
Components.
Back to Topic List
Before starting any section of the tutorial, you should:
Back to Topic List
Downloading the Required
Components and Start JDeveloper 11g
In the following steps, you download JDeveloper 11g
and other files required for this tutorial.
| 1. |
Have access to or have installed Oracle JDeveloper
11g (TP4). You can download it from Oracle
Technology Network.
|
| 2. |
Download the FOD schema zip file
from OTN or right click the following link
and choose Save Target As... from context to download
the storefront_techpreview2.zip
file on a local directory of your choice.
|
| 3. |
Unzip the storefront_techpreview2.zip
file on a local directory of your choice (i.e. temp)
|
| 4. |
Start JDeveloper. Double-click the JDeveloper executable
jdeveloper.exe
found in the root directory (<jdev_home>)
where you unzipped it.
If the Migrate User Settings dialog box opens, click
NO.
If prompted for a User Role, choose Default.
Close the Tip of the Day window.
|
| 5. |
The JDeveloper IDE should now be displayed.

|
Back to Topic
Back to Topic List
Installing the Database
Schema
In this part, you use a JDeveloper Application to install
the schema in your database and populate the FOD schema with the corresponding
data.
| 1. |
Click the Open Application link or from
the tool menu, choose File | Open.

Locate the workspace infrastructure.jws where you've
unzipped the storefront_techpreview2.zip
file. i.e.: d:\temp\Infrastructure.
Click Open. If you are prompted to
migrate the project, click Yes to confirm.
|
| 2. |
In the Application Navigator, expand the MasterBuildScript
| Resources nodes and double-click build.properties
to open it in the editor.

|
| 3. |
Set the appropriate values in the build.properties
file (jdeveloper.home, and all the jdbc.* and db.* settings). The relevant
settings are:
| jdeveloper.home |
Location where you have installed
JDeveloper, i.e. d:/jdev/jdev11gjdbc. |
| jdbc.urlBase |
Base URI for your database, i.e., jdbc:oracle:thin:@localhost |
| jdbc.port |
Port number for your database, i.e. , 1521 |
| jdbc.sid |
Database instance name, i.e. ,XE
or ORCL |
| db.adminUser |
Database user with admin privileges, i.e., system. |
| db.adminUser.password |
Password for database user with admin privileges,
i.e. , welcome |
| db.demoUser |
Name of database user and schema to be created,
i.e. , fod |
| db.demoUser.password |
Password for database user to be created, i.e.,
fusion |
| db.demoUser.tablespace |
Name of the user tablespace, i.e., USERS |
| db.demoUser.tempTablespace |
Name of the temporary tablespace,
i.e., TEMP |

|
| 4. |
In the MasterBuildScript project, select the build.xml
file.

|
| 5. |
In the Structure window, right-click the refreshSchema
target and choose Run Target "refreshSchema".

|
| 6. |
Verify that the log window doesn't report any error.
It should look like this:

|
| 7. |
Next to the Infrastructure application name, click
the down arrow
and select Remove Application from IDE.

|
| 8. |
Click Save All
icon on the JDeveloper menu bar, or select File | Save All.
|
Back to Topic
Back to Topic List
Uploading the Starter
Application
Before you create any component, you
must first open the startup application. To do this, perform the following steps:
| 1. |
Download the Gantt. zip file. Right click the following
link and choose Save Target As...
from context to download the Gantt.zip
file on a local directory of your choice.
|
| 2. |
Unzip the Gantt.zip
file on a local directory of your choice (i.e. temp)
|
| 3. |
From the Application Navigator, click the
Open Application link.

Locate the workspace c:\temp\BrowseEditApp\BrowseEditApp.jws.
Click Open. If you
are prompted to migrate the project, click Yes to confirm.
|
| 4. |
The Application is loaded up in JDeveloper.
|
Back to Topic
Back to Topic List
Creating a Database
Connection
You need to create a Database Connection
to the FOD schema. To do this, perform the following steps:
| 1. |
From the Menu Bar, select View | Database Navigator.
|
| 2. |
In the Database Navigator, right click BrowseEditApp
and select New Connection from context.
|
| 3. |
Enter a name for the connection, select the connection type, and
enter the username and password. To follow along with this example,
use FOD for the connection name, fod
for the username and fusion for the password.
|
| 4. |
Click Test Connection to confirm that you can connect.

Click OK if the connection was successful.
|
| 5. |
In the Application Navigator, open the Application Resources panel
by clicking on it.

|
| 6. |
In the Application Navigator, expand the Connections and
Database nodes in the Application Resources panel to see the
FOD connection you just created. You can expand the FOD node to view
the database objects.

|
Back to Topic
Back to Topic List
Exploring the Startup Application
The startup application uses Orders, OrderItems and ProductsBase
entity objects and their corresponding view objects. It also uses additional
view objects that you discover when required to use them.
| 1. |
Open the Application Navigator and expand the Model
project nodes. Notice the existing Entities, Views, Links objects and
the FODModule.

The model project contains all the necessary components needled for
the application. Collapse the Model project.
|
| 2. |
To test the module in the Business Component tester, in the Application
Navigator, right-click FODModule and choose Run.

|
| 3. |
In the Business Component Configuration dialog, click Connect.
Wait for the Browser window to open.
|
| 4. |
In the Business Component Browser, double-click OrdersItemsOrdersFkLink1.
|
| 5. |
Use the navigation buttons to browse through the Orders

|
| 6. |
Close the Business Component Browser window.
|
| 7. |
Expand the ViewController project nodes. Notice
the existing components that are created by default when creating a
Fusion Web Application.

|
Back to Topic
Back to Topic List
The startup application uses Orders, OrderItems and ProductsBase
entity objects and their corresponding view objects. It also uses additional
view objects that you discover when required to use them.
| 1. |
In the Application Navigator right click the ViewController
node and select New from context.

|
| 2. |
In the New Gallery, click the Current Project Technologies
tab, then select the Web Tier | JSF category and select
the JSF Page item.

Click OK.
|
| 3. |
Set the File Name field to OrdersAndStocks.

Click OK.
|
| 4. |
The new page opens up in the Design editor.

|
| 5. |
From the Component Palette, using the ADF Faces | Layout
library, drag and drop a Panel Tabbed component onto
the page.
In the Property Inspector, using the Style | Box tab,
set the Width to 100 Percent and the
Height to 600 Pixel.

|
| 6. |
Select the showDetailItem an in the Property Inspector
using the Common tab, type MDOrders
in the text field.

|
| 7. |
In the Application Navigator, expand the Data Controls
panel and the FODModuleDataControl node.
|
| 8. |
Drag the OrdersView1 node onto the visual editor,
and drop it onto the Page. From the Create context menu, select Forms
--> ADF Read-only Form.
|
| 9. |
In the Edit Form Fields dialog, check the Include Navigation
Controls check box., select all the fields except the following:
OrderId, OrderDate, OrderStatusCode, OrderTotal, and
CustomerId. Then click Delete
.

Click OK.
|
| 10. |
In the Data Controls panel, expand the OrdersView1
node. Drag the OrderItemsView2 node onto the lower
part of the form.

|
| 11. |
From the Create context menu, select Tables --> ADF Read-only
Table.

|
| 12. |
In the Edit Table Columns dialog, select both Row Selection
and Sorting. Select all the columns except
the following: LineItemId, Quantity, UnitPrice, and
ProductName. Click Delete .

Then click OK.
|
| 13. |
With the new table selected, in the Property Inspector, select the
Style | Box tab, enter 100 Percent
for the Width . For the Height enter 100 Pixel.

Select the Common tab and type orderItemsTable
as the Id.

|
| 14. |
The page should look like this:

|
| 15. |
Click Save All
icon on the JDeveloper menu bar, or select File | Save All.
|
| 16. |
Right click within the page and select Run from
context.

|
| 17. |
The page loads up in your browser.

|
| 18. |
Experiment the Navigation buttons.

|
| 19. |
Try the sorting facility on any of the detail columns.

|
| 20. |
Close the browser window.
At this point you have a working page, you are now
going to add graphical components such as bart chart, gauge, gantt chart,
geographic info and create a Pivot Table.
|
Back to Topic
List
In this section, you start adding a basic Pie chart based
on warehouse information to the OrdersAndStocks page, then you use the Advanced
Graph to enhance the pie chart characteristics.
Back to Topic
List
Creating
the Basic Pie Chart
Based on the view WarehouseStockLevelsView, you add a pie
chart to the MDOrders tab in the OrdersAndStocks page to render for each product
of a given order the corresponding stock level in each warehouse location. The
WarehouseStockLevelsView view is linked to the OrderItemsView via the productId
attribute.
| 1. |
Back to JDeveloper, expand the Model | Application
Sources | oracle.fod.model and double click the WarehouseStockLevelsView
view to open it in the editor.
|
| 2. |
In the editor click the Query tab,
to display the SQL statement. Notice that the view returns the following
columns: warehouse id, warehouse name, product id, and quantity on hand,
for any warehouseid based in the US having the product.
SELECT Warehouses.Warehouse_id,
Warehouses.Warehouse_Name,
WarehouseStockLevels.Product_Id,
WarehouseStockLevels.Quantity_On_Hand,
Addresses.Address1, Addresses.City,
Addresses.State_Province,
Addresses.POSTAL_CODE,
Addresses.Country_Id
FROM
WAREHOUSES Warehouses,
Warehouse_Stock_Levels WarehouseStockLevels,
Addresses Addresses
WHERE
Warehouses.warehouse_id = WarehouseStockLevels.warehouse_id
and Addresses.address_id = Warehouses.address_id and Addresses.Country_id='US'
|
| 3. |
In the editor window, click the OrdersAndStocks tab
to display the page.
|
| 4. |
In the Data Controls panel, expand the OrdersView1 | OrderItemsView2
nodes. Select the WarehouseStockLevelsView1 node and
drop it in the Structure pane below the OrderItems detail
table.
From the Create context menu, select Graphs
--> Pie. Notice that different specific graphs are proposed,
alternatively, using the Advanced Graph option allows you to create a
specific graph with more options. You see this later on.
|
| 5. |
In the Create Graph Binding dialog,
- deselect Include Child Accessors.
In the Data Points section,
- confirm that the Typed Attributes option is selected,
then click Add .
- Select Numeric Value from the Usage drop down list.
- Select QuantityOnHand from the Data Attribute drop
down
- Enter Quantity in the Label field.
In the Group By section,
- Select In Legend (Slices), then click Add
.
- Select WarehouseId from the Group Attribute drop down
list.
- Select WarehouseName from the Group Label Attribute
drop down.

|
| 6. |
Click the Preview tab. After connecting to the database
the diagram displays.

Click OK.
|
| 7. |
In the Property Inspector, using the Appearance group,
set the following property:
and expanding the Image node, set
the following properties:
| ImageHeight |
300 |
| ImageWidth |
400 |
| ImageFormat |
Flash |
| 3D Effect |
true |

|
| 8. |
In the Behavior tab, set PartialTriggers to orderItemsTable
so that the Graph is synchronized with the order item row selection.

|
| 9. |
In the Structure pane, select the dvt:pieGraph component and from the
Components Palette, click the ADF Data Visualization | Graph |
General | seriesSet. The seriesSet should be insert inside the
dvt:graph component in the Structure pane.
|
| 10. |
Right click the seriesSet component in the Structure
pane and select Insert Inside --> Series

|
| 11. |
In the Property Inspector for the Common tab, set
the PieSliceExplode to 100 which indicates how far one
exploded slice is away from the main pie.

In the Advanced tab set the Id to 0.

|
| 12. |
Save your work and click the Run
button in
the toolbar to run the Page.
|
| 13. |
The page loads up in the Browser. Notice that by default, percentages
are displayed for each slice and each serie label is associated to a different
color. Move the mouse over each slide to see the tooltip label (the warehouse
name and the quantity).

Close the browser window.
|
Back to Topic
Back to Topic List
Converting
to an Advanced Graph
Using the Convert option allows you to change the type visual
element and provides additional properties to define your graphical component.
| 1. |
Back to JDeveloper, in the Structure Pane, right click
the pieChart component and select Convert
from context.

|
| 2. |
In the Convert Pie dialog, Select Advanced Graph,
and click OK.

|
| 3. |
On the Edit Graph Binding dialog, click Preview. Notice
that by default the graph displayed is a Bar one.

|
| 4. |
In the Preview, click the Change Graph button.

|
| 5. |
Explore the various graph subtypes that exist in each graph type. Then
select Pie as the type and Pie as Subtype.

Click OK.
|
| 6. |
Back in the Create Graph Dialog, check the Use new graph type
check box.

Click OK.
|
| 7. |
On the Confirm Convert dialog, click OK to accept
the removal warning.

|
| 8. |
With the dvt:graph now selected, you can see that more
properties have now been added in the Property Inspector.
In the Property Inspector, using the Appearance tab,
in the Line Graph section, set MarkerTooltipType to MTT_PERCENT_VAL_VALUES
from the drop down list.

|
| 9. |
In the Property Inspector, using the Appearance tab,
in the Series section, set the SeriesRolloverBehavior
to RB_HIGHLIGHT and the SeriesEffect to SE_GRADIENT.

|
| 10. |
In the Property Inspector, using the Appearance tab,
in the Style section, set the StylePath to Comet.
(This is the property that was removed during the convert operation).

|
| 11. |
To replace the percentage values that appear for each slice, right
click the dvt:graph component in the Structure pane and
select Insert Inside --> ADF Data Visualization

From the Item list, select Slice Label and click OK.

|
| 12. |
In the Property Inspector, for the Common tab, set
the TextType to LD_TEXT

|
| 13. |
From the Component Palette, drag and drop a Legend Area inside
the graph component.
|
| 14. |
In the Property Inspector, for the Common tab, set
the Rendered property to false.

|
| 15. |
Save you work and click the Run button
to run the
page. |
| 16. |
The page displays in your browser window.

|
| 17. |
Move the mouse over a slice of the pie, the tooltips
now display quantity and percentage for each warehouse and the Warehouse
location now appears next to each slice.

|
| 18. |
Select a different slice, the pie chart should display
a new situation about this different product.

You can experiment selecting another line item.
|
| 19. |
Close the browser window. |
Back to Topic
Back to Topic List
Based on the same view, you add a Gauge graph reflecting the
stock level in each warehouse.
| 1. |
Back in JDeveloper, on the OrdersAndStocks.jspx
page in the editor window, right click the within the MDOrders
tab and from context select Insert after Show Detail Item -->
Show Detail Item.

|
| 2. |
In the Property Inspector, using the Common tab,
set the Text to StockLevels

|
| 3. |
Click the StockLevels tab, then open the Data
Controls accordion and select FODModuleDataControl
| OrdersView1 | OrderItemsView2 | WarehouseStockLevelsView1.
Drop it onto the StockLevels pane
|
| 4. |
Select Tables --> ADF Read-only Table.
|
| 5. |
In the Edit Table Column dialog, select Row Selection and Sorting
check boxes. Delete
the following attributes: WarehouseId, Address1, PostalCode.

Click OK.
|
| 6. |
In the Property Inspector, for the table component, using the Style
| Box tab, set the width to 100 percent
and the Height to 600 pixels.

|
| 7. |
Using the Behavior tab, set the Partial Triggers
property to orderItemsTable.

|
| 8. |
In the Component Palette, select the from the ADF Data Visualization,
select the Gauge component and drop it onto the Quantity
column.

|
| 9. |
In the Structure pane, right click the outputText #{row.Quantity}
and delete it.

|
| 10. |
In the Structure pane, select the dvt:gauge component
and in the Property Inspector set the following properties: for the
Common tab set the Gauge type to STATUSMETER.
Next to the Value Field select Expression Builder from
the list.

In the Expression Builder dialog, expand the JSP Objects |
Row and select QuantityOnHand, then using
the Insert into Expression button, shuttle it in the
Expression pane.

Click OK.
|
| 11. |
Select the Gauge Data tab and type 0
for the MinValue and 1000 to the MaxValue assuming
for our simple example that no stock level is ever greater that 1000
for a single product in a warehouse.

|
| 12. |
Select the Style tab and type 100 Percent
for the Width and 80 Pixel for the Height.

|
| 13. |
Select the af:column above the Gauge component in
the Structure pane and in the Property Inspector, for the Appearance
tab set the Width to 200.

|
| 14. |
In the next few steps, you add thresholds to the gauge, allowing
you to specify in our example minimum and maximum stock level indicators.
In the Structure pane select the gauge component and
in the Component Palette click the Threshold Set component.
This automatically adds the component inside the gauge.
|
| 15. |
With the Threshold Set selected in the Structure
pane, click three times on the Threshold component
on the Component palette to add 3 thresholds inside the Threshold Set.
|
| 16. |
Select the first Threshold component
in the Structure pane. In the Property inspector set the ThresholdMaxValue
to 30 which is the minimum stock level alert we want
to set.

In the Advanced tab set the id field to t0.

|
| 17. |
Select the second Threshold component in the Structure
pane. In the Property inspector set the ThresholdMaxValue to 700
which is the optimum stock level we want to have.

In the Advanced tab set the id field to t1.
|
| 18. |
Select the the third Threshold component in the
Structure pane. In the Property inspector leave the ThresholdMaxValue
empty. In the Advanced tab set the id field to t2.
|
| 19. |
In the next few steps, you format the way you want the metric label
and tick label to be displayed.
In the Structure pane select the gauge component and
in the Component Palette click the Tick Label component.
This automatically adds the component inside the gauge.
|
| 20. |
In the Structure pane select the tickLabel component
and in the Component Palette from the ADF Data Visualization
| Shared Child Tags, click the Number Format component.
This automatically adds the component inside the tickLabel.
|
| 21. |
In the Property Inspector, for the Number Format tag, using the Common
| Scale tab, set the ScaleFactor property to SCALEFACTOR_NONE

|
| 22. |
In the Structure pane select the gauge component
and in the Component Palette from the ADF Data Visualization
| Gauge, click the Metric Label component.
This automatically adds the component inside the gauge.
|
| 23. |
Using the Common tab, set the Position property
for the Metric Label to LP_INSIDE_GAUGE_RIGHT.

|
| 24. |
In the Structure pane select the metricLabel component
and in the Component Palette from the ADF Data Visualization
| Shared Child Tags, click the Number Format component.
This automatically adds the component inside the metricLabel.
|
| 25. |
In the Property Inspector, for the Number Format tag, using the Common
| Scale tab, set the ScaleFactor property to SCALEFACTOR_NONE

|
| 26. |
The Page should look like this:

|
| 27. |
Click the Run button
to run the Page.

|
| 28. |
Use the Navigation button to select another order then select an
orderItem. Click the StockLevels tab
to display the corresponding stock levels with the Gauge.

|
| 29. |
The stock level gauge shows how a product is doing in a warehouse
regarding to the minimum alert level.

|
| 30. |
You can experiment switching from the MDOrders tab
to the StockLevels one using a different order.
|
| 31. |
Close your Browser window.
|
Back to Topic List
Working on the same view previously used for warehouses located
in the US, using the spatial functionality of Oracle, you add a map to a new
tab in the existing page, indicating the geographical location of the related
warehouses.
| 1. |
Back to JDeveloper, in the OrdersAndStocks page, right click within
the StockLevels tab and select Insert after
Show Detail Item --> Show Detail Item

|
| 2. |
In the Property Inspector using the Common tab, change the Text to
Location.

Using the Style | Box tab set the Width to 100
Percent - the Height to 600 Pixel.
|
| 3. |
Click the Location tab, then in the Data Controls panel, expand
the OrdersView1 | OrderItemsView2 nodes. Select the
WarehouseStockLevelsView1 node and drop it on the page
in the Location tab.
|
| 4. |
From the Create context menu, select Geographic Map ->
ADF Map and Point Theme.
|
| 5. |
In the Create Geographic Map dialog, click Add
to create a new Map configuration.

|
| 6. |
Click the Add button
next to the MapViewer URL field.

Enter the following URL information:
Name: MapViewer
URL: http://elocation.oracle.com/mapviewer
Click the Test Connection button. The connection should
be successful.

Click OK
|
| 7. |
Repeat the previous step for the Geocoder field providing the following
URL information:
Name: Geocoder
URL: http://elocation.oracle.com/geocoder/gcserver
Click the Test Connection button. Connection should
be successful.
Click OK
Click OK. Back on the Map Configuration
dialog, click OK.

|
| 8. |
On the displayed map, click the top left arrow to
re center the map to north america which is the location corresponding
to the query, or enter -100 as Starting X and 40
as Starting Y to focus on north America. Click Refresh.

Click OK.
|
| 9. |
The Create Map Point Theme Binding dialog comes up. For Address,
pick US (street, city, state, zip) and choose the following
fields:
| Street |
Address1 |
| City |
City |
| State |
StateProvince |
| Zip Code |
PostalCode |
| Label |
WarehouseName |
Under Point Data specify:·
| Data |
Quantity on Hand |
| Label |
Quantity |
Click OK to insert the map.

|
| 10. |
In the Structure window, select the dvt:map component.
In the Property Inspector, on the Behavior tab, set
the PartialTriggers property to orderItemsTable
(the id of the table).
|
| 11. |
On the Appearance tab, set the MapZoom to 1.

|
| 12. |
To add a toolbar to the map, allowing zooming, area selection, and
other functionalities, from the Component Palette, select the Toolbar
component and drag and drop it underneath the dvt:map
component.
|
|
|