You are on page 1of 386

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY.

COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

D68162
July 2010
Edition 2.0
D53979GC20
ADF I
Activity Guide
Oracle Fusion Middleware
11g: Build Applications with

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Disclaimer

This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and
print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way.
Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display,
perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization
of Oracle.

The information contained in this document is subject to change without notice. If you find any problems in the document, please
report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.

Restricted Rights Notice

If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United

Oracle University and Datum, S.A. De C.V. use only


States Government, the following notice is applicable:

U.S. GOVERNMENT RIGHTS


The U.S. Governments rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted
by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.

Trademark Notice

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective
owners.

Authors
Kate Heap, Patrice Daux

Technical Contributors and Reviewers


Joe Greenwald, Glenn Maslen

This book was published using: Oracle Tutor


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Table of Contents

Practices for Lesson 1 .....................................................................................................................................1-1


Practices for Lesson 1: Introduction to Oracle Fusion and Oracle ADF .........................................................1-3

Practices for Lesson 2 .....................................................................................................................................2-1


Practices for Lesson 2: Getting Started with JDeveloper Discovering the Shopping Cart Application ........2-3
Practice 2-1: Setting IDE Preferences............................................................................................................2-4
Practice 2-2: Creating a JDeveloper Application and Project .........................................................................2-6
Practice 2-3: Initializing the Project and Creating a Database Connection ....................................................2-8
Practice 2-4: Examining the Course Application ............................................................................................2-10

Oracle University and Datum, S.A. De C.V. use only


Practices for Lesson 3 .....................................................................................................................................3-1
Practices for Lesson 3: Building a Data Model with ADF Business Components ..........................................3-3
Practice 3-1: Creating Default Business Components ...................................................................................3-4
Practice 3-2: Testing the Business Model ......................................................................................................3-8

Practices for Lesson 4 .....................................................................................................................................4-1


Practices for Lesson 4: Querying and Persisting Data ...................................................................................4-3
Practice 4-1: Creating Read-Only View Objects.............................................................................................4-4
Practice 4-2: Creating Multiple Read-Only View Objects at Once ..................................................................4-7
Practice 4-3: Creating Entity Objects Based on Database Views...................................................................4-9
Practice 4-4: Creating Multiple Entity Objects at Once...................................................................................4-11
Practice 4-5: Creating Associations ...............................................................................................................4-12
Practice 4-6: Creating Updatable View Objects .............................................................................................4-14
Practice 4-7: Refactoring Associations and Links ..........................................................................................4-17

Practices for Lesson 5 .....................................................................................................................................5-1


Practices for Lesson 5: Exposing Data to Clients...........................................................................................5-3
Practice 5-1: Creating an Application Module to Display Categories .............................................................5-4
Practice 5-2: Creating an Application Module to Display the Shopping Cart ..................................................5-5

Practices for Lesson 6 .....................................................................................................................................6-1


Practices for Lesson 6: Declaratively Customizing Data Services .................................................................6-3
Practice 6-1: Defining Control Hints ...............................................................................................................6-4
Practice 6-2: Declaratively Populating a Primary Key with a Database Sequence.........................................6-7
Practice 6-3: Designating History Columns ....................................................................................................6-9
Practice 6-4: Creating and Using View Criteria ..............................................................................................6-12
Practice 6-5: Creating Join View Objects .......................................................................................................6-15
Practice 6-6: Creating LOVs ..........................................................................................................................6-18

Practices for Lesson 7 .....................................................................................................................................7-1


Practices for Lesson 7: Programmatically Customizing Data Services ..........................................................7-3
Practice 7-1: Adding Code to Entity Objects ..................................................................................................7-4
Practice 7-2: Programmatically Assigning a Database Sequence..................................................................7-7
Practice 7-3: Populating History Columns When There Is No Logged-in User ..............................................7-9
Practice 7-4: Creating and Running a Test Client ..........................................................................................7-11
Practice 7-5: Creating an Application Module Base Class .............................................................................7-14
Practice 7-6: Editing an Application Module to Extend the New Base Class ..................................................7-17
Practice 7-7: Adding and Exposing Service Methods.....................................................................................7-18
Practice 7-8: Restrict the Shopping Cart Query .............................................................................................7-21

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
i
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 8 .....................................................................................................................................8-1


Practices for Lesson 8: Validating User Input ................................................................................................8-3
Practice 8-1: Adding Declarative Validation: List Validator .............................................................................8-4
Practice 8 -2: Adding Declarative Validation: Unique Key Validator ...............................................................8-7
Practice 8-3: Adding Programmatic Validation: Method Validator ..................................................................8-9
Practice 8-4: Creating and Using a Domain for Validation .............................................................................8-12
Practice 8-5: Testing the Validation................................................................................................................8-14

Practices for Lesson 9 .....................................................................................................................................9-1


Practices for Lesson 9: Troubleshooting ADF BC Applications ......................................................................9-3
Practice 9-1: Discovering Application Problems .............................................................................................9-4
Practice 9-2: Setting Breakpoints in the Debugger.........................................................................................9-5
Practice 9-3: Running the Application Module in Debug Mode ......................................................................9-7

Oracle University and Datum, S.A. De C.V. use only


Practices for Lesson 10 ...................................................................................................................................10-1
Practices for Lesson 10: Understanding UI Technologies ..............................................................................10-3

Practices for Lesson 11 ...................................................................................................................................11-1


Practices for Lesson 11: Binding UI Components to Data .............................................................................11-3
Practice 11-1: Creating Databound Pages .....................................................................................................11-4
Practice 11-2: Examining the Page's Data Bindings ......................................................................................11-8
Practice 11-3: Adding an Additional Detail Table ...........................................................................................11-11
Practice 11-4: Renaming a Page ...................................................................................................................11-13

Practices for Lesson 12 ...................................................................................................................................12-1


Practices for Lesson 12: Planning the User Interface ....................................................................................12-3
Practice 12-1: Creating an Unbounded Task Flow .........................................................................................12-4
Practice 12-2: Creating Bounded Task Flows ................................................................................................12-10
Practice 12-3: Extracting Part of a Task Flow ................................................................................................12-16

Practices for Lesson 13 ...................................................................................................................................13-1


Practices for Lesson 13: Adding Functionality to Pages ................................................................................13-3
Practice 13-1: Creating a Table with Row Selection ......................................................................................13-4
Practice 13-2: Creating a Search Page ..........................................................................................................13-10
Practice 13-3: Creating a Read-Only Form ....................................................................................................13-16
Practice 13-4: Creating a Sortable Table .......................................................................................................13-18
Practice 13-5: Creating a Category Tree ........................................................................................................13-20
Practice 13-6: Creating LOVs ........................................................................................................................13-24
Practice 13-7: Setting Up the UI Project for Internationalization ....................................................................13-28

Practices for Lesson 14 ...................................................................................................................................14-1


Practices for Lesson 14: Implementing Navigation on Pages ........................................................................14-3
Practice 14-1: Creating Buttons for Navigation ..............................................................................................14-4
Practice 14-2: Creating Links for Navigation ..................................................................................................14-9
Practice 14-3: Using Breadcrumbs.................................................................................................................14-18
Practice 14-4: Defining a Sequence of Steps .................................................................................................14-19
Practice 14-5: Simplifying and Enhancing a Task Flow..................................................................................14-26

Practices for Lesson 15 ...................................................................................................................................15-1


Practices for Lesson 15: Achieving the Required Layout ...............................................................................15-3
Practice 15-1: Stretching Tables and Columns ..............................................................................................15-4
Practice 15-2: Adjusting JDeveloper's Default Layout Components ..............................................................15-6
Practice 15-3: Adding Layout Components to Existing Pages .......................................................................15-8

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
ii
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 15-4: Creating New Pages with Required Layout .............................................................................15-12


Practice 15-5: Setting Conditional Display .....................................................................................................15-20
Practice 15-6: Implement PPR to Coordinate Products Display with Selected Subcategory .........................15-25

Practices for Lesson 16 ...................................................................................................................................16-1


Practices for Lesson 16: Ensuring Reusability ...............................................................................................16-3
Practice 16-1: Converting Bounded Task Flows to Use Page Fragments ......................................................16-4
Practice 16-2: Creating a Page Template and Applying It to Existing Pages .................................................16-7
Practice 16-3: Creating a Page Template and Applying It to a New Page .....................................................16-13
Practice 16-4: Using Bounded Task Flows as a Region on a Page ...............................................................16-20

Practices for Lesson 17 ...................................................................................................................................17-1


Practices for Lesson 17: Passing Values Between UI Elements ....................................................................17-3

Oracle University and Datum, S.A. De C.V. use only


Practice 17-1: Conditional Rendering Based on Parameters .........................................................................17-4
Practice 17-2: Using Parameters for Dynamic Breadcrumbs .........................................................................17-11
Practice 17-3: Implementing the Add to Cart Functionality ............................................................................17-13
Practice 17-4: Implementing Create Supplier Functionality (Optional) ...........................................................17-17

Practices for Lesson 18 ...................................................................................................................................18-1


Practices for Lesson 18: Responding to Application Events ..........................................................................18-3
Practice 18-1: Defining Task Flow Parameters ..............................................................................................18-4
Practice 18-2: Creating a Helper Method to Evaluate EL ...............................................................................18-5
Practice 18-3: Creating the Producer (Payload) Method ................................................................................18-9
Practice 18-4: Initiating the Contextual Event ................................................................................................18-12
Practice 18-5: Creating the Consumer (Handler) Method ..............................................................................18-14
Practice 18-6: Mapping the Contextual Event ................................................................................................18-16
Practice 18-7: Passing Values Through Region Parameters .........................................................................18-19
Practice 18-8: Modifying the JSF Life Cycle (Optional Exercise) ...................................................................18-21

Practices for Lesson 19 ...................................................................................................................................19-1


Practices for Lesson 19: Implementing Transactional Capabilities ................................................................19-3
Practice 19-1: Saving the Shopping Cart .......................................................................................................19-4
Practice 19-2: Updating, Deleting, and Displaying Details of Shopping Cart Items ........................................19-5
Practice 19-3: Controlling Transactions in the CheckoutFlow ........................................................................19-12
Practice 19-4: Adding CRUD Functionality for Suppliers (Optional Exercise) ................................................19-13

Practices for Lesson 20 ...................................................................................................................................20-1


Practices for Lesson 20: Implementing Security in ADF BC Applications ......................................................20-3
Practice 20-1: Configuring the Application to Use ADF Security ....................................................................20-4
Practice 20-2: Defining Users in the Identity Store .........................................................................................20-7
Practice 20-3: Defining Enterprise Roles .......................................................................................................20-8
Practice 20-4: Implementing Security on Task Flows and Pages...................................................................20-11
Practice 20-5: Testing Application Authentication and Authorization .............................................................20-13
Practice 20-6: Implementing Entity Object Security .......................................................................................20-15
Practice 20-7: Testing Entity Object Security .................................................................................................20-17
Practice 20-8: Accessing Security Context Programmatically ........................................................................20-18
Practice 20-9: Conditionally Displaying a Component Based on User Role ...................................................20-20
Practice 20-10: Modifying the Hard-Coded Username to Use the API ...........................................................20-23

Practices for Appendix A ................................................................................................................................21-1


Practices for Appendix A ................................................................................................................................21-3
Practice A-1: Creating a Database Diagram with Existing Schema Objects ..................................................21-4
Practice A-2: Adding New Schema Objects ...................................................................................................21-8
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
iii
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Appendix B ................................................................................................................................22-1


Practices for Appendix B: Deploying ADF BC Applications ............................................................................22-3
Practice B-1: Creating Deployment Profiles ...................................................................................................22-4
Practice B-2: Using a WebLogic Server Data Source ....................................................................................22-6
Practice B-3: Creating an Application Server Connection ..............................................................................22-9
Practice B-4: Deploying the Application from JDeveloper ..............................................................................22-10
Practice B-5: Deploying the Application from the WebLogic Server Administration Console .........................22-12

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Oracle Fusion Middleware 11g: Build Applications with ADF I Table of Contents
iv
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 1


Chapter 1 - Page 1
Chapter 1

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 1

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 1


Chapter 1 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 1: Introduction to Oracle Fusion and Oracle


ADF
There is no practice for this lesson.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1


Chapter 1 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 1


Chapter 1 - Page 4
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 2


Chapter 2 - Page 1
Chapter 2

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 2

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 2


Chapter 2 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 2: Getting Started with JDeveloper Discovering


the Shopping Cart Application
Practices Overview
In the practices for this lesson, you start JDeveloper, set preferences for the IDE, and create a
JDeveloper application, project, and database connection. You then view the course application
in a browser and identify the functionality of the pages.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 2-1: Setting IDE Preferences


In this practice, you start JDeveloper and set general preferences on the IDE.
1. Start JDeveloper, using the Default role.

a. Double-click the desktop shortcut to start JDeveloper.


b. In the Select Role dialog box, select the Default Role option and click OK.
c. In the Migrate User Settings dialog box, click No.
d. JDeveloper starts by displaying the Tip of the Day. Deselect the Show tips at
startup check box, and then click Close.
e. Close the Start page by clicking the X at the right of its tab. (The X is not visible until

Oracle University and Datum, S.A. De C.V. use only


you position the cursor over the tab.)
2. Set the global naming preferences for your ADF BC objects. Entity objects, view objects,
and application modules should, by default, have the suffixes EO, VO, and AM,
respectively, and should be created in the entity, uiview, and module packages,
respectively.
a. From the JDeveloper menu, select Tools > Preferences > Business Components >
Object Naming.
b. In the dialog box, set suffixes as follows:
Entity EO
View Object VO
Application Module AM

c. Select Packages in the list at the left and set the following values:
Entity entity
View Object uiview
Application Module module

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

d.

Practices for Lesson 2


Click OK.

Chapter 2 - Page 5
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 2-2: Creating a JDeveloper Application and Project


In this practice, you begin developing the Storefront application by creating an application and
project.
1. Create an application named Storefront in the oracle.fod.storefront package. Do
not use an application template. Create the initial project with the name StorefrontModel.
a. In the Application Navigator, click the New Application link.
b. On the Name page of the Create Application Wizard:
1) Enter Storefront as the application name.
2) Enter oracle.fod.storefront as the application package prefix.
3) Select Generic Application as the Application Template.

Oracle University and Datum, S.A. De C.V. use only


4) Click Next.
a. On the Name your project page of the wizard:
1) Enter StorefrontModel as the project name.
2) On the Project Technologies tab, shuttle ADF Business Components and
Database (Offline) from the Available list to the Selected list. (This also selects
the Java technology.)
3) Click Finish.
b. Note that the Application Navigator displays your application and project.

c. Also, note that the application overview page, Storefront Overview, is open in the
editor. This page enables you to see all the aspects of your application at a glance, to
obtain related help, and to create new objects. You can spend some time exploring this
overview if you want to, but it is not used in these practices.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

When you have finished looking at the overview, close it by clicking the X on its tab.
(The X is not visible until you move the cursor over the tab.) If you want to display it
again, right-click a project and select Show Overview.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 2-3: Initializing the Project and Creating a Database


Connection
In this practice, you initialize the StorefrontModel project for business components. In the
process of doing so, you create a database connection to use for the business components.
You also add any libraries that it requires.
1. Initialize the StorefrontModel project for business components. This requires a database
connection, so create that as part of this initialization.
a. Double-click the StorefrontModel project (or right-click it and select Project
Properties).
b. In the Project Properties dialog box, select Business Components from the tree at the
left.

Oracle University and Datum, S.A. De C.V. use only


c. In the Business Components panel, select the Initialize Project for Business
Components check box.

d. Click Create a new database connection to the right of the Connection field.
e. In the Create Database Connection dialog box:
1) Supply the information in the table below.
Connection Name FOD
Connection Type Oracle (JDBC)
Username fod (or follow the instructions given by
your instructor if you are using a shared
database)
Password fusion
Save Password Select the check box.

2) In the lower half of the page, Oracle (JDBC) Settings, leave the Driver field at its
default, thin, and enter the Host Name, JDBC Port, and SID as given to you by the
instructor if using a shared database, or localhost, 1521, and XE if using a local
XE database.
3) Click Test Connection. You should see that the Status box displays the word
Success!.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


f. Click OK to dismiss the Create Database Connection dialog box and return to the
Business Components page of the Project Properties dialog box.
g. Click OK to set the project properties and dismiss the Project Properties dialog box.

h. Click Save All to save your work. You should get into the habit of frequently
saving your work.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 2-4: Examining the Course Application


In this practice, you run the completed application and explore its functionality.
1. Open the Storefront-CompletedApp application in JDeveloper. There are several ways to
open an application.
a. If there is no open application currently, you can click the Open Application link in the
Application Navigator

Oracle University and Datum, S.A. De C.V. use only


OR if there is an open application, you can invoke the drop-down application list by
clicking the down arrow at the right of the application name in the Application
Navigator, and then selecting Open Application

OR click Open on the JDeveloper menu toolbar

OR select File > Open from the JDeveloper main menu.

b. When you select to open a new application, a file dialog box enables you to navigate to
the directory where the application resides:
1) Navigate to your courses \Labs directory and open the Storefront-
CompletedApp folder.
2) Select Storefront-CompletedApp.jws and click Open.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


The application opens in the Application Navigator. If requested to migrate the
application, execute the necessary steps to perform the operation.
2. Open the main task flow for the application, which is adfc-config.
a. The application contains two projects that are displayed on the first level of the
applications hierarchy. Expand the StorefrontUI node.
b. In the StorefrontUI project, expand the Web Content and Page Flows nodes.
c. Double-click adfc-config to open it in the editor.
3. When a task flow opens in the editor, you will see a Thumbnail tab to the left of the editor,
below the Application Navigator. Click the Thumbnail tab, and then drag the viewport
rectangle so that the view activities are visible in the editor.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

4. Examine the connection information and change it if necessary to point to your database.
a. Right-click the StorefrontModel project and select Project Properties. (You can also
double-click StorefrontModel to display the Project Properties Editor.)
b. Select Business Components in the tree at the left.
c. Next to Connection, click Edit.
d. Edit the connection information to your database connection (FOD) (see Practice 2-3,
step 1(e)).
e. Test the connection, and if successful, click OK.
f. Click OK to close the Project Properties Editor and save the settings.
5. To run the application, in the adfc-config diagram, right-click the
FODShoppingDashboard view and select Run. Test the functionality of the shopping

Oracle University and Datum, S.A. De C.V. use only


application.
a. JDeveloper starts an integrated Oracle WebLogic Server, deploys the application to it,
and runs the requested page in a browser. A tree of categories appears at the left, with
a table of categories and descriptions at the right. In the tree, expand the Media
category and click the Music subcategory.

b. A list of Music products appears in the right panel. Note that there are breadcrumbs
along the top of the table that enable you to navigate to the Media subcategory, or to
the main-level list of categories if you click Store. For now, click the name of one of
the products.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. Details about the selected product are shown. Buttons enable you to add the item to
your cart, to search for products, or to return to the shopping page. For now, click
Search.

Oracle University and Datum, S.A. De C.V. use only


d. On the Search page, enter Pla in the ProductName field and click Search. A list of
products beginning with Pla is returned.

e. Click the Playstation Portable link to display details about this product.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

f. Click Add Item to Cart to add the Playstation Portable to the shopping cart and display
the cart.

g. The shopping cart is displayed. It is populated with the shopping cart items of a default
user, and the Playstation Portable has been added. Resize the right panel of the page
so that the line total is visible, and then change the quantity of the Playstation Portable

Oracle University and Datum, S.A. De C.V. use only


to 2. Click Update to show the updated line total.

h. With the Playstation Portable selected, click Delete to remove it from your cart.

i. Click Details to display details about the selected product in a separate pop-up
window.

j. Click OK to close the pop-up window, and then click Checkout to begin the checkout
process.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

k. The first page of the checkout process displays the shipping information. Navigate to
the next page either by clicking Next or by clicking the Billing train stop at the top of
the panel.

Oracle University and Datum, S.A. De C.V. use only


l. The second page of the checkout process displays the billing information. Navigate to
the next page either by clicking Next or by clicking the Confirmation train stop at the
top of the panel.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

m. The final page of the checkout process displays all the informationshipping, billing,
and order items. Click Submit to submit the order and return to the shopping page.
Note: The Submit button does not actually do anything except perform navigation, but
in a complete application, it could fire off some additional services, such as creating an
order in the database, sending information about the order to the shipping department
and the billing department, and sending an email confirmation to the customer. This
functionality is outside the scope of the course application.

Oracle University and Datum, S.A. De C.V. use only


6. Test the functionality of managing suppliers.
a. Click the Suppliers tab in the left panel of the page.

b. The page displays a list of suppliers. Click New Supplier.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. The New Supplier page initializes. Enter any supplier name and select a supplier status
from the drop-down list, and then click Save.

d. The new row appears at the top of the list, with a supplier ID that is automatically
assigned. Click Delete to delete the supplier.

Oracle University and Datum, S.A. De C.V. use only


e. Click the SupplierId of one of the suppliers in the list.
f. On the Update Supplier page, change the Status of the supplier and click Save.

g. The supplier is shown in the list with the updated status.

h. Close the browser when you have finished.


i. To make the application start a little faster the next time you run it, you can undeploy
the application:
1) Select View > Run Manager.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 17
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) In the Run Manager window, select Storefront-CompletedApp (Running on


IntegratedWebLogicServer), and then click the red square to undeploy.

Another way to undeploy the application is to click Terminate in the JDeveloper


menu toolbar, and then select the application to undeploy.

Oracle University and Datum, S.A. De C.V. use only


j. The application is undeployed when the log window displays the message: [Application
Storefront-CompletedApp stopped and undeployed from Server Instance Instance
IntegratedWebLogicServer].
7. Close the Storefront-CompletedApp application. You should continue to work in the
Storefront application that you created.
a. Invoke the application menu by clicking the right-most down arrow at the top of the
Application Navigator.
b. Select Close Application from the IDE.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2


Chapter 2 - Page 18
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 3


Chapter 3 - Page 1
Chapter 3

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 3


Chapter 3 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 3: Building a Data Model with ADF Business


Components
Practices Overview
This exercise is to familiarize you with the default capabilities of JDeveloper and ADF Business
Components.
In this practice, you create a business model by using the wizards that are built into JDeveloper.
You see how to build a default model without any coding. In subsequent lessons and practices,
you learn to build and customize components to meet your specific application requirements.
If you successfully completed all sections of the previous practice, you can continue working in
the same project. However, if you prefer to start with a clean application that contains everything

Oracle University and Datum, S.A. De C.V. use only


completed up to the start of this lesson, open Storefront-03.jws and edit the database
information as described in step 4 of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3


Chapter 3 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 3-1: Creating Default Business Components


In this practice, you create some default business components that compose part of the
business model for the Storefront application. In the practices for subsequent lessons, you
create more customized business components and refine the default components as well.
1. Invoke the Business Components Wizard.
a. Right-click the StorefrontModel project in the Application Navigator and select New.
b. Select Business Tier > ADF Business Components in the Categories list.
c. Select Business Components from Tables in the Items list.
d. Click OK.

Oracle University and Datum, S.A. De C.V. use only


2. In the Create Business Components from Tables Wizard, create entity objects for the
ORDERS, ORDER_ITEMS, and PERSONS tables. Name them OrderEO, OrderItemEO, and
PersonEO.
a. On the Entity Objects page of the wizard, ensure that the schema from the connection
that you created previously is the selected schema.
b. Ensure that the package name is oracle.fod.storefront.entity.
c. Enter ORD in the Name Filter field. Click Query to see the available tables (ORDERS
and ORDER_ITEMS).

d. Click Add All to move both tables to the Selected pane.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3


Chapter 3 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Select ORDERS in the Selected pane and change the Entity Name to OrderEO
(instead of OrdersEO).

Oracle University and Datum, S.A. De C.V. use only


f. Similarly, change the Entity Name of OrderItemsEO to OrderItemEO.
g. Set the Name Filter to % and click Query to show all the available tables. If you were
creating several more entity objects, you could multiselect any tables for which you
want to create EOs and shuttle them to the Selected pane at the same time. For now,
just create one additional EO, PersonEO, based on the PERSONS table. Be sure to
change the default name of the entity object.
h. Click Next.
3. Continuing in the Create Business Components from Tables Wizard, create the following
updatable view objects (do not create any read-only view objects at this time):
VO Based on
ShoppingCartVO OrderEO
ShoppingCartItemVO OrderItemEO
a. On the Updatable View Objects page of the wizard, ensure that the package name is
oracle.fod.storefront.uiview.

b. Ctrl-click to select the OrderEO and OrderItemEO entities.

c. Click Add to move the selected items to the Selected list.


d. Rename OrderVO by selecting it in the Selected pane and changing the Object Name
to ShoppingCartVO. The reason for this is that you are creating a model for a
shopping application, where an order is represented as a customers shopping cart.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3


Chapter 3 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Similarly, rename OrderItemVO to ShoppingCartItemVO.

Oracle University and Datum, S.A. De C.V. use only


f. Click Next.
g. The next page is for creating read-only view objects. These are based on SQL queries
rather than on entity objects. For now, you will not create read-only VOs, so click Next.
4. Continuing in the Create Business Components from Tables Wizard, create an application
module to provide access to your components. You will later create application modules
that are customized for your application, but you can use a default application module for
testing your components. Create an application module named TestAM in the
oracle.fod.storefront.test package.
a. On the Application Module page of the wizard, ensure that the Application Module
check box is selected.
b. To separate this test application module from those that you customize for the
Storefront application, change the package name to
oracle.fod.storefront.test.
c. Change the application module name to TestAM.

d. Click Next.
5. Complete the wizard to finish creating the business components. Do not create a business
components diagram.
a. On the Diagram page of the wizard, ensure that the Business Components Diagram
check box is not selected.
b. Click Next.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3


Chapter 3 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. The last page of the wizard shows the components that you have chosen to create. It
should show the following components to be created:

Oracle University and Datum, S.A. De C.V. use only


d. Click Finish to create the business components. This may take a few moments.
e. Click Save All to save your work.
f. The StorefrontModel project in the Applications Navigator should look like this:

Note that the wizard created not only EOs, VOs, and an AM, but also two associations
and a view link based on the foreign key relationships that are defined in the database.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3


Chapter 3 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 3-2: Testing the Business Model


In this practice, you examine and test the components you just created.
1. Use the editor to examine the OrderEO entity object.
a. In the Applications Navigator, double-click the OrderEO entity to open the entity in the
editor.
b. Click the Attributes tab or panel to see the attributes. From this view, you can double-
click any of the attributes to open the Attribute Editor.
c. Each of the other panels (General, Business Rules, Java, Business Events, and View
Accessors) shows different aspects of the OrderEO entity. Click and examine each
panel.
d. Click the Source tab at the bottom of the editor to view and examine the XML source.

Oracle University and Datum, S.A. De C.V. use only


2. Test the default components by running the application module in the Business
Components Browser.
a. In the Application Navigator, right-click the application module (TestAM) in the
oracle.fod.storefront.test package and select Run.
b. The Business Components Browser may take a few minutes to appear, and it may
appear behind other windows. You can click its icon on the taskbar to display it.
The Browser should initially look similar to the following (the objects can be in a
different order):

c. Under the ShoppingCart1 node, double-click the OrderItemsOrdersFkLink1 to open


a page that shows the order items that belong to an order. Because this is a shopping
application, an order is contained in a shopping cart and order items are referred to as
shopping cart items.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3


Chapter 3 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


d. In the top portion of the page, click Move to the next row to navigate through rows
in the Orders view. Note that the order items change as you move to a new order.
e. Open the other views and examine the contents as you choose.
f. When you have finished, close the Business Components Browser.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3


Chapter 3 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 3


Chapter 3 - Page 10
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 4


Chapter 4 - Page 1
Chapter 4

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 4

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 4


Chapter 4 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 4: Querying and Persisting Data


Practices Overview
In the previous set of practices, you used the Create Business Components from Tables
Wizard to create multiple types of objects at once. You performed some limited customization of
components as enabled by the wizard, such as changing default names and locations.
Now you begin to create components that are more customized for your application. First you
determine the LOVs that your application requires, and you create read-only view objects to
support those LOVs. Next you create entity objects for tables that the application will update,
and you also create updatable view objects based on these. You also create and refactor
associations and view links. For now, you place all of the view objects and links in the TestAM

Oracle University and Datum, S.A. De C.V. use only


application module so that you can test them; in the next set of practices, you create custom
application modules that are designed for your application.
If you successfully completed all sections of the previous practice, you can continue working in
the same project. However, if you prefer to start with a clean application that contains everything
completed up to the start of this lesson, open Storefront-04.jws and edit the database
information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the
next lesson by opening the starter application for that lesson.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 4-1: Creating Read-Only View Objects


Most of the view objects in your application are required for updating information. However,
some view objects exist only to provide data for lists of values. In this practice, you create
read-only view objects to support LOVs.
Because these read-only view objects are based on SQL queries, you do not require an existing
entity object on which to base them. You create them by using either of two wizards:
Create View Object Wizard: Creates view objects individually; you must write the query
Business Components from Tables Wizard: Creates multiple view objects at once; you
select the table for the query that is automatically generated
1. Create a single read-only view object to query the LOOKUP_CODES table by using a bind
variable for LOOKUP_TYPE. Name the view object LookupCodeVVO. Create it in the

Oracle University and Datum, S.A. De C.V. use only


oracle.fod.storefront.view package. Put the view object in your TestAM
application module. Use the following query statement for the VO: (You can copy the code
from LookupCodes.txt in the \files subdirectory of your \labs directory for this
course.)
SELECT
LOOKUP_CODES.LOOKUP_TYPE LOOKUP_TYPE,
LOOKUP_CODES.LOOKUP_CODE LOOKUP_CODE,
LOOKUP_CODES.MEANING MEANING,
LOOKUP_CODES.DESCRIPTION DESCRIPTION,
LOOKUP_CODES.LANGUAGE LANGUAGE
FROM
LOOKUP_CODES
WHERE
LOOKUP_CODES.LANGUAGE = SYS_CONTEXT('USERENV', 'LANG') AND
LOOKUP_CODES.LOOKUP_TYPE = :BindLookupType
a. In the Application Navigator, right-click the StorefrontModel project and select New
from the context menu.
b. In the New Gallery, expand the Business Tier node in the Categories list and select
ADF Business Components. Select View Object in the Items list and click OK.
c. On the Name page of the Create View Object Wizard:
1) Change the package name to oracle.fod.storefront.view and enter
LookupCodeVVO as the view object name. (Note that the suffix is VVO rather
than VO that you used for the updatable view objects, and that you are placing the
read-only VOs in a separate package.)

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) Specify that the view object should have Read-only access through SQL query.

Oracle University and Datum, S.A. De C.V. use only


3) Click Next.
d. On the Query page of the wizard:
1) Enter the query statement shown in step 1. (You can copy from
LookupCodes.txt, or click Query Builder to build the query if desired, but make
sure that the finished query is as shown above.)
2) Click Test to verify that the query is valid.
3) Click Next.
e. On the Bind Variables page of the wizard:
1) Click New.
2) On the Variable tab in the lower section of the page, enter BindLookupType as
the name for the variable, leaving all other values at their defaults.

3) Click Next.
f. Continue clicking Next until you reach the Application Module page:
1) Select the Application Module check box.
2) Click Browse next to the Package field.
3) Click the Hierarchy tab in Package Browser and browse to and select the oracle
> fod > storefront > test package. Click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

4) If the Name field is not automatically populated with TestAM:


a) Click Browse next to the Name field.
b) In the Select Parent dialog box, expand oracle > fod > storefront > test.
c) Select the TestAM application module to enable you to test the query.
5) Click Finish to create the view object. The Application Navigator should look
similar to the following screenshot:

Oracle University and Datum, S.A. De C.V. use only


g. Save your work.
2. Test the query:
a. Run TestAM as you did previously.
b. In the Business Components Browser, double-click the LookupCodeV1 node.
c. In the Bind Variables dialog box, enter a Value such as SHIPPING_CLASS_CODE and
click OK.
d. Navigate through the rows to see all the payment type codes. Note that all fields are
disabled, because this view object is read-only.

e. Click Edit Bind Variables to invoke the Bind Variables dialog box to modify the
value. You can enter different values for bind variables to test whatever lookup codes
you want to check from the following lookup types:
SHIPPING_CLASS_CODE USAGE_TYPE_CODE
CONTACT_METHOD_CODE PRODUCT_STATUS_CODE
OWNER_TYPE_CODE PERSON_TITLE_CODE
DISCOUNT_TYPE_CODE CARD_TYPE_CODE
PERSON_TYPE_CODE MEMBERSHIP_TYPE_CODE
GENDER_CODE ORDER_STATUS_CODE
MARITAL_STATUS_CODE ID_TYPE_CODE
VERIFICATION_METHOD_CODE SUPPLIER_STATUS_CODE
PAYMENT_TYPE_CODE

f. When you have finished testing, close the Business Components Browser.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 4-2: Creating Multiple Read-Only View Objects at Once


In this practice, you use the Create Business Components from Tables Wizard to create
multiple read-only view objects at once.
1. Create the following read-only view objects (note the VVO suffix) in the
oracle.fod.storefront.view package:
Query Table or View VO
COUNTRY_CODES CountryVVO
PERSONS CustomerVVO
PAYMENT_OPTIONS (optional) PaymentOptionVVO

Oracle University and Datum, S.A. De C.V. use only


PRODUCTS (optional) ProductVVO
WAREHOUSES (optional) WarehouseVVO
Note: Creating all of these view objects is optional. You can create them all if you
want to, but you may choose to create only the first two. If you create only a
subset of the objects, you must begin the practices for the next lesson by opening
the starter application.
a. As you did in Practice 3-1, step (1), invoke the Create Business Components from
Tables Wizard.
b. Click Next to navigate to the Read-Only View Objects page of the wizard:
1) Set the package name to oracle.fod.storefront.view.
2) Select your schema (FOD) from the drop-down list.
3) Use the Name Filter, or simply click Query, to find and select the tables and views
shown above and modify the name in each case as before (note the VVO suffix).

4) Click Next.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. On the Application Module page of the wizard, place the view objects in your
application module as you did before by using the Browse buttons to navigate to, and
select the proper package (test) and application module (TestAM).
d. Click Finish to create the view objects.
e. Save your work. The Application Navigator should look like this:

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 4-3: Creating Entity Objects Based on Database Views


Although it is easy to create multiple EOs at once with the Create Business Components from
Tables Wizard, there are cases where you may want to use the Create Entity Object Wizard to
create EOs individually, because that enables a greater degree of customization at the time of
creation.
This application has some EOs that are based on database views, and it is necessary to
designate a primary key for such EOs. You can do that with the Create Entity Object Wizard.
In this practice, you create several database viewbased entity objects and designate their
primary keys.
1. Create an entity object named ProductCategoryEO and base it on the
Product_Categories database view. Set the CategoryId to be its primary key.

Oracle University and Datum, S.A. De C.V. use only


a. To invoke the Entity Object Wizard, you could use the New Gallery. However, there is
an even easier way to invoke the wizards:
1) In the Application Navigator, expand the StorefrontModel project.
2) Expand the Application Sources and oracle.fod.storefront nodes.
3) Right-click the entity node and select New Entity Object.

b. On the Name page of the Create Entity Object Wizard:


1) Ensure that oracle.fod.storefront.entity is the package name.
2) Enter ProductCategoryEO as the entity object name.
3) Ensure that the Database Schema Object option is selected and that the
database schema is FOD.
4) Click Browse to the right of the Schema Object field.
a) In the Select Schema Object dialog box, select the Views object type and
deselect Tables.
b) Click Query.
c) In the list of schema objects, select PRODUCT_CATEGORIES. Note that you
cannot multiselect more than one schema object, because you are creating
only one entity object with this wizard.
d) Click OK.
5) If the schema object is not automatically populated in the field, enter
PRODUCT_CATEGORIES. Click Next.
c. On the Attributes page, click Next to accept all columns. This wizard enables you to
remove or add attributes if necessary.
d. On the Attribute Settings page:
1) Select CategoryId from the Select Attribute drop-down list.
2) Select the Primary Key check box.
3) Click Finish to create your ProductCategoryEO entity object.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


2. Optional step (If you choose not to create these objects, you must begin the
practices for the next lesson by opening the starter application.)
Similarly, create the following entity objects that are based on database views:
EO Based on Database View Primary Key
PersonInformationEO PERSON_INFORMATION CustomerId
ProductEO PRODUCTS ProductId

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 4-4: Creating Multiple Entity Objects at Once


You can create entity objects individually as above, but it is much quicker to create multiple
entity objects if you do not have to specify the columns to include or change attribute settings
(such as setting the primary key). In this practice, you create the remaining entity objects at
once by using the Business Components from Tables Wizard.
1. Create the following entity objects that are based on tables:
EO Based on
AddressEO ADDRESSES
AddressUsageEO ADDRESS_USAGES

Oracle University and Datum, S.A. De C.V. use only


CountryEO COUNTRY_CODES
LookupCodeEO LOOKUP_CODES
PaymentOptionEO PAYMENT_OPTIONS
SupplierEO SUPPLIERS
WarehouseEO WAREHOUSES
WarehouseStockLevelEO WAREHOUSE_STOCK_LEVELS
Note: Creating all of these entity objects is optional. You can create them all if you
want to, but you may choose to create only the first two. If you create only a
subset of the objects, you must begin the practices for the next lesson by opening
the starter application.
a. In the Application Navigator, right-click the oracle.fod.storefront.entity package, and
select New Business Components from Tables.
b. On the Entity Objects page of the Business Components from Tables Wizard, check
whether the package name is oracle.fod.storefront.entity and the schema is
FOD. Click Query.
c. As you did in an earlier practice, Ctrl-click to select multiple tables for which to create
entity objects, and rename the entity objects, according to the table shown above.
d. Click Finish to create the entity objects.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 4-5: Creating Associations


When you use the Business Components from Tables Wizard to create entity objects, database
foreign keys are used to automatically generate associations. However, there are some
additional associations that you must create for the EOs that are based on database views, and
others that you must create where there are no foreign keys. In this practice, you create these
additional associations.
1. Create an association that relates CategoryId of the ProductCategoryEO entity object
to ParentCategoryId of the same entity object. Name the association
ProductCategoriesSubProductCategoriesAssoc.
a. Right-click the oracle.fod.storefront.entity package and select New Association.
b. On the Name page of the Create Association Wizard:

Oracle University and Datum, S.A. De C.V. use only


1) Ensure that the package is oracle.fod.storefront.entity.
2) Enter a name of ProductCategoriesSubProductCategoriesAssoc.
3) Click Next.
c. On the Entity Objects page of the wizard:
1) Expand ProductCategoryEO in the Select Source Attribute list and select the
CategoryId attribute.
2) Expand ProductCategoryEO in the Select Destination Attribute list and select the
ParentCategoryId attribute.
3) Click Add, and then click Next.

d. On the Association Properties page of the wizard:


1) Leave the check boxes selected in both Source Accessor and Destination
Accessor sections.
2) Click Next, and then click Finish.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2. Optional step (If you choose not to create these associations, you must begin the
practices for the next lesson by opening the starter application.)
In a similar manner, create the following additional associations, with accessors in both
source and destination (leave both check boxes selected):
Name Source Destination
OrdersOrderItemsAssoc OrderEO.OrderId OrderItemEO.OrderId
ProductCategoriesProductsAssoc ProductCategoryEO. ProductEO.CategoryId
CategoryId
3. Optional step (If you choose not to create this association, you must begin the

Oracle University and Datum, S.A. De C.V. use only


practices for the next lesson by opening the starter application.)
In a similar manner, create an association named OrderItemsProductsAssoc between
the ProductId fields of the OrderItemEO and ProductEO entity objects. The application
needs to access the product for a particular order item, but never needs to access order
items that pertain to a particular product, so expose accessors only in the destination
entity for this association. (Deselect the check box in the Source Accessor section.)
4. Save your work. Including the optional steps, the entity package in the Application
Navigator should now look like this:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 4-6: Creating Updatable View Objects


In this practice, you create updatable view objects based on some of the entity objects you
created in previous practices. Because you are creating view objects that are based on existing
entity objects, you must use the Create View Object Wizard.
In the application that you are building, the user interface displays categories and
subcategories. To accomplish this, the model requires two view objects: one that displays the
root categories (those without a parent category), and another that displays the subcategories.
A view link is also required to set up this master-detail relationship.
1. In the oracle.fod.storefront.uiview package, create two view objects that are based on
ProductCategoryEO: RootCategoryVO for those rows whose ParentCategoryId is null, and
SubCategoryVO. Place the view objects in your TestAM application module.

Oracle University and Datum, S.A. De C.V. use only


a. In the Application Navigator, right-click the oracle.fod.storefront.uiview
package and select New View Object from the context menu.
b. On the Name page of the Create View Object Wizard:
1) Ensure that the package is oracle.fod.storefront.uiview.
2) Enter RootCategoryVO as the view object name.
3) Select the Updatable access through entity objects option.
4) Click Next.
c. On the Entity Objects page:
1) Expand the oracle.fod.storefront.entity package node.
2) Shuttle ProductCategoryEO into the Selected pane.
3) Click Next.
d. On the Attributes page:

1) Click Add All to shuttle all attributes into the Selected pane.
2) Click Next.
e. On the Attribute Settings page, click Next.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

f. On the Query page:


1) Add the following WHERE clause:
ProductCategoryEO.PARENT_CATEGORY_ID IS NULL
2) Click Test to ensure that the query is valid, and click OK to acknowledge the
message.

Oracle University and Datum, S.A. De C.V. use only


3) Click Next.
g. Navigate through the subsequent pages until you reach the Application Module page:
1) Add the view object to the TestAM application module as you have been doing.
2) Click Finish to create the updatable view object.
h. Similarly, create the SubCategoryVO view object based on the same
ProductCategoryEO entity object, with all attributes.
1) Use the following WHERE clause:
ProductCategoryEO.PARENT_CATEGORY_ID IS NOT NULL
Place the view object in your TestAM application module.
2. The two view objects that you just created should be related by
ProductCategoriesSubProductCategoriesAssoc in a view link named
RootCategoriesSubCategoriesLink. Create this view link.
a. Right-click the oracle.fod.storefront.uiview package and select New View Link.
b. On the Name page of the Create View Link Wizard, enter a name of
RootCategoriesSubCategoriesLink, and then click Next.
c. From the Select Source Attribute list, select oracle.fod.storefront.uiview >
RootCategoryVO > ProductCategoriesSubProductCategoriesAssoc.
d. From the Select Destination Attribute list, select oracle.fod.storefront.uiview >
SubCategoryVO > ProductCategoriesSubProductCategoriesAssoc.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Click Add.

Oracle University and Datum, S.A. De C.V. use only


f. Click Next several times until you reach the Application Module page. Select the
Application Module check box and browse to select the TestAM application module
in the oracle.fod.storefront.test package. Click Finish to create the view link.
3. Optional step (If you choose not to create this object, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, create one more updatable view object named SupplierVO in the
oracle.fod.storefront.uiview package. Base it on SupplierEO, including all
attributes. Do not include a WHERE clause. Add the view object to the TestAM application
module.
4. Save your work, and then test the view objects and view link that you just created.
a. Run TestAM as before.
b. Check whether the RootCategory1 view object instance displays the data you expect
(only those categories without a ParentCategoryId should display).
c. Check whether the SubCategory1 view object instance displays the data you expect
(only those categories with a ParentCategoryId).
d. Test that RootCategoriesSubCategoriesLink displays the master-detail relationship
between root categories and subcategories, similar to the following:

e. Close the Business Components Browser when you have finished testing.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 4-7: Refactoring Associations and Links


If you inadvertently create objects in the wrong package, or if you want to reorganize the
created objects into different packages, you can use refactoring. In this practice, you move
existing associations and links into a separate package.
1. Move all associations into the oracle.fod.storefront.assoc package.
a. In the Application Navigator, multiselect (Ctrl-click) all associations in the
oracle.fod.storefront.entity package.
b. Right-click and select Refactor > Move. Note that depending on the optional steps you
have or have not done, your application might look different from the following images.

Oracle University and Datum, S.A. De C.V. use only


c. In the Move Business Components dialog box, enter the Package name of
oracle.fod.storefront.assoc and click OK.

d. Confirm that you would like to create the package by clicking Yes.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 17
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. JDeveloper creates the assoc package and moves the associations into it. This may
take several minutes.

Oracle University and Datum, S.A. De C.V. use only


2. In a similar manner, move all view links into the oracle.fod.storefront.link
package. Refactor links in both the uiview and the view packages.

3. Test the application module to ensure that all view links still function correctly.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4


Chapter 4 - Page 18
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 5


Chapter 5 - Page 1
Chapter 5

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 5

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 5


Chapter 5 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 5: Exposing Data to Clients


Practices Overview
In this practice, you take some of the view objects you have created and add them to application
modules. You create two application modules in this practice. The first application module
displays categories and subcategories. The second application module is for displaying and
managing a customers shopping cart.
In the interest of time, you create only two of the five application modules that are required for
the Storefront application, although you have the knowledge to create all five. When you begin
to develop the user interface, you will start with a completed model with all the objects and
application modules that you require.

Oracle University and Datum, S.A. De C.V. use only


If you successfully completed all sections of the previous practice, including the optional steps,
you can continue working in the same project. However, if you prefer to start with a clean
application that contains everything completed up to the start of this lesson, open
Storefront-05.jws and edit the database information as described in step 4 of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5


Chapter 5 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 5-1: Creating an Application Module to Display Categories


In this practice, you create the application module to display categories. It contains the two VOs
that are based on ProductCategoryEO and the view link that establishes a master-detail
relationship between root categories and subcategories.
1. Create an application module named FODCategoryAM and put it in the
oracle.fod.storefront.module package. It should contain RootCategoryVO and
also the VO for the subcategories, accessed through the view link.
a. Right-click the oracle.fod.storefront package and select New Application Module.
b. On the Name page of the Create Application Module Wizard, ensure that the package
name is oracle.fod.storefront.module. Enter the name FODCategoryAM and
click Next.

Oracle University and Datum, S.A. De C.V. use only


c. On the Data Model page, in the Available View Objects pane, expand
oracle.fod.storefront.uiview and RootCategoryVO.
d. Select RootCategoryVO and shuttle it to the Data Model.
e. With RootCategoryVO1 selected in the Data Model panel, shuttle SubCategoryVO
via RootCategoriesSubCategoriesLink to the Data Model.
f. Click Finish to create the application module.
g. Save your work.
2. Test the application module and then close the Business Components Browser when you
have finished.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5


Chapter 5 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 5-2: Creating an Application Module to Display the Shopping


Cart
In this practice, you create the application module to display a customers shopping cart.
1. Create the shopping cart application module named FODShoppingCartAM in the
oracle.fod.storefront.module package. It should contain the VOs that are based
on Orders and OrderItems, with the view link.
a. Right-click the oracle.fod.storefront.module package and select New Application
Module.
b. On the Name page of the Create Application Module Wizard, enter the name
FODShoppingCartAM and click Next.

Oracle University and Datum, S.A. De C.V. use only


c. On the Data Model page, expand oracle.fod.storefront.uiview and
ShoppingCartVO.
d. Select ShoppingCartVO and shuttle it to the Data Model.
e. With ShoppingCartVO1 selected in the DataModel, shuttle ShoppingCartItemVO via
OrderItemsOrdersFkLink to the Data Model.
f. Click Finish to create the application module.
g. Save your work.
2. Test the application module and then close the Business Components Browser when you
have finished.
Note: At first, this application module shows all orders. In the practices for a later lesson,
you add code so that it displays the shopping cart (status CART order) for a particular user.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5


Chapter 5 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 5


Chapter 5 - Page 6
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 6


Chapter 6 - Page 1
Chapter 6

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 6

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 6


Chapter 6 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 6: Declaratively Customizing Data Services


Practices Overview
In this set of practices, you make declarative modifications to your business components.
If you successfully completed all sections of the previous practice, you can continue working in
the same project. However, if you prefer to start with a clean application that contains everything
completed up to the start of this lesson, open Storefront-06.jws and edit the database
information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the

Oracle University and Datum, S.A. De C.V. use only


next lesson by opening the starter application for that lesson.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 6-1: Defining Control Hints


Control hints on entity object attributes enable you to globally define labels, tool tips, and
formatting for any views that are based on those entity objects. In this practice, you define and
test several control hints.
1. In the OrderEO entity object, format the OrderTotal as currency and set the labels of
OrderTotal, OrderDate, and OrderShippedDate to have spaces between the words.
You also set some tool tips.
a. In the Application Navigator, in the entity package, double-click OrderEO to open it in
the editor.
b. Click the Attributes tab at the left of the editor.
c. Select the OrderTotal attribute and click Edit . (You can also double-click the

Oracle University and Datum, S.A. De C.V. use only


attribute to open its editor.)
d. In the Edit Attribute dialog box, select Control Hints in the list at the left.
e. Set the Format Type to Currency.
f. Set the Label Text to Order Total by using a resource bundle (for translatable text),
as follows:
1) Click the ellipsis to the right of the Label Text field.
2) In the Select Text Resource dialog box:
a) In the Display Value field, enter Order Total. This automatically populates
the Key field, but you could change the Key value if desired. However, you
can leave it at the default for this attribute.
b) Enter the following in the Description field: Label for OrderTotal
attribute.
c) Click the Save and Select button.

g. Set the appropriate tool tip text, using a resource bundle.


1) Click the ellipsis to the right of the Tooltip Text field.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) In the Select Text Resource dialog box:


a) In the Display Value field, enter Computed total of the order, and in
the Key field, enter ORDER_TOTAL_TOOLTIP.
b) Enter the following in the Description field: Tooltip for the Order
Total attribute.
c) Click Save and Select.

Oracle University and Datum, S.A. De C.V. use only


Note: Whether or not the instructions specifically direct you to do so, you can use
a text resource in a resource bundle for any translatable text throughout these
practices, as you would need to do for a real application. However, in the interest
of time, you may choose to simply enter the hard-coded text.
h. Click OK to dismiss the attribute editor for OrderTotal.
i. Optional step: Using a resource bundle, enter appropriate Label Text and Tool tip
Text for OrderDate and OrderShippedDate. For example:

2. Optional step: Similarly, edit OrderItemEO to format UnitPrice as Currency and set its
Label Text to have a space between words.
3. Test the changes by running TestAM in the oracle.fod.storefront.test package.
a. Double-click ShoppingCart1 > OrderItemsOrdersFkLink1.
b. Look at the labels and formatting that you defined.
c. Position the cursor over OrderTotal, OrderDate, and OrderShippedDate to see the
tool tip text.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

d.

Practices for Lesson 6


Chapter 6 - Page 6
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Close the Business Components Browser when you have finished.

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 6-2: Declaratively Populating a Primary Key with a Database


Sequence
Declarative use of a database sequence to populate an EO attribute value relies on existence of
a database sequence and a database trigger to use that sequence. For example, the FOD
schema has a database sequence named SUPPLIER_SEQ and a database trigger that the DBA
created with the following script:
CREATE TRIGGER ASSIGN_SUPPLIER_ID BEFORE INSERT ON SUPPLIERS
FOR EACH ROW
BEGIN
IF :NEW.SUPPLIER_ID IS NULL OR :NEW.SUPPLIER_ID < 0 THEN

Oracle University and Datum, S.A. De C.V. use only


SELECT SUPPLIER_SEQ.NEXTVAL
INTO :NEW.SUPPLIER_ID
FROM DUAL;
END IF;
END;
This ensures that when a new row is committed with a null primary key, the value from the
database sequence populates the primary key. When you use a database trigger to populate
the primary key, there are few gaps in the sequence of the primary keys, because the database
sequence does not get used until the row is committed.
On the Business Components model side, all that is required is to populate the value
temporarily, so that the NOT NULL primary key can be committed. That is what happens when
you declaratively set the column to use a database sequence, as you do in this practice.
1. Set SupplierEO to use a database sequence at commit time for its primary key. There is
already a database trigger defined that populates the primary key from a database
sequence if it is null.
a. In the Application Navigator, double-click SupplierEO to open it in the editor.
b. Click the Attributes tab.
c. Select the SupplierId attribute and click Edit .
d. In the Edit Attribute dialog box, select Entity Attribute in the list at the left.
e. Select DBSequence from the Type drop-down list. (If not in the list, click Browse and
select it in the oracle.jbo.domain package.)

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

f. Make sure that the attribute has the following properties:

Oracle University and Datum, S.A. De C.V. use only


Value 0
While New Selected
Persistent Selected
Primary Key Selected
Queryable Selected
Insert Selected

g. Click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 6-3: Designating History Columns


There are several mandatory attributes in many of the entity objects that record information
about the record: who created it and when it was created, who last updated it and when it was
last updated, and a version number. These attributes can be automatically populated if you
designate them as history columns.
In this practice, you modify three of the entity objects so that the history columns are populated
automatically.
1. In the SupplierEO entity object, designate the following columns as history columns and
ensure that they are automatically populated at run time: CreatedBy, CreationDate,
LastUpdatedBy, LastUpdateDate, and ObjectVersionId.
a. In the Application Navigator, double-click SupplierEO to open it in the editor, or click

Oracle University and Datum, S.A. De C.V. use only


its tab if it is already open.
b. Click the Attributes tab.
c. Select the CreationDate attribute and click Edit .
d. In the Edit Attribute dialog box, select Entity Attribute in the list at the left.
e. Select the History Column check box and select created on from the drop-down list.
f. Click OK.
g. Similarly, edit the following attributes by selecting the History Column check box and
choosing the following values from the drop-down list:

Attribute Name History Column value


LastUpdateDate modified on
ObjectVersionId version number

h. To populate the history columns for created by and modified by, there must be a
logged-in user. You later designate these attributes as history columns, but to test with
the Business Components Tester with no logged-in user, you simply give these
columns default values. Set the default Value of the CreatedBy and LastUpdatedBy
attributes to anonymous. (Ensure that Literal is selected as the option for Value Type.)

2. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, modify the same five attributes for OrderItemEO and for OrderEO.
3. Save your work.
4. Test SupplierVO to ensure that you can actually insert and commit a record.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

a. Run the TestAM application module.


b. Double-click Supplier1.

c. Click Insert .
d. Ensure that a temporary SupplierId appears (it should be a negative number) and that
the history columns are populated.

Oracle University and Datum, S.A. De C.V. use only


e. Enter a SupplierName, such as ABC Plumbing, and a SupplierStatus, such as
ACTIVE.

f. Click Save .
g. Ensure that the SupplierId value is populated from the database sequence.

5. Optional step: (Perform this step only if you added history columns to these entities.)
Test OrderEO and OrderItemEO, making sure that when you insert a record the history
columns are populated.
a. Double-click ShoppingCart1 > OrderItemsOrdersFkLink1.

b. In the upper section of the panel, click Insert .


c. Ensure that all five of the history columns are populated.

d. Click Insert in the lower portion.


e. Ensure that the history columns are populated in the new row.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


f. Click Delete in the lower and then in the upper sections of the panel to delete the
new rows without committing them.
g. Close the Business Components Browser when you have finished.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 6-4: Creating and Using View Criteria


In this practice, you define a named query for the PaymentOptionVVO view object. Named
queries, referred to as view criteria, enable you to define complex sets of query criteria that you
can optionally apply at run time.
1. Add a named query to PaymentOptionVVO that selects records where CustomerId is
equal to a bind variable named PersonId.
a. In the Application Navigator, in the oracle.fod.storefront.view package, double-click
the PaymentOptionVVO view object to open it in the editor.
b. Click the Query tab to the left of the editor.
c. In the View Criteria section, click Add .

Oracle University and Datum, S.A. De C.V. use only


d. In the Create View Criteria dialog box, click the Criteria Definition tab and click the
Add Item button.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. In the Criteria Item section of the Create View Criteria dialog box, select the following
values from the drop-down lists:
List Name Value
Attribute CustomerId
Operator Equal to
Operand Bind Variable
Parameter Click New and define a variable named
PersonId of type Number.

Oracle University and Datum, S.A. De C.V. use only


Validation Optional

f. Click OK to create the named query.


2. Test the query by applying the view criteria in the Business Components Browser, using
values 110, 114, 117, or 119 for the bind variable.
a. Run TestAM in the Business Components Browser.
b. Double-click PaymentOptionV1.
c. In the PaymentOptionV1 window, click Specify View Criteria .
d. In the Business Component View Criteria dialog box, select
PaymentOptionVVOCriteria in the Available list and shuttle it to the Selected list, and
then click Find.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. In the Bind Variables dialog box, enter a value of 110 and click OK.

Oracle University and Datum, S.A. De C.V. use only


f. The payment options for customer 110 should be displayed.
g. You can test with other values if you would like to do so. Some other valid values are
114, 117, and 119.
h. Close the Business Components Browser when you have finished testing.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 6-5: Creating Join View Objects


Join views are those that include more than one entity object. One serves as the basis for the
view object, whereas additional entity objects are for reference.
For example, the OrderEO contains information about an order, including the CustomerId,
whereas PersonEO contains information about persons, including customers. In the
ShoppingCartVO view object, you may want to display the customer name or other customer
information, which is part of PersonEO. To accomplish this, you can include PersonEO in the
view object as a reference entity, creating a join view.
You can create join views when using the Create View Object Wizard. If you already have a
view object to which you want to add a reference entity, you can do so by editing the view object
to create the join view. That is what you do in this practice.

Oracle University and Datum, S.A. De C.V. use only


1. Add all the attributes from PersonEO as an inner join to be used as reference in the
ShoppingCartVO view object.
a. In the Application Navigator, in the oracle.fod.storefront.uiview package,
double-click the ShoppingCartVO view object to open it in the editor.
b. Click the Entity Objects tab to the left of the editor.
c. Expand oracle.fod.storefront.entity and shuttle PersonEO to the Selected list.
d. Select PersonEO in the Selected list. Ensure that the Association is set to
OrdersPersonsFkAssoc.Person and that the Join Type is set to inner join. Ensure
that the Updatable check box is not selected, and that the Reference check box is
selected.

e. Click the Attributes tab to the left of the editor.


f. Check to be sure that all the attributes from PersonEO have been added to the VO.
1) If they have not been added automatically, click the down arrow next to the Add

icon and select Add Attribute from Entity to add them.


Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) In the Attributes Editor, select PersonEO in the Available list and shuttle it to the
Selected listthis adds all of its attributes.

Oracle University and Datum, S.A. De C.V. use only


3) Click OK.
2. Optional step: (If you choose not to create these objects, you must begin the
practices for the next lesson by opening the starter application.)
Similarly, add reference entities and attributes to ShoppingCartItemVO as follows:
Entity Object Attributes
ProductEO ProductId
ProductName
Description
AdditionalInfo
ListPrice
ProductCategoryEO CategoryId
CategoryName
a. In the Application Navigator, double-click the ShoppingCartItemVO view object in the
oracle.fod.storefront.uiview package to open it in the editor.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. Add the reference entities and attributes shown in the table above, accepting the
default join types. If all attributes are added automatically, delete all attributes that are
added except for those shown in the table above.

Oracle University and Datum, S.A. De C.V. use only


3. Optional step: (Perform this step only if you added history columns to the
ShoppingCartItemEO entity.):
Delete the history attributes from ShoppingCartItemVO. You do not need these mandatory
attributes in the view object because you have set their values in the entity object.
a. If it is not already open, double-click the ShoppingCartItemVO view object in the
oracle.fod.storefront.uiview package of the Application Navigator to open it in the
editor.
b. Click the Attributes tab and delete the following attributes: CreatedBy,
CreationDate, LastUpdatedBy, LastUpdateDate, and ObjectVersionId.
c. Save your work.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 17
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 6-6: Creating LOVs


When you define a list of values in the back-end data model, any UI that uses that model
displays the LOV automatically.
In this practice, you create a view accessor that supports a list of values for the ProductId in
the ShoppingCartItemVO. You then modify the ProductId to use an LOV.
1. In OrderItemEO, create a view accessor to ProductVVO.
a. In the Application Navigator, double-click OrderItemEO in the
oracle.fod.storefront.entity package to open it in the editor.
b. Click the View Accessors tab at the left of the editor.
c. On the View Accessors panel, click Create new view accessors .

Oracle University and Datum, S.A. De C.V. use only


d. In the list of Available View Objects, expand oracle.fod.storefront.view.
e. Select ProductVVO and shuttle it to the View Accessors list, and then click OK.

f. Save your work.


2. In ShoppingCartItemVO, set ProductId to use a choice list as an LOV, and force users
to select a value from that LOV. Display the ProductId and ProductName in the LOV.
a. In the Application Navigator, double-click ShoppingCartItemVO in the
oracle.fod.storefront.uiview package to open it in the editor.
b. Click the Attributes tab to the left of the editor.
c. Select the ProductId attribute.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 18
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

d. Expand the List of Values section in the editor and click Add list of values .

Oracle University and Datum, S.A. De C.V. use only


e. In the List of Values dialog box:
1) On the Configuration tab:
a) Select OrderItemEO.ProductVVO1 as the List Data Source. (Click OK in
the Information dialog box.)
b) Select ProductId as the List Attribute.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 19
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) On the UI Hints tab:


a) Ensure that the Default List Type is Choice List.
b) Shuttle ProductId and ProductName to the Selected list; these are the
attributes that will appear in the list.
c) Deselect the Include No Selection Item check box.

Oracle University and Datum, S.A. De C.V. use only


3) Click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 20
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3. Test the LOV.


a. Run the TestAM application module.
b. Double-click the first-level ShoppingCartItem1. You should see that ProductId
appears as a drop-down list that shows the ProductId and ProductName. Note the
OrderId value.

Oracle University and Datum, S.A. De C.V. use only


c. Change the initial product to some other product.
d. Double-click OrderItemsOrdersFkLink1 under ShoppingCart1.
e. Query for the same order that appears in the ShoppingCartItem1 window (order 1034
in the example shown above). The corresponding shopping cart item should show the
change that you made in the other window. View objects that display the same data
remain in sync throughout the application.

f. Close the Business Components Browser.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6


Chapter 6 - Page 21
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 6


Chapter 6 - Page 22
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 7


Chapter 7 - Page 1
Chapter 7

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 7

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 7


Chapter 7 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 7: Programmatically Customizing Data Services


Practices Overview
In this set of practices, you add programmatic functionality to your business components.
If you have successfully completed all sections of the previous practice, including the optional
steps, you can continue working in the same project. However, if you prefer to start with a clean
application that contains everything completed up to the start of this lesson, open
Storefront-07.jws and edit the database information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the

Oracle University and Datum, S.A. De C.V. use only


next lesson by opening the starter application for that lesson.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-1: Adding Code to Entity Objects


In the application that you are building, users add items to their shopping carts and may also
perform other operations on their shopping carts. In this exercise, you add the Java code to add
an item to the cart; you must first generate a Java class for OrderEO where you can add the
code. Because the code uses methods from OrderItemEOImpl.java, you first generate that
Java class without adding any code to it.
1. Generate the Java class for OrderItemEO.
a. Open OrderItemEO in the editor and click the Java tab.
b. Click Edit .
c. Select the Generate Entity Object Class check box and click OK.

Oracle University and Datum, S.A. De C.V. use only


d. Save your work.
2. Generate the Entity Object Java class for OrderEO and add the following method for
adding an item to the cart: (You can copy the code from the addItemToOrder.txt file in
the \files subdirectory of your \labs directory.)
a. Similarly, generate the entity object class for OrderEO.
b. Click the Entity Object Class link to open OrderEOImpl.java in the editor.

c. Note that the Structure window shows the methods that are included in the class. (If
the Structure window is not visiblethat is, the default location is at the lower left of the
IDEthen you can select View > Structure to open it.) You can see accessors (getters
and setters) for all the OrderEO attributes. You can double-click any method to

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

navigate to it in the editor.

Oracle University and Datum, S.A. De C.V. use only


d. In the editor, scroll to the bottom of the file and just above the closing right brace, add
the code shown below. You can copy the code from the addItemToOrder.txt file in
the \files subdirectory of your \labs directory.
/**
* Add an item to the order. Typically used to add items to the
shopping cart.
*
* @param productId
*/
public void addItemToOrder(Number productId) {
if (productId == null) {
System.err.println("NO PRODUCT ID!!!");
throw new NullPointerException();
}

RowIterator orderItems = getOrderItem();


assert orderItems != null;

OrderItemEOImpl row;
boolean found = false;
for (row = (OrderItemEOImpl)orderItems.first(); row != null;
row = (OrderItemEOImpl)orderItems.next()) {
if (row.getProductId().equals(productId)) {
found = true;
break;
}
}

if (found) {
Number qty = row.getQuantity();
if (qty == null)
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

qty = new Number(1);


else
qty = qty.add(1);
row.setQuantity(qty);
} else {
OrderItemEOImpl newItem =
(OrderItemEOImpl)orderItems.createRow();
EntityDefImpl productEODef =
EntityDefImpl.findDefObject("oracle.fod.storefront.entity.Produc
tEO");

Oracle University and Datum, S.A. De C.V. use only


EntityImpl productEO =
productEODef.findByPrimaryKey(getDBTransaction(), new Key(new
Object[] { productId }));
Number unitPrice =
(Number)productEO.getAttribute("ListPrice");

newItem.setProductId(new Number(productId));
newItem.setQuantity(new Number(1));
newItem.setUnitPrice(unitPrice);
try {
getDBTransaction().validate();
} catch (TxnValException e) {
System.out.println(e.getMessage());
for (Throwable t : e.getExceptions()) {
System.out.println(t.getMessage());
}
} catch (JboException e) {
System.out.println(e.getMessage());
}
}
}

e. Press Alt + Enter if prompted to import the following:


oracle.jbo.TxnValException
oracle.jbo.JboException
f. Right-click the editor and select Make from the context menu, and then save your
work.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-2: Programmatically Assigning a Database Sequence


You had previously set a declarative type for an EO attribute to use a database sequence. This
technique results in few (if any) gaps in the numbers that are assigned. However, it may be
confusing for users to see a negative number until the record is committed. Another
disadvantage is that there must be a database trigger to assign the actual value.
Another technique for using a database sequence is to programmatically assign the database
sequence value as the default value for an attribute. No database trigger is required, but if the
record is never committed, this results in gaps in the numbers. In this practice, you implement
this eager assignment of values from a database sequence.
1. Set OrderItemEO to use a database sequence for the line item ID by supplementing the
initDefaults() method with the following code: (You can copy the code from the

Oracle University and Datum, S.A. De C.V. use only


initDefaults.txt file in the \files subdirectory of your \labs directory.)
SequenceImpl seq = new SequenceImpl("ORDER_ITEMS_SEQ",
getDBTransaction());
populateAttributeAsChanged(LINEITEMID, seq.getSequenceNumber());
a. Double-click the OrderItemEOImpl.java file in the Application Navigator to open
the source fileit is located under the OrderItemEO node.
b. From the context menu, select Source > Override Methods.
c. In the Override Methods dialog box, select the check box next to the method
initDefaults() : void and click OK (whereas in the Override Methods dialog
box, you can just start entering the method name to navigate to it, or use the scroll
bar).

d. After the line:


super.initDefaults();
Add the code shown above. You can copy the code from the initDefaults.txt file
in the \files subdirectory of your \labs directory.
e. Press Alt + Enter when prompted to import oracle.jbo.server.SequenceImpl.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

f. Right-click the method name initDefaults, and then select the Quick JavaDoc option

Oracle University and Datum, S.A. De C.V. use only


from the context menu. JDeveloper displays an explanation of the method. Click
outside of the doc window to close it.
g. Right-click the editor and select Make and make sure that no compilation errors are
reported in the Compiler Log pane.
h. Save your work.
2. Test the assignment of the line item ID.
a. Run the FODShoppingCartAM application module.
b. Double-click OrderItemsOrdersFkLink1. This opens the master-detail window for
Orders and OrderItems.

c. Click Insert a new row in the bottom pane of the window (the OrderItems
section).
d. Note that the row is created with a LineItemId value defaulted from the database
sequence ORDER_SEQ.

e. Because there are a number of mandatory columns, do not commit the new row.
f. Close the BC Browser without committing the row.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-3: Populating History Columns When There Is No Logged-


in User
You previously designated some attributes as history columns in the OrderEO, OrderItemEO,
and SupplierEO entity objects. However, because there was no logged-in user in the Business
Components Tester, you were not able to designate the CreatedBy and LastUpdatedBy
attributes as history columns.
In this practice, you add code to entity objects to automatically populate the CreatedBy and
LastUpdatedBy history columns.
1. In SupplierEO, modify the CreatedBy and LastUpdatedBy columns as follows:
a. Open the SupplierEO entity object, and click the Attributes tab.

Oracle University and Datum, S.A. De C.V. use only


b. For both attributes, delete the anonymous default value.
c. Designate the column as a history column with the appropriate value:

Attribute Name History Column value


CreatedBy created by
LastUpdatedBy modified by

2. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, designate the same columns as history columns in OrderEO and OrderItemEO.
3. As you did previously for OrderEO and OrderItemEO, generate the entity object class for
SupplierEO.
4. In the entity object class for SupplierEO, override the
getHistoryContextForAttribute() method with the following code, which you can
copy from the getHistoryContextForAttribute.txt file in the \files subdirectory
of your \labs directory:
protected Object getHistoryContextForAttribute(AttributeDefImpl
attributeDefImpl) {
Object value =
super.getHistoryContextForAttribute(attributeDefImpl);
// If value is null and is modify user or create user
// history column then return "anonymous"
if (value == null && (attributeDefImpl.getHistoryKind() ==
AttributeDefImpl.HISTORY_MODIFY_USER ||
attributeDefImpl.getHistoryKind() ==
AttributeDefImpl.HISTORY_CREATE_USER))
{
return "anonymous";
}
return value; }
a. Open the Java class in the editor.
b. From either the main menu or the context menu, select Source > Override Methods.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. In the Override Methods dialog box, select the check box to the left of the
getHistoryContextForAttribute(AttributeDefImpl) : Object method
and click OK. (You can use the filter field.)

Oracle University and Datum, S.A. De C.V. use only


d. Substitute the code shown above for the generated code. You can copy the code from
the getHistoryContextForAttribute.txt file in the \files subdirectory of
your \labs directory.

5. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, override the getHistoryContextForAttribute() method with the same
code in the entity object classes for OrderEO and OrderItemEO.
6. Run the TestAM application module and perform the same tests as you did in step 4 of
practice 6-3, (Supplier1 and also ShoppingCart1>OrderItemsOrdersFKLink1) except
that if you test the shopping cart, you will not be able to see how the history columns
appear in the shopping cart item record because the history columns are no longer part of
the ShoppingCartItemVO view object.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-4: Creating and Running a Test Client


In this practice, you create a Java client to experiment with some of the view object APIs.
1. Create a test client class named StorefrontTest in the
oracle.fod.storefront.test package.
a. In the Application Navigator, right-click the oracle.fod.storefront.test package and
select New from the context menu.
b. In the New Gallery:
1) Select General in the Categories list.
2) Select Java Class in the Items list.
3) Click OK.

Oracle University and Datum, S.A. De C.V. use only


c. In the Create Java Class dialog box:
1) Enter a name of StorefrontTest.
2) Make sure that only the Main Method check box is selected, and then click OK.

2. Use the bc4jclient shortcut to generate the test client code.


a. StorefrontTest.java opens in the editor. If it does not open, double-click it in the
Application Navigator to open it.
b. Delete the only line of code in the main() method and in its place, enter
bc4jclient, and press Ctrl + Enter to instantiate a BC4J application module.
3. Add code to print the number of rows in the PaymentOption view object, to execute the
query on the PaymentOption view object, and to print CustomerId and
PaymentTypeCode for all rows. Use the TestAM application module.
a. In the stub client code that is generated in the test client, modify the lines:
String amDef = "test.TestModule";
String config = "TestModuleLocal";
Change them to:
String amDef = "oracle.fod.storefront.test.TestAM";
String config = "TestAMLocal";
b. In the test client, change the line:
ViewObject vo = am.findViewObject("TestView");
to:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

ViewObject vo = am.findViewObject("PaymentOptionV1");
c. After the line:
// Work with your appmodule and view object here
and above the line:
Configuration.releaseRootApplicationModule(am, true);
add the following code: (You can copy it from the TestClient.txt file in the \files
subdirectory of your \labs directory.)
System.out.println("The table contains " +
vo.getEstimatedRowCount() + " rows:");
vo.executeQuery();

Oracle University and Datum, S.A. De C.V. use only


while (vo.hasNext()){
Row paymentOptionRow = vo.next();
System.out.println(" CustomerID: " +
paymentOptionRow.getAttribute("CustomerId") +
" Payment Type Code: " +
paymentOptionRow.getAttribute("PaymentTypeCode"));
}
Your code should look like the following:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

4. Right-click the editor and select Run. The test client runs and should display the data in the
log window. It ends when the log displays the message: Process exited with exit
code 0.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-5: Creating an Application Module Base Class


The Storefront application currently does not implement security. When the application is
eventually finished, security will be implemented and there will be a login module. However, for
testing and development purposes in the meantime, there must be a way to identify which
customer is using the application, so that shopping cart and checkout information for only that
customer appears in the application.
In the Java class that you create in this practice, the customer name is hard coded to simulate a
name that would ordinarily be retrieved from a login module.
1. Create a new Java Class named BaseApplicationModuleImpl in the
oracle.fod.storefront.module package, extending the default base application
module.

Oracle University and Datum, S.A. De C.V. use only


a. Right-click the oracle.fod.storefront.module package and select New.
b. In the New Gallery:
1) Select General in the Categories list.
2) Select Java Class in the Items list.
3) Click OK.
c. In the Create Java Class dialog box:
1) Enter a name of BaseApplicationModuleImpl.
2) Ensure that the package name is set to oracle.fod.storefront.module.
3) Next to the Extends field, click Browse.
a) In the Class Browser dialog box, click the Search tab and enter AMI
(uppercase) in the Match Class Name field, which displays a list of matching
classes.
b) Select the ApplicationModuleImpl(oracle.jbo.server) class and click OK.

4) Click OK to create the class and open it in the editor.


2. Add and initialize a private String variable named mCurrentUser.
a. Place your cursor just after the line:
public class BaseApplicationModuleImpl extends
ApplicationModuleImpl {
b. Press Enter to begin a new line.
c. Add the following declaration:
private String mCurrentUser = null;

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3. Override the getUserPrincipalName() : String method and replace the default


return statement with code that sets the current user to a hard-coded user: DRAPHEAL.
a. From the menu, select Source > Override Methods.

Oracle University and Datum, S.A. De C.V. use only


b. In the Override Methods dialog box, select the check box next to the
getUserPrincipalName():String method and click OK (whereas in the Override
Methods dialog box, you can just start entering the method name to navigate to it).

c. In the method, delete the line:


return super.getUserPrincipalName();
and replace it with the following code: (You can copy it from the
getUserPrincipalName.txt file in the \files subdirectory of your \labs
directory.)
/* TODO: This should be removed as soon
* as we have a working security model
*/
if (mCurrentUser == null) {
String userPrincipal = "DRAPHEAL";
mCurrentUser = userPrincipal;

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

}
return mCurrentUser;

Oracle University and Datum, S.A. De C.V. use only


4. Compile and save the code.
a. Right-click the editor and select Make.
b. Ensure that the log window displays no compilation errors. It should display the
message: Successful compilation: 0 errors, 0 warnings.
c. Save your work. The default preference in the IDE is to automatically save before
compiling.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-6: Editing an Application Module to Extend the New Base


Class
In this practice, you edit the shopping cart application module so that it extends the base class
that you just created.
1. Edit FODShoppingCartAM and generate a Java class for it that extends
BaseApplicationModuleImpl.
a. Open FODShoppingCartAM in the editor.
b. Click the Java tab.
c. Click Edit next to Java Classes.
d. In the Select Java options dialog box:

Oracle University and Datum, S.A. De C.V. use only


1) Select the Generate Application Module Class check box.
2) Because you must use the method in the BaseApplicationModuleAMImpl class
that you created earlier, this application module class must extend that one, so
click Classes Extend.
3) In the Override Base Classes dialog box:
a) Click Browse next to the Object field.
b) In the Find Superclass dialog box, click the Search tab and enter BA in the
Match Class or Package Name field. This should populate Matching Classes
and Packages.
c) Select the BaseApplicationModuleImpl class and click OK.
d) Click OK again to close the Override Base Classes dialog box.
e. Click OK to generate the application module class.
f. Save your work.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 17
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-7: Adding and Exposing Service Methods


The shopping cart application module in the completed application contains several methods for
initializing and managing the shopping cart. In this practice, you add two of these methods and
expose them to the client interface.
1. Examine the client interface for the application modules that you have created.
a. Expand the Data Controls panel and expand each of the FOD application modules.

Oracle University and Datum, S.A. De C.V. use only


b. You can see that the view objects and some operations are exposed to the client. Now
you add some service methods and expose them to the client as well.
2. Add a method to the shopping cart application module to initialize the shopping cart to that
of the current user of the application (remember that you hard coded the username in
BaseApplicationModuleImpl.java). The code is shown here: (You can copy the code
from the ShoppingCartInit.txt file in the \files subdirectory of your \labs
directory.)
public void init() {
DBTransactionImpl trx = (DBTransactionImpl)getDBTransaction();
ApplicationModuleImpl am =
(ApplicationModuleImpl)trx.getRootApplicationModule();
String user = am.getUserPrincipalName().toUpperCase();
System.out.println("The session user is: " + user);
ViewObjectImpl vo;
vo = getShoppingCart1();
String bindUser =
(String)vo.getNamedWhereClauseParam("CurrentUser");
if (! user.equals(bindUser)) {
vo.setNamedWhereClauseParam("CurrentUser", user);
/* The ShoppingCart is guaranteed to only have one row.
* However, we may not always properly initialize this
* from the UI because the actual row from ShoppingCart is
* not really needed. The following initializes the view
* object so that the view link to the shopping cart items
* properly works.
*/
vo.executeQuery();
Row cart = vo.first();
if (cart == null) {
cart = vo.createRow();
// TODO: Need to finish this off.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 18
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

cart.setAttribute("OrderDate",
((DBTransactionImpl)getDBTransaction()).getCurrentDbTime());
cart.setAttribute("OrderStatusCode", "CART");
vo.insertRow(cart);
}
}
}
a. In the Application Navigator, expand FODShoppingCartAM and double-click
FODShoppingCartAMImpl.java to open it in the editor.
b. Add the code shown above just before the closing right brace.
c. Press Alt + Enter if prompted to import the following:

Oracle University and Datum, S.A. De C.V. use only


oracle.jbo.Row
oracle.jbo.server.DBTransactionImpl
oracle.jbo.server.ApplicationModuleImpl
3. Now add a method that adds an item to the users shopping cart. This method should call
an entity object method that you added earlier to OrderEOImpl.java. Use the following
code (you can copy from addItemToCart.txt):
public void addItemToCart(Number productId) {
init();
ViewObject shoppingCartVO = getShoppingCart1();
assert shoppingCartVO != null;

ViewRowImpl shoppingCartRow =
(ViewRowImpl)shoppingCartVO.first();
assert shoppingCartRow != null;

OrderEOImpl orderEO =
(OrderEOImpl)shoppingCartRow.getEntity(0);
orderEO.addItemToOrder(productId);
}
a. Insert the code just before the closing brace in FODShoppingCartAMImpl.java.
b. Press Alt + Enter if prompted, to import the following:
oracle.jbo.ViewObject
oracle.jbo.server.ViewRowImpl
oracle.fod.storefront.entity.OrderEOImpl.
c. The code shows an error when calling the addItemToOrder() method. To fix it,
manually add the following import statement to the import section of the file:
import oracle.jbo.domain.Number;
d. Right-click the editor and select Make.
e. Save your work.
4. Now that you have written the service methods to initialize and add items to the shopping
cart, expose the new methods to the client interface.
a. Examine the Data Controls panel again. It looks the same as before. The new methods
are not yet available to the client interface.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 19
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. Edit FODShoppingCartAM and click the Java tab.


c. In the Client Interface section of the Java panel, click Edit .
d. In the Edit Client Interface dialog box, shuttle the init() and addItemToCart()
methods to the Selected list, and then click OK.
e. Save your work.
f. In the Application Navigator, expand FODShoppingCartAM and observe that two
additional Java files have been generated:
1) An FODShoppingCartAM interface
2) An FODShoppingCartAMClient class that implements the interface
g. Examine the Data Controls panel again. Click the Refresh button. You can now see the

Oracle University and Datum, S.A. De C.V. use only


service methods that you added. These methods are now available for use in a client,
such as the Storefront UI that you build later in this course.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 20
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 7-8: Restrict the Shopping Cart Query


Now that you have added a method to initialize the shopping cart, in this practice, you modify
the shopping cart to display only the cart for the current user.
1. Edit the shopping cart view object to restrict the shopping cart to display only the status
CART order belonging to one user. Use a bind variable named CurrentUser.
Hint: This should be a String that is contained in the Principal_Name column of
PersonEO.
a. In the oracle.fod.storefront.uiview package, open ShoppingCartVO in the editor.
b. Click the Query tab.
c. Click Edit.

Oracle University and Datum, S.A. De C.V. use only


d. In the Query dialog box:
1) The WHERE clause already reads:
OrderEO.CUSTOMER_ID = PersonEO.PERSON_ID
Append to the WHERE clause:
AND OrderEO.ORDER_STATUS_CODE = 'CART'
AND PersonEO.PRINCIPAL_NAME = :CurrentUser

2) Select Query > Bind Variables in the tree at the left.


3) In the Bind Variables panel, click New.
4) Enter a variable name of CurrentUser and click OK.

2. Test the shopping cart. Execute the init() method, but do not supply a value for the bind
variable, because that comes from the init() method.
a. Run FODShoppingCartAM.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 21
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. When the Business Components Browser appears, right-click the


FODShoppingCartAM node and select Show, or simply double-click the node.

c. Select init from the Method drop-down list.


d. Click Execute. The Result should be success.

Oracle University and Datum, S.A. De C.V. use only


e. Double-click ShoppingCart1.
f. In the Bind Variables dialog box, click Cancel, because the init() method already
assigned the value to the bind variable.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 22
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

g. One record should be returned by the query: the status CART order for DRAPHEAL.

Oracle University and Datum, S.A. De C.V. use only


h. Close the Browser window.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7


Chapter 7 - Page 23
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 7


Chapter 7 - Page 24
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 8


Chapter 8 - Page 1
Chapter 8

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 8

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 8


Chapter 8 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 8: Validating User Input


Practices Overview
In this practice, you add several types of both declarative and programmatic validation to entity
objects.
If you have successfully completed all sections of the previous practice, including the optional
steps, you can continue working in the same project. However, if you prefer to start with a clean
application that contains everything completed up to the start of this lesson, open
Storefront-08.jws and edit the database information as described in step 4 of Practice 2-4.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 8-1: Adding Declarative Validation: List Validator


In this practice, you define a List validator for the status code of an order.
1. Add validation to the OrderStatusCode attribute of the OrderEO entity object to ensure
that the value entered is valid. Display a meaningful error message to the user when
validation fails, using the resource bundle.
Hint: Use the LOOKUP_CODES table.
a. In the Application Navigator, in the oracle.fod.storefront.entity package, right-click
the OrderEO entity object and select Open OrderEO from the context menu.
b. In the Entity Object Editor, select the Attributes node, and then select the
OrderStatusCode attribute.
c. You can invoke the Add Validation Rule dialog box either from the Attribute Editor, or

Oracle University and Datum, S.A. De C.V. use only


with the attribute selected, from the Validation Rules accordion of the Entity Object
Editor. Invoke the Add Validation Rule dialog box in one of the following ways:
1) With the OrderStatusCode attribute selected, click Edit. Then in the Attribute
Editor, select Validation in the tree at the left, and then click New.

2) Alternatively, after selecting the OrderStatusCode attribute in the Entity Object


Editor, in the Validation Rules accordion of the editor, click Add Validation Rule.

d. In the Add Validation Rule dialog box:


1) Select List in the Rule Type drop-down list.
2) Leave the Operator at its default value of In.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3) Select Query Result from the List Type drop-down list.


Note: This is not the recommended way to define list validation. It is preferable to
use a view accessor attribute for this type of lookup.
4) In the Enter SQL statement field, enter the following query:
select distinct lookup_code from lookup_codes
where lookup_type = 'ORDER_STATUS_CODE'
5) Click Test to test the query. A message should inform you that the query is valid.
Click OK to close the validation message.

Oracle University and Datum, S.A. De C.V. use only


e. On the Failure Handling tab, check whether the Validation Failure Severity option
button is set to Error, and then, to define a translatable string in a resource bundle,
click in the Message Text section. If you do not choose to do so, in the interest of
time, you can simply enter the text rather than clicking to define a text resource. If
you choose this option, enter You have entered an invalid value in the
Message Text field and skip step (f) below.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


f. If you choose to define a text resource, simply click this option . In the Select Text
Resource dialog box:
1) In the Display Value field, enter: You have entered an invalid value
2) In the Key field, enter: INVALID_VALUE
3) In the Description field, enter: Error message for invalid value
4) Click Save and Select.

g. Click OK to save your validation definition, and then click OK to close the Attribute
Editor if you used it to invoke the Add Validation Rule dialog box.
2. Save your work. You will test this validation after all validations are defined.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 8 -2: Adding Declarative Validation: Unique Key Validator


In this practice, you add validation to the OrderEO entity to ensure that a duplicate value is not
entered for the primary key.
1. Add a Unique Key validator for OrderEO. Display a meaningful error message to the user
when validation fails.
a. In the Entity Object Editor for the OrderEO entity, select the Business Rules node.
b. In the Business Rules section, select Entity Validators, and then click Create new
validator to add a new rule. (Note that this is another way to define attribute
validation if you expand the Attributes node and select an attribute.)

Oracle University and Datum, S.A. De C.V. use only


c. In the Add Validation Rule dialog box:
1) Select UniqueKey from the Rule Type drop-down list.
2) Select OrdersPk(ORDER_ID) in the Keys list.

3) On the Failure Handling tab:


a) Check whether the Validation Failure Severity option is set to Error.
b) As you did previously, using the icon, you can add, save, and use the
message You have entered a duplicate ID, using a Key of
DUPLICATE_ID and a Description of Error message for unique key
validation (alternatively, simply enter the hard-coded Message Text).

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


4) Click OK to save your validation definition. You should see the new validation rule
in the Validation Rules section of the OrderEO editor.

2. Save your work. You will test this validation after all validations are defined.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 8-3: Adding Programmatic Validation: Method Validator


In this practice, you add a programmatic validation method for the OrderShippedDate
attribute of the OrderEO entity.
1. Add a Method validator to verify that the shipping date of an order is not prior to the order
date, and display a meaningful error message when validation fails. You can use the
following code: (You can copy the code from the ShippedDateAfterOrderDate.txt
file in the \files subdirectory of your \labs directory.)
public boolean validateShippedDateAfterOrderDate(Date
ordershippeddate) {
return ordershippeddate == null ||

Oracle University and Datum, S.A. De C.V. use only


ordershippeddate.dateValue().compareTo
(getOrderDate().dateValue()) >= 0;
}
a. In the editor for the OrderEO entity, select the Attributes node, and then select the
OrderShippedDate attribute.
b. Invoke the Add Validation Rule dialog box as you did previously for the
OrderStatusCode attribute.

c. In the Add Validation Rule dialog box:


1) Select Method in the Rule Type drop-down list.
2) Ensure that the Create and Select Method check box is selected.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3) For Method Name, enter the value validateShippedDateAfterOrderDate

Oracle University and Datum, S.A. De C.V. use only


d. On the Failure Handling tab:
1) Check whether the Validation Failure Severity option button is set to Informational
Warning.
2) As before, add, save, and use the message Order shipped date must not
be prior to order date, using a Key of SHIP_DATE_TOO_SOON and a
Description of Warning message for validation of shipping date.
Click Save and Select. Alternatively, you can just enter the message in the
Message Text field.

e. Click OK to save your validation definition. (Click OK again to dismiss the Attribute
Editor if you used it to invoke the Add Validation Rule dialog box.)
f. In the Application Navigator, expand the OrderEO node and double-click
OrderEOImpl.java to open it in the editor (by adding the Method validator, this file
would have been automatically generated if it did not already exist).
g. In the Structure window, double-click the validateShippedDateAfterOrderDate
method to locate it in the editor.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


h. Replace the method with the code specified in step 1.

i. Right-click and select Make.


j. Save your work. You will test this validation after all validations are defined.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 8-4: Creating and Using a Domain for Validation


In this practice, you create a domain for a short email address data type. You then apply that
domain as the data type for a customers email address.
1. Create a domain named PhoneNumber. It should be a string 12 characters in length with
the format xxx.xxx.xxxx.
a. In the Application Navigator, right-click the oracle.fod.storefront node and select New
Domain.
b. On the Name page of the Create Domain Wizard:
1) Set the package name to oracle.fod.storefront.domain.
2) Set the Name to PhoneNumber.

Oracle University and Datum, S.A. De C.V. use only


3) Ensure that the Domain for an Oracle Object Type check box is not selected.
4) Click Next.
c. On the Settings page of the wizard:
1) Select String from the Type drop-down list.
2) Click Next, and then click Finish.
d. In the Application Navigator, double-click PhoneNumber.java to open it in the editor. It
is located under the oracle.fod.storefront > domain > PhoneNumber node.

e. In the Structure window, double-click the validate():void node to navigate to that


method in the code.
f. After the commented line in the validate() method, add the following custom
domain validation logic: (You can copy the code from the PhoneNumber.txt file in
the \files subdirectory of your \labs directory.)
int dot1pos = mData.indexOf('.');
int dot2pos = mData.lastIndexOf('.');
int ln = mData.length();
if (dot1pos != 3 || dot2pos != 7 || ln != 12) {
throw new DataCreationException(null,
"Invalid phone number - format is xxx.xxx.xxxx",null);
}

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Press Alt + Enter when prompted to accept the import of


oracle.jbo.domain.DataCreationException.
g. Right-click and select Make.

Oracle University and Datum, S.A. De C.V. use only


h. Save your work.
2. Apply the domain to the PhoneNumber attribute of SupplierEO.
a. Open SupplierEO in the editor.
b. Click the Attributes tab.
c. Select the PhoneNumber attribute and click Edit (or simply double-click the attribute).
d. In the Edit Attribute dialog box:
1) Select Entity Attribute in the list at the left.
2) From the Type drop-down list, select
oracle.fod.storefront.domain.common.PhoneNumber.

3) Click OK.
3. Save your work.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 8-5: Testing the Validation


In this practice, you test all the validation that you have defined.
1. Run FODShoppingCartAM and test the List validator that you defined for the OrderEO
entity object. Be sure to initialize the cart first to bring up the status CART record for
DRAPHEAL.
a. In the Application Navigator, right-click FODShoppingCartAM and select Run.
b. If necessary, click Connect to establish the connection.
c. When the Business Components Browser appears, double-click the
FODShoppingCartAM node, select init from the Method drop-down list, and click
Execute to execute the init method.
d. Double-click ShoppingCart1 and in the Bind Variables dialog box, click Cancel to

Oracle University and Datum, S.A. De C.V. use only


leave the bind variable at the value that was set by the init() method.
e. Change the OrderStatusCode to XXXX and tab out of the field. You should receive the
error message that you defined.
Note: If you defined the validation error message by entering hard-coded text, the error
message text looks the same, but the JBO error is a rather cryptic generated key
instead of INVALID_VALUE.

f. Click OK to acknowledge the error.


g. Change the OrderStatusCode back to its original value (CART) so that you can
navigate out of the field.
2. While still in FODShoppingCartAM, test the Unique Key validator that you defined for the
OrderEO entity object.
a. Make note of the current value of the OrderId field.
b. Change the OrderId to a value that already exists, such as 1001, 1002, or 1003.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. Tab out of the field. You should receive the error message that you defined.

Oracle University and Datum, S.A. De C.V. use only


d. Click OK to acknowledge the error.
e. Change the OrderId back to its original value so that you can navigate out of the field.
3. While still in FODShoppingCartAM, test the Method validator that you defined for the
OrderEO entity object.
a. Enter a value in Order Shipped Date that is later than the value in Order Date. You
should be able to tab out of the field with no error.

b. Enter the same value in Order Shipped Date that is in Order Date. You should be able
to tab out of the field with no error.

c. Enter a value in Order Shipped Date that is earlier than the value in Order Date. You
should receive the warning message that you defined. (The JBO key is different if you
entered hard-coded message text rather than defining a text resource.)

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

d. Click OK to acknowledge the message. You should notice that navigation to the next
field was successful, because you defined failure handling to be an informational
warning rather than an error.
e. Close the Business Components Browser.
4. Run TestAM to test the domain that you defined and applied to the SupplierEO entity
object.
a. In the Application Navigator, right-click TestAM and select Run.
b. If necessary, click Connect to establish the connection.
c. When the Business Components Browser appears, double-click the Supplier1 node.
d. Navigate to a supplier with a phone number. Change the phone number in various
ways, such as by deleting the dots (.) or by making the phone number longer. Each

Oracle University and Datum, S.A. De C.V. use only


time that the phone number does not conform to the format xxx.xxx.xxxx, you
should not be able to tab out of the field. Doing so should result in receiving the error
message that you defined.

e. Close the Business Components Browser when you have finished.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8


Chapter 8 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 9


Chapter 9 - Page 1
Chapter 9

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 9

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 9


Chapter 9 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 9: Troubleshooting ADF BC Applications


Practices Overview
Most of the techniques for troubleshooting are used mainly for debugging a user interface.
However, you can run the JDeveloper Debugger with the Business Components Browser, which
enables you to troubleshoot problems with your ADF BC model apart from running a Fusion
Web application. In the practices for this lesson, you debug a client method in an application
module, and you explore the features of the JDeveloper Debugger.
Note: This practice is optional, and does not affect subsequent practices. Do this practice only if
you have extra time.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 9-1: Discovering Application Problems


In this practice, you test the Storefront application and discover a problem at run time.
1. Open the StorefrontDebug application from the StorefrontDebug folder. As you have
been doing, run the FODShoppingCartAM application module and initialize the shopping
cart, and then display the shopping cart.
a. From the JDeveloper application menu, select Open Application.

Oracle University and Datum, S.A. De C.V. use only


b. Navigate to the StorefrontDebug folder and open the StorefrontDebug application.
This application is identical to the one you have been working on, except that an error
has been introduced.
c. If prompted to migrate the application, perform the migration steps.
d. Modify the connection to point to your schema and edit the database information as
described in step 4 of Practice 2-4.
e. In the oracle.fod.storefront.module package, run FODShoppingCartAM.
f. Initialize the shopping cart:
1) In the Business Components Browser, double-click FODShoppingCartAM.
2) Select init from the Method drop-down list.
3) Click Execute to execute the init method.
g. Display the shopping cart:
1) Double-click ShoppingCart1.
2) In the Bind Variables dialog box, click Cancel so that the value that was set by
the init() method is used.
3) The cart does not display a users order, as expected, but instead displays a blank
(except for default values) new record.
h. Close the Business Components Browser.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 9-2: Setting Breakpoints in the Debugger


You know that there is a record in the shopping cart, but it did not appear in the Business
Components Browser. Now that you have discovered a run-time problem, in this practice, you
prepare to use the JDeveloper Debugger.
1. You know that the init() method of the FODShoppingCartAM application module sets
up the shopping cart. Set a source breakpoint in that method.
a. In the Application Navigator, select FODShoppingCartAMImpl.java.
b. In the Structure window, right-click init():void and select Go to Source.

Oracle University and Datum, S.A. De C.V. use only


c. To set a breakpoint, click in the left margin of the code editor next to the first line of
executable code in the init() method.

2. You know that the value of the mCurrentUser variable in


BaseApplicationModuleImpl.java receives the value of the current user of the application.
Set a watchpoint breakpoint for when this value changes.
a. In the Application Navigator, in the oracle.fod.storefront.module package, select
BaseApplicationModuleImpl.java.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. In the Structure window, click the Show Fields button, and then right-click
mCurrentUser:String and select Create Watchpoint.

Oracle University and Datum, S.A. De C.V. use only


3. View all the breakpoints that are set on the application.
a. From the JDeveloper main menu, select View > Breakpoints (or use the shortcut key
combination Ctrl + Shift +R).

b. The Breakpoints window shows the breakpoints that you have set, in addition to those
persistent breakpoints that are set by default.

c. Right-click the Breakpoints window to see the options that are available in the context
menu (but do not make any changes).

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 9-3: Running the Application Module in Debug Mode


Now that you have some breakpoints, in this practice, you run the application in debug mode
and use some of the features of the JDeveloper Debugger.
1. Run FODShoppingCartAM in debug mode.
a. In the Application Navigator, right-click FODShoppingCartAM and select Debug.

Oracle University and Datum, S.A. De C.V. use only


b. Before the Business Components Browser appears, the debugger is invoked in the
JDeveloper IDE. Examine the information in the IDE.
1) BaseApplicationModuleImpl.java is shown in the editor with a watchpoint icon
and a pointer displayed to the left of the line setting mCurrentUser to null. This
is because the application has hit the watchpoint breakpoint that you set on this
variable.

2) If the Stack window is not visible, from the JDeveloper main menu, select View >
Debugger > Stack. You can see in the Stack window that the
BaseApplicationModuleImpl class is in the process of being initialized, and
that it was called by the initialization of FODShoppingCartAMImpl.

c. Step through the code and use the debugger features to figure out the problem.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

1) Click Step Into on the JDeveloper toolbar. You can see the pointer move to the
next executable line of code in the editor window.
2) In the Data, expand the this node. Note that the value of mCurrentUser is null.
Also, mCurrentUser appears as its own in the SmartData. You want to keep
track of the value of this variable, so right-click it in the Smart Data or in the Data
panel and select Watch. This adds the variable to a watch list where you can keep
track of various values all in one place.

Oracle University and Datum, S.A. De C.V. use only


3) Click Resume on the toolbar to continue the execution until the next time a
breakpoint is encountered. No breakpoint is encountered, so the Business
Components Browser appears.
4) Now set up the shopping cart as you have done before by executing the init()
methoddouble-click FODShoppingCartAM in the browser, select the init()
method from the Method drop-down list, and then click Execute. The control
passes to the debugger again, so click back within the JDeveloper window to
continue the actions.
5) FODShoppingCartImpl.java is shown in the editor with a source breakpoint icon
and a pointer displayed to the left of the line in the init() method where you set
the breakpoint.

6) If you step into the code at this point, you would need to have the ADF source
because ADF source classes are called in the next lines. Because you do not have
the source, click Step Over to advance to the next line of code in this class
everything still executes, but you just do not step into the called classes. Note: Be
sure to click Step Over and not Step To End of Method, whose icon looks similar.
7) Click Step Over again to advance to the line of code that assigns a value to the
user variable. This assignment calls the getUserPrincipalName() method of
the application module base class, which is overridden in
BaseApplicationModuleImpl.java.
8) You are interested in two variable values: user and mCurrentUser. Click the
Smart Data tab. (If it is not available, use the View > Debugger menu to invoke
it.)

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

9) On the Smart Data tab, collapse all nodes, and then right-click user and select
Watch.

Oracle University and Datum, S.A. De C.V. use only


The Watches tab now shows both the this.mCurrentUser and user variables
so that you can easily track their values.
10) Click Step Into to step into the getUserPrincipalName() method in
BaseApplicationModuleImpl.java. Note that when you do so, on the
Watches tab the user variable has question marks for value and type because it
is out of scope.
11) Click Step Into again twice. The pointer should now be on the line that assigns
a value to mCurrentUser, but that line of code has not yet been executed. You
can see that the value of the variable userPrincipal is about to be assigned to
mCurrentUser.
12) Click the Smart Data tab and notice that the value of userPrincipal is
"DRAPHAEL"this username is misspelled.
13) In the Smart Data panel, right-click the userPrincipal variable and select
Modify Value.

14) In the Modify Value dialog box, change the value to DRAPHEAL, which is the
correct spelling for the username of the user whose shopping cart you want to
display, and then click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

15) Click Step Into (you

Oracle University and Datum, S.A. De C.V. use only


may have to click it twice). On the
Watches tab, you should see that
mCurrentUser now has the value
DRAPHEAL, the correct spelling.
16) Click Step Out to execute the remaining lines of code in this method and return
to the FODShoppingCartAMImpl class.
17) Click the Watches tab, and then click Step Into and then Step Over . You
should see the value DRAPHEAL being assigned to user.
18) Click Step Over four times until the pointer is at the line of code that sets the
named WHERE clause parameter. This should set the bind variable of the view
objects query to return only the cart order belonging to the user DRAPHEAL.
19) Click the Smart Data tab and expand vo.mViewRowSet, and then place
mWhereParams on your watch list.
20) Click Step Over twice, so that the VO query executes, and then in the Watch
panel, expand mWhereParams and [0]. You should see that the Current User
parameter has been set to DRAPHEAL.

21) Click Resume , and then in the Business Components Browser, double-click
ShoppingCart1. Click Cancel in the Bind Variables dialog box so that the value
set by the init method is used. You should see that the correct record appears
now.

You have seen some features of the debugger and how being able to view variable and
parameter values as the code runs can help you to figure out a coding problem. This
code was so simple that you probably could have easily figured it out just by looking at it,
but the debugger can be very useful for troubleshooting complex code. You were able to
change a value while code execution was paused, so that you could see the outcome.
Of course, you would also have to fix the code itself instead of just changing a variable
value in the debugger, but that is not part of this exercise.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9


Chapter 9 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 10


Chapter 10 - Page 1
Chapter 10

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 10

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 10


Chapter 10 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 10: Understanding UI Technologies


There is no practice for this lesson.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10


Chapter 10 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 10


Chapter 10 - Page 4
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 11


Chapter 11 - Page 1
Chapter 11

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 11

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 11


Chapter 11 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 11: Binding UI Components to Data


Practices Overview
In this set of practices, you create a databound JSF page. You then examine the data bindings
and manipulate the data binding files.
Even if you successfully completed all sections of previous practices, do not continue working
in the same project, because there was no time to create all the elements required for the UI.
You must open Storefront-11.jws and then edit the database information as described in
step 4 of Practice 2-4.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 11-1: Creating Databound Pages


In this practice, you create a product catalog page. It initially contains tables that display product
categories and subcategories for the products that the company sells. Note that a new project
StoreFrontUI now exists for the view part of the application.
1. Create a JSF page named Products.
a. With your StorefrontUI project selected in the Application Navigator, select File > New
to invoke the New Gallery. (Alternatively, you can right-click StorefrontUI and select
New from the context menu, or click New on the toolbar.)
b. In the Categories list, select Web Tier > JSF. Select JSF Page in the Items list and
click OK.
c. In the Create JSF Page dialog box:

Oracle University and Datum, S.A. De C.V. use only


1) Enter a file name of Products.
2) To the default Directory path, add \oracle\storefront\ui\pages.
3) Ensure that Create as XML Document (*.jspx) is selected, and then click OK.

2. After the designer initializes, the new blank page opens in the editor. Add to the page two
databound tables for product categories and subcategories as master-detail tables.
a. In the Data Controls panel, expand FODProductAMDataControl >
BrowseCategory1.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. Drag BrowseSubCategory1 to the page, selecting Master-Details > ADF Master


Table, Detail Table from the Create menu.

Oracle University and Datum, S.A. De C.V. use only


3. By default, all attributes of the view objects were added to the tables. You want to display
only the category name and description. Delete the ones that you do not want to display,
and set the master table to enable row selection.
a. To edit the master table, select the top table (BrowseCategory) in either the visual
editor or the Structure window and click Edit in the Property Inspector. (If the Property
Inspector is not visible, use the View menu to display it.)

b. Delete the columns that you do not want to display by selecting them and clicking
Delete , and you can use the arrows at the right of the Edit Table Columns dialog
box to reorder the columns. Set the column list to match the following:
CategoryName
CategoryDescription
Hint: When you select an attribute, it is best to select the first column, Display Label,
because that is the only column that does not invoke a pop-up list.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Note: Although this short list of attributes is easy to reorder, a quick way to reorder
attributes is to select the one that you want last in the list (in this case,
CategoryDescription), and then click the up arrow to move it to the top of the list.
Then working from the bottom up, repeat for each desired attribute (in this case,
CategoryName). Finally, select all the attributes below the desired attributes and delete
them.
c. Make sure that Row Selection is selected in the Enable ADF Behavior section at the
top of the window, and then click OK to apply the changes.

Oracle University and Datum, S.A. De C.V. use only


d. Select the second table (BrowseSubCategory1) in either the visual editor or the
Structure window and click Edit in the Property Inspector.
e. Set the column list to match the following (remove the extra columns and reorder as
needed):
CategoryName
CategoryDescription
f. Deselect the Row Selection check box and click OK. The page should now look
similar to the following screenshot, in which some of the extra white space has been
cut out:

4. Test the page.


a. If the Products.jspx page is not open, click its tab, or reopen it in the editor.
b. Right-click the page editor and select Run. The log window should display messages
relating to starting the server, and then the browser should display your page. This may
take a few minutes, but will be faster the next time that you run a page, because the
server is already started.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. Select one of the Categories and note that the SubCategories change to reflect the
selected row. Select another category and note the change. You may have to scroll
down to see the SubCategories.
The page should look similar to the following screenshot, in which some of the extra
white space has been cut out:

Oracle University and Datum, S.A. De C.V. use only


Note that the table does not fill the page. In the practice for the lesson titled Achieving
the Required Layout, you modify the layout so that the table fills the page.
d. Leave the browser window open to refer to in the next task.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 11-2: Examining the Pages Data Bindings


In this practice, you examine the data bindings that JDeveloper automatically created on the
page when you dragged a data control to the page.
1. Note the difference in the way the table columns appear in the JDeveloper editor and the
way they appear at run time.

Oracle University and Datum, S.A. De C.V. use only


For example, select the first column in the upper table in the JDeveloper editor, and then
look at the Property Inspector. What is the Header Text property set to?
__________________________________________________________________
__________________________________________________________________
Answer: #{bindings.BrowseCategory1.hints.CategoryName.label}
2. Select the CategoryName output text under the column header. What is its value?
__________________________________________________________________
__________________________________________________________________
Answer: #{row.CategoryName}
3. The reference to row is to a variable that is defined on the table.
Select the table in the Structure window, and then click the Source tab in the editor. How
is the row variable defined?
__________________________________________________________________
__________________________________________________________________
Answer:
var="row" value="#{bindings.BrowseCategory1.collectionModel}"
4. At run time, what appears in the browser for the first columns heading?
__________________________________________________________________
__________________________________________________________________
Answer: The column heading is Category Name.
5. In JDeveloper, in the StorefrontModel project, open the ProductCategoryEO entity object
and edit the CategoryName attribute. Where does the Category Name label in the UI
come from?
__________________________________________________________________
__________________________________________________________________

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Answer: Category Name comes from the entity object attributes control hints for
Label.
6. At run time, what appears in the browser for the first columns values? Where do these
values come from?
__________________________________________________________________
__________________________________________________________________
Answer: Office, Electronics, and Media are the category names in the rowset;
they are the input values for the category names in the rows.
7. In the Application Navigator, right-click the page and select Go to Page Definition. What is
the name of the page definition file? (You can also view data bindings by clicking the
Bindings tab of the page itself.)

Oracle University and Datum, S.A. De C.V. use only


__________________________________________________________________
Answer: ProductsPageDef.xml
8. In the Model section of the page definition file, trace the source of the BrowseCategory1
binding. Where does the data come from?
__________________________________________________________________
__________________________________________________________________
Answer: The data comes from the BrowseCategory1 view object instance in the
FODProductAMDataControl. The data is held in the entity object on which the
BrowseCategory view object is based, and the values ultimately come from the
database.
9. At the top of the page, click the link to the Data Binding Registry. What is the name of this
file?
__________________________________________________________________
__________________________________________________________________
Answer: DataBindings.cpx
10. When does this data binding registry file get created? Hint: The answer is right at the top of
the Overview page for the data binding registry file.
__________________________________________________________________
__________________________________________________________________
Answer: The file is created the first time that you bind a UI component to data in the
application.
11. What does the Page Mappings section of this file show?
__________________________________________________________________
__________________________________________________________________
Answer: It shows the mapping of pages to the IDs of their associated page definition
files.
12. What does the Page Definition Usages of this file show?
__________________________________________________________________
__________________________________________________________________
Answer: It shows the mapping of page definition file IDs to paths of their page definition
files.
13. What does the Data Control Usages section of this file show?
__________________________________________________________________

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

__________________________________________________________________
Answer: It shows the data controls that are used in the application.
14. Close the browser and the files that you have open in the JDeveloper editor. As you add
pages to the application, you can reexamine the data-binding registry to see how page
mappings, page definition usages, and data control usages are shown for the additional
pages.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 11-3: Adding an Additional Detail Table


In this practice, you add the Products table to the page as a detail of the
BrowseSubCategory table.
1. Add data controls to the Products.jspx page.
a. If the Products.jspx page is still open, click its tab, or reopen it in the editor.
b. In the Data Controls panel, expand FODProductAMDataControl > BrowseCategory1
> BrowseSubCategory1.
c. Drag the BrowseSubCategory1 > BrowseProduct1 data control to the af:form
node in the Structure window.

Oracle University and Datum, S.A. De C.V. use only


d. From the Create menu, select Table > ADF Read-only Table.
e. Do not enable Row Selection.
f. Include the following attributes in order, deleting the other attributes, and then click OK:
ProductName
Description
ListPrice

2. Run the page to test it. Now, when you run the page, the log window shows that the
application is undeployed and then redeployed to the default server.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

a. You should note that although the top two tables are coordinated with one another, the
products that appear in the bottom table are those of the first category/subcategory,
and the display of products does not change when different categories or
subcategories are selected. In the practice for the lesson titled Achieving the Required
Layout, you use partial page rendering to refresh the Products table so that it
coordinates with the record that is selected in the Subcategory table.
b. Close the browser when you have finished and undeploy the application as described
in step 6(i) of Practice 2-4.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 11-4: Renaming a Page


Although there is no facility for refactoring a page name in JDeveloper, you may sometimes
need to rename a page. In this task, you learn how renaming a page affects data binding and
what you must do to reestablish data binding on a renamed page.
1. Rename the Products page ProductCatalog.
a. Shut down JDeveloper, saving any unsaved work and terminating any running
processes if prompted.
b. Open Windows Explorer and navigate to your application directory.
c. In the StorefrontUI\public-html\oracle\storefront\ui\pages directory,
change the name of Products.jspx to ProductCatalog.jspx.

Oracle University and Datum, S.A. De C.V. use only


2. Test the ProductCatalog page.
a. Reopen JDeveloper, and then open the ProductCatalog.jspx page in the editor.
b. Run ProductCatalog.jspx.
c. The browser displays error messages, but does not display any data.

d. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
3. The Access Denied error that you received is indicative of a problem with data bindings.
Fix the problem without re-creating the tables on the page.
a. Click the Bindings tab in the editor of the ProductCatalog page to see that there are
no data bindings for the page.
b. In the Application Navigator, navigate to StorefrontUI > Application Sources >
oracle.storefront.ui and open DataBindings.cpx.
c. Map the existing page definition file to the renamed page: In the Page Mappings
section of DataBindings.cpx, edit the path. Change Products in the path to
ProductCatalog. You can do this by selecting the page mapping, and then editing
the path in the Property Inspector.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


d. Save your work.
4. Test the ProductCatalog page again.
a. Close and reopen ProductCatalog.jspx in the editor.
b. Click the Bindings tab. You should see data bindings, and the Page Definition File
should be listed as oracle/storefront/ui/pages/ProductsPageDef.xml.
c. Run the page. The data should now be displayed correctly.
d. Close the browser when finished, and undeploy the application as described in step
6(i) of Practice 2-4.
5. If you have time, as an optional exercise, rename the page definition file to match the
new name of the page.
a. Close JDeveloper, saving any unsaved work and terminating any running processes if
prompted.
b. In Windows Explorer, navigate to your application directory.
c. In the StorefrontUI\adfmsrc\oracle\storefront\ui\pages directory,
change the name of ProductsPageDef.xml to ProductCatalogPageDef.xml.

d. Reopen JDeveloper.
e. In the Application Navigator, navigate to StorefrontUI > Application Sources >
oracle.storefront.ui > pages and select ProductCatalogPageDef.xml.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

f. In the Structure window, right-click the ProductsPageDef node and select Refactor >
Rename.

g. In the Rename dialog box, change ProductsPageDef to

Oracle University and Datum, S.A. De C.V. use only


ProductCatalogPageDef.

This changes the ID of the page definition. Alternatively, you could change the ID in the
Property Inspector.
h. In the Application Navigator, navigate to StorefrontUI > Application Sources >
oracle.storefront.ui and open DataBindings.cpx.
i. Map the renamed page definition file to the path of the existing page: In the Page
Definition Usages section of DataBindings.cpx, select the path, and then in the
Property Inspector, change the value of the path from ProductsPageDef to
ProductCatalogPageDef.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

j. Save your work and then retest the page.


k. Although it is not necessary, if you also want to change the page mapping usageId and
the page definition usages ID, you must edit the XML file manually. This is because
JDeveloper reports an error and will not allow you to declaratively change one of these
values because that would result in an invalid XML document. To change manually:
1) Click the Source tab of the Databindings.cpx editor.
2) In the <pageMap><page> section, change usageId to
oracle_storefront_ui_ProductCatalogPageDef. The usageId is now
underlined with a red squiggly line indicating an error, because it does not match
the other ID value.

Oracle University and Datum, S.A. De C.V. use only


3) In the <pageDefinitionUsages><page> section, change the id to be the same as
the usageId in the previous section. The red squiggly line should disappear.

4) If desired, retest the page.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11


Chapter 11 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 12


Chapter 12 - Page 1
Chapter 12

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 12

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 12


Chapter 12 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 12: Planning the User Interface


Practices Overview
You could continue developing pages, but it is usually helpful to plan out the application before
creating all the pages. This enables you to visualize the flow of the application and create a
blueprint for it. You can do this in JDeveloper by creating task flows.
In the practices for this lesson, you create both unbounded and bounded task flows, along with
various types of activities and control flows for each. You also extract part of an unbounded task
flow into its own flow, and convert an unbounded task flow to a bounded one.
If you successfully completed all sections of the previous practice, you can continue working in
the same project. However, if you prefer to start with a clean application that contains everything

Oracle University and Datum, S.A. De C.V. use only


completed up to the start of this lesson, open Storefront-12.jws and edit the database
information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the
next lesson by opening the starter application for that lesson.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 12-1: Creating an Unbounded Task Flow


In this practice, you create activities and control flows in an unbounded task flow. The
application that you are developing is for a storefront, where the main activity is shopping. Users
can peruse a product catalog and add products to their shopping cart. They can then check out
to complete the order.
1. You have already started developing the ProductCatalog page. To begin planning the
rest of the application, add the ProductCatalog page to the applications unbounded task
flow.
a. Open the unbounded adfc-config.xml task flow. For convenience, JDeveloper
displays a node for this task flow in two places in the Application Navigator. Expand
StorefrontUI and WebContent. You can then open adfc-config.xml from the

Oracle University and Datum, S.A. De C.V. use only


node located under WEB-INF or the one located under Page Flows.

b. Drag ProductCatalog.jspx from the Application Navigator to the task flow that is open
in the editor.

This creates a view activity in the unbounded task flow.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. Select the view activity in the task flow editor and look at its Property Inspector. You
can see that it is linked to the ProductCatalog page that you created.

Oracle University and Datum, S.A. De C.V. use only


2. Create two additional view activities in the unbounded task flow named ProductSearch
and ProductDetails.
a. In the Component Palette, ensure that ADF Task Flow is selected in the drop-down list
at the top. Expand the Components category and drag a View activity to the editor.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. Change the name of the view activity to ProductSearch by entering the new name
either directly on the diagram or in the Property Inspector.

Oracle University and Datum, S.A. De C.V. use only


c. Similarly, add another view activity named ProductDetails.

Note the yellow warning symbol on the view activities that you just created. This
means that they do not yet point to pages.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3. Add a Control Flow Case from ProductSearch to ProductDetails and name it detail.
a. Click Control Flow Case in the Component Palette.
b. Click inside ProductSearch, and then click inside ProductDetails.

Oracle University and Datum, S.A. De C.V. use only


c. Enter detail as the name of the case. You can enter directly on the diagram, or it
may be easier to use the Property Inspector and enter the name as the from-
outcome of the control flow case.

4. In the same way, add a Control Flow Case from ProductDetails to ProductSearch and
name it search.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

5. Add a Control Flow Case from ProductCatalog to ProductSearch and name it search.

6. You can move the view activities to make the diagram look better. For example, you can
arrange the view activities as shown:

Oracle University and Datum, S.A. De C.V. use only


7. Add a control flow case named detail from ProductCatalog to ProductDetails.
8. Add a control flow case named shop from ProductDetails to ProductCatalog.

9. Create a fourth View activity named ProductCategory. The page is to display a category
tree for user navigation.
10. Finally, create a View activity called FODShoppingDashboard. The page for this view
activity will be the main page of the application from which all parts of the application are
accessed.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 12


11. Save your work.

Chapter 12 - Page 9
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 12-2: Creating Bounded Task Flows


In this practice, you create bounded task flows for tasks that have defined entry points.
1. Create a bounded task flow for the shopping cart. Create the task flow in the
oracle\storefront\ui\flow subdirectory of Page Flows.
a. Select File > New to invoke the New Gallery.
b. In the Categories list, expand Web Tier and select JSF.
c. In the Items list, select ADF Task Flow and click OK.

Oracle University and Datum, S.A. De C.V. use only


d. In the Create Task Flow dialog box:
1) Set File Name to ShoppingCartFlow.
2) To the directory path, add \oracle\storefront\ui\flow. This is the path you
should use for all task flows.
3) Ensure that Create as Bounded Task Flow is selected.
4) Ensure that Create with Page Fragments is not selected.

5) Click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Note that the newly created task flow appears in the Application Navigator in two
places, both under WEB-INF and under Page Flows.

Oracle University and Datum, S.A. De C.V. use only


f. The Shopping Cart flow opens in the editor. Add a view activity and name it
ShoppingCart.

Note that the view activity is surrounded with a green halo. This indicates that it is the
default activity, or entry point, of the task flow. A bounded task flow must have one, and
only one, default activity. Only bounded task flows show default activities, because
unbounded task flows do not have a defined entry point.
g. Add a Task Flow Return and name it Shop.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

h. In the Property Inspector for the Shop task flow return activity, set the Outcome name
to shop. This means that when the task flow returns to the one that called it, it
navigates by using a control flow case whose from-outcome is named shop.

Oracle University and Datum, S.A. De C.V. use only


i. Add a Control Flow Case from ShoppingCart to the Shop task flow return activity
and name it too as shop.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

j. Similarly, add another task flow return activity called Checkout, with the outcome
name checkout.

Oracle University and Datum, S.A. De C.V. use only


k. Add a control flow case also named checkout from ShoppingCart to Checkout.

l. Save your work.


2. Optional step: (If you choose not to create these additional task flows, you must
begin the practices for the next lesson by opening the starter application.)
Similarly, create two additional bounded task flows, being sure to create them in the
\oracle\storefront\ui\flow subdirectory and not to use page fragments: (If in the
Application Navigator, you right-click the WEB-INF > oracle > storefront > ui > flow node,
and then select New; the New Gallery reflects the correct path in the Directory field.)
a. Create the ManageSupplierFlow with:
1) A view activity named SupplierUpdate that is the default activity

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) A task flow return activity named Save whose outcome is named done

Oracle University and Datum, S.A. De C.V. use only


3) A task flow return activity named Cancel whose outcome is also named done

4) A wildcard control flow rule

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

5) Control flow cases between the activities:


From To Name
SupplierUpdate Save save
Wildcard Cancel cancel

Oracle University and Datum, S.A. De C.V. use only


b. In the same way, create the ShowSuppliersFlow in the
\oracle\storefront\ui\flow subdirectory, with one view activity named
BrowseSuppliers.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 12-3: Extracting Part of a Task Flow


After further consideration, you realize that the product search, details, and catalog function
should be a separate bounded task flow with ProductCatalog as the entry point. In this practice,
you extract part of the unbounded task flow into a separate task bounded task flow.
1. From the unbounded task flow, extract ProductCatalog, ProductSearch, and
ProductDetails into a separate bounded task flow named ShoppingFlow.
a. Open the adfc-config.xml unbounded task flow.
1) In the Application Navigator, expand StorefrontUI and WebContent.
2) Expand either the WEB-INF or the PageFlows node.
3) Double-click adfc-config.xml to open it in the editor.

Oracle University and Datum, S.A. De C.V. use only


b. In the editor, drag a rectangle to encompass the ProductSearch, ProductDetails, and
ProductCatalog view activities, with their control flows.

c. Right-click one of the selected objects and select Extract Task Flow.

d. On the Extract Task Flow warning, click Yes to accept and proceed.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. In the Extract Bounded Task Flow dialog box, enter a file name of ShoppingFlow,
add \oracle\storefront\ui\flow to the directory path, and then click OK.

Oracle University and Datum, S.A. De C.V. use only


f. In the editor, arrange the ShoppingFlow activities in a visually pleasing manner, such
as shown below:

g. Right-click the ProductCatalog view activity and select Mark Activity > Default
Activity.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 17
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


The ProductCatalog activity is now surrounded with a green halo indicating that it is the
default activity, or entry point, for the task flow.
h. When you extract a bounded task flow, a task flow call activity is created on the task
flow from which the bounded task flow was extracted. (You may need to look for it in
the diagram, if not visible.) This is not needed, so you can delete it from the adfc-config
task flow.
1) Open or switch to adfc-config.xml.
2) In the visual editor, right-click the ShoppingFlow activity and select Delete, or you
can delete task-flow-call-ShoppingFlow in the Structure window.

i. Save your work.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12


Chapter 12 - Page 18
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 13


Chapter 13 - Page 1
Chapter 13

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 13

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 13


Chapter 13 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 13: Adding Functionality to Pages


Practices Overview
In the practices for this lesson, you begin to add functionality to pages by using ADF Faces
components. You create search and detail pages and another page that displays a hierarchical
tree of categories and subcategories. You also create several pages that display input
components as a list of values.
If you successfully completed all sections of the previous practice, including the optional steps,
you can continue working in the same project. However, if you prefer to start with a clean
application that contains everything completed up to the start of this lesson, open
Storefront-13.jws and edit the database information as described in step 4 of Practice 2-4.

Oracle University and Datum, S.A. De C.V. use only


This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the
next lesson by opening the starter application for that lesson.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 13-1: Creating a Table with Row Selection


In this practice, you create the Shopping Cart page. This page displays the items in a users cart
(those order items for the user whose status is CART).
1. Create the ShoppingCart page.
a. Open ShoppingCartFlow in the editor.
b. Double-click the ShoppingCart view activity.
c. In the Create JSF Page dialog box, ensure that Create as XML Document is selected,
so that the file that is created can be used as metadata. (This option should be
selected and disabled.)
d. Leave the file name as ShoppingCart.jspx.

Oracle University and Datum, S.A. De C.V. use only


e. To the Directory path, append \oracle\storefront\ui\pages, and then click OK.

2. Create a read-only table on the page to display the users cart, showing the product name,
list price, quantity, and line total of items that are ordered. Users should be able to use a
mouse to select a line item.
a. The ShoppingCart page opens in the editor. From the Data Controls panel, drag
FODShoppingCartAMDataControl > ShoppingCart1 > ShoppingCartItem1 to the
page as a Table > ADF Read-only table.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


b. Ensure that Row Selection is enabled.
c. Delete all but the following attributes and arrange them in order:
ProductName
ListPrice
Quantity
LineTotal

Note: Select and remove the other attributes by clicking Delete. You can reorder the
attributes by selecting an attribute and using the up and down arrows as required.
Hint: An easy way to reorder many attributes is to first select the last attribute that you
want in the display (in this case, LineTotal) and click the top arrow, which places the
attribute at the top of the list. Then select the next-to-last attribute (in this case
Quantity) and place it at the top of the list. Continue with all the attributes, from last to
first. Finally, select all the other attributes and delete them.
d. Click OK.
3. Test the page.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

a. Right-click the editor for the ShoppingCart page and select Run.
b. If necessary, in the Confirm Run JSF JSP dialog box, click Yes.

Oracle University and Datum, S.A. De C.V. use only


Note: You receive this message because you are running the page directly instead of
running it within the context of the bounded task flow. You do not need to use the ADF
Controller in this case because you are not using any control flows to test this single
page. In most cases, however, you should run pages from a task flow rather than
running them directly.
You also receive several compilation warnings: XML-24521: (Error) Element not
completed: 'view', because you have created several activities in task flows that have
not been completed, such as view activities without corresponding pages. You can
safely ignore these warnings.
c. The page runs, but does not show any data. ShoppingCart is tied to a specific user;
however, you have not yet told it what user.

d. Close the browser when you have finished and undeploy the application as described
in step 6(i) of Practice 2-4.
4. Add to the page an invocation of the application modules init() method that initializes
the application to show shopping cart data for a specific user. The method interrogates the
system user (a hard-coded name is used until security is implemented in a later practice)
and uses that name as the username for the shopping cart. Hint: This involves adding a
method action binding and an invoke action binding to the page definition.
a. Click the Bindings tab in the editor for the ShoppingCart page.
b. Add a Method Action binding to the init() method in the
FODShoppingCartAMDataControl:

1) In the Bindings section, click Add .

2) In the Insert Item dialog box, select methodAction and click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


3) In the Create Action Binding dialog box, select
FODShoppingCartAMDataControl, choose init() from the Operation drop-
down list, and then click OK.

c. Add an InvokeAction to the executables that runs init(). Name it invokeInit


and set the Refresh property to ifNeeded. Make sure that it is the first executable so
that it runs before the iterator.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

1) In the Executables section, click Add .

2) In the Insert Item dialog box, select invokeAction, and then click OK.

Oracle University and Datum, S.A. De C.V. use only


3) In the Insert invokeAction dialog box:
Enter an ID of invokeInit, select init from the Binds drop-down list, and click
OK.

4) In the Property Inspector, set Refresh to ifNeeded.

5) In the Executables panel, drag the invokeInit executable to the top position, so
that the init() method is invoked before the iterator.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

d. Save your work and run the page again to check that you can see items in the
shopping cart.
You should be able to select any row in the table, and the page should look similar to
the following:

e. Close your browser when you have finished and undeploy the application as described
in step 6(i) of Practice 2-4.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 13-2: Creating a Search Page


In this practice, you use a query component to create a search page, and you test its
functionality.
1. Create the ProductSearch page.
a. Open ShoppingFlow in the visual editor.
b. Double-click the ProductSearch view activity.
c. In the Create JSF Page dialog box, ensure that Create as XML Document is selected,
so that the file that is created can be used as metadata. (This option should be
selected and disabled.)
d. Leave the file name as ProductSearch.jspx.
e. To the Directory path, append \oracle\storefront\ui\pages, and then click OK.

Oracle University and Datum, S.A. De C.V. use only


2. Add a query component to the ProductSearch page to query for products. The search
results should appear in a table that shows product name, category name, list price, and
description. The user should be able to select a row.
a. The ProductSearch page opens in the editor. Drag FODProductAMDataControl >
BrowseProduct > Named Criteria > SearchByName to the page in the editor and
select Query > ADF Query Panel with Table from the context menu.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


b. In the Edit Table Columns dialog box:
1) Enable Row Selection.
2) Include only the following four attributes in this order:
ProductName
CategoryName
ListPrice
Description

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3) Click OK. The page should look similar to the following:

Oracle University and Datum, S.A. De C.V. use only


3. Test the functionality of the ProductSearch page.
a. Right-click the editor for the ProductSearch page and select Run. (Do not run the
page from the task flow because the default activity of the task flow does not yet have
the ability to navigate to the ProductSearch page.)
NOTE: Although this page is represented as a view activity on the bounded task flow
that is not the default activity, you can still run the page separately when you are not
running it from the task flow. It is the task flow that has a single entry point, not
individual pages.
b. The page runs and looks similar to the following:

Note that the table does not fill up the page. You must scroll to see all the columns.
You later improve the look of the table in the practice for the lesson titled Achieving the
Required Layout.
c. Experiment with the functionality of the page.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

1) Enter a percentage sign (%) in the ProductName field and click Search. All of the
products appear.

Oracle University and Datum, S.A. De C.V. use only


2) Resize columns in the table by dragging the lines between the column headers.
3) Reorder columns in the table by dragging column headers.

4) Click Advanced to enable more search options.


5) Select Contains from the operators drop-down list.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

6) Enter Pla in the ProductName search field and click Search. Note that the table
displays products that contain Pla.

Oracle University and Datum, S.A. De C.V. use only


7) Select Does not contain from the operators drop-down list and click Search.
Now the table displays only those products that do not contain the string Pla.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

8) Select Price from the Add Fields drop-down list.

Oracle University and Datum, S.A. De C.V. use only


9) For the Price criterion, select Greater than from the operators drop-down list,
enter a value of $1000 (ListPrice is formatted as currency), and then click Search.
Now the table displays only those products that do not contain the string Pla and
whose list price is more than $1000.

10) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 13-3: Creating a Read-Only Form


In this practice, you create the ProductDetails page. This page displays the details of the
product that the user selects on the ProductSearch page. Later, in the practices for the lesson
titled Implementing Navigation on Pages, you add a button to the ProductSearch page that
navigates to the ProductDetails page.
1. Create the ProductDetails page on the ShoppingFlow task flow.
a. Open ShoppingFlow from the Application Navigator if it is not already open.
b. Double-click the ProductDetails view activity, or right-click it and select Create Page.
c. Create a .jspx page in the directory where you are creating pages
\oracle\storefront\ui\pages.
2. Add a read-only form to the ProductDetails page to display details of the selected product,

Oracle University and Datum, S.A. De C.V. use only


including product name, category name, and list price.
a. Drag the Data Control FODProductAMDataControl > BrowseProduct to the visual
editor and select Form > ADF Read-only form from the context menu.

b. In the Edit Form Fields dialog box:


1) Include only the following fields in order:
ProductName
CategoryName
ListPrice
Note: Select and remove the other attributes by clicking the icon. The attributes can
be reordered by selecting an attribute and using the up and down arrows as required.
2) Do not include Submit Button or Navigation Controls.

3) Click OK. The page should look similar to the following:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3. Run the page to test it. Run it directly rather than from the task flow because you have not
added navigation yet. The page should look similar to the following, displaying only one
record, which may not be the same as the record shown:

Oracle University and Datum, S.A. De C.V. use only


4. When you have finished, close the browser and undeploy the application as described in
step 6(i) of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 17
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 13-4: Creating a Sortable Table


In this practice, you create the BrowseSuppliers page that enables users to sort the table on any
of its columns. This practice is optional because the steps are similar to what you have done
previously. If you choose not to create the BrowseSuppliers page, you must begin the practices
for the next lesson by opening the starter application.
1. Create the BrowseSuppliers page on ShowSuppliersFlow.
a. From the Application Navigator, open ShowSuppliersFlow.
b. Open the BrowseSuppliers page, being sure to create it in your
\oracle\storefront\ui\pages directory.
2. Create a read-only table on the page to list the suppliers, displaying the supplier ID, name,
status, phone number, and email address. The table should be sortable, and users should

Oracle University and Datum, S.A. De C.V. use only


be able to select a row.
a. From the Data Controls panel, drag to the page FODSupplierAMDataControl >
Supplier1 as a Table > ADF Read-only Table.

b. Use only the first five attributes.


c. Enable Row Selection and Sorting.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 18
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3. Test the page.


a. From either the page editor or the task flow, run the BrowseSuppliers page. It should
look similar to the following:

Oracle University and Datum, S.A. De C.V. use only


b. Test that you are able to sort columns and select rows.

c. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 19
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 13-5: Creating a Category Tree


In this practice, you create the ProductCategory page, and then create on it a tree that shows
product categories with their subcategories.
1. Create the ProductCategory page on the unbounded task flow.
a. Open adfc-config.xml from the Application Navigator.
b. You may have to scroll in the diagram to see the existing views, and then either
double-click the ProductCategory view, or right-click it and select Create Page.

Oracle University and Datum, S.A. De C.V. use only


c. Create a .jspx page in the directory where you are creating pages
(\oracle\storefront\ui\pages).
2. Add a tree to the ProductCategory page to display categories and subcategories.
a. From the Data Controls panel, drag to the page FODCategoryAMDataControl >
RootCategory1 as a Tree > ADF Tree.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 20
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. In the Edit Tree Binding dialog box, select SubCategory from the Add Rule drop-
down list.

Oracle University and Datum, S.A. De C.V. use only


c. Select the oracle.fod.storefront.uiview.RootCategoryVO(<SubCategory>) tree level
rule.
d. Shuttle CategoryName from the Available Attributes list to the Display Attributes list,
and remove CategoryDescription from the Display Attributes list.

e. Now, select the oracle.fod.storefront.uiview.BrowseSubCategoryVO tree-level rule.


Shuttle CategoryName from the Available Attributes list to the Display Attributes list,
and remove CategoryDescription from the Display Attributes list.

f. Click OK to create the binding.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 21
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Note: This shows up at run time as a hierarchical tree with nodes and subnodes
displaying category names and subcategory names. Note that both RootCategoryVO
and BrowseSubCategoryVO are based on the same entity object, ProductCategoryEO.
The queries are differently defined to select those with no parent category for
RootCategoryVO and all categories for BrowseSubCategory. The view link defined to
link the two view objects restricts the second view to display only those subcategories
whose parent category is the root category. This becomes clearer when you run the
page.
g. The page should look similar to the following:

Oracle University and Datum, S.A. De C.V. use only


3. Convert the output text to a command link.
a. On the ProductCategory page, select af:outputText in either the Structure window
or the visual editor. (You must keep expanding the af:tree node all the way to find
af:outputText.)
b. Right-click af:outputText and select Convert To.

c. In the Convert Output Text dialog box, select Link.


d. Click OK. You will get a Confirm Convert dialog box informing that the Value attribute
will be removed. Click OK to continue.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 22
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. In the Properties Inspector, set the Text to #{node}. (You can use Expression
Builder and select the expression from JSP Objects.)

4. Test the ProductCategory page.

Oracle University and Datum, S.A. De C.V. use only


a. Run the ProductCategory page from either the page editor or from the task flow. The
page should look similar to the following when you expand the category nodes:

b. Note that you can expand the nodes, but nothing happens when you click the links
other than that the tree is refreshed. You change this behavior in a later practice.
c. When finished, close the browser and undeploy the application as described in step
6(i) of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 23
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 13-6: Creating LOVs


In this practice, you create pages with input components that use lists of values. Input
components automatically use LOVs when the model specifies that an LOV be used for display
of an attribute.
1. In the data model, review how a list of values was defined for SupplierVO.
a. In the Application Navigator, expand the StorefrontModel project.
b. Expand Application Sources > oracle.fod.storefront > uiview.
c. Double-click SupplierVO to open it in the editor.
d. Click the Attributes tab.
e. Select the SupplierStatus attribute.

Oracle University and Datum, S.A. De C.V. use only


f. In the List of Values section in the lower portion of the editor, open the List of Values
node, and then select LOV_SupplierStatus and click Edit.

g. In the List of Values editor:


1) Click the Configuration tab, where you can see that SupplierStatus will be
selected from the available LookupCode rows in the LookupCodeVVO1 view
accessor, and that the LookupCode value will be returned to the SupplierStatus
attribute when the user selects a value from the list.
2) Click the UI Hints tab, where you can see that the attribute appears as a Choice
List containing the LookupCode and Description.
3) Click Cancel.
h. Open SupplierEO under the StorefrontModel > Application Sources >
oracle.fod.storefront > entity node.
i. Click the View Accessors tab.
j. Select LookupCodeVVO1, and then click Edit.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 24
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

k. You can see that the view accessor limits the view to those rows where the lookup type
is SUPPLIER_STATUS_CODE.

l. Click Cancel to close the window, and then close the EO and VO editors.
2. In the ManageSupplierFlow task flow, create the SupplierUpdate page, using an LOV for

Oracle University and Datum, S.A. De C.V. use only


the SupplierStatus attribute. Place this page in a \supplier subdirectory where you have
been creating pages (\oracle\storefront\ui\pages). The form needs to show only
one record.
a. Open the ManageSupplierFlow task flow from the Application Navigator if it is not
already open.
b. Create the SupplierUpdate page, placing it in a supplier subdirectory
\oracle\storefront\ui\pages\supplier.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 25
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. Drag the data control FODSupplierAMDataControl > Supplier1 to the page and
create an ADF Form.

Oracle University and Datum, S.A. De C.V. use only


d. Select only the following fields:
SupplierName
SupplierStatus
PhoneNumber
Email
Do not include Navigation Controls or a Submit Button.

Click OK. Note that the Component to Use field for the SupplierStatus attribute is
ADF Select One Choice; this is determined by the setting in the ADF BC model.
Although you can change the setting here, it is better to let the model determine the list
type.
The page should look something like the following:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 26
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Test the page by running it directly. The page should look similar to the following with
the list of values dropped down:

f. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 27
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 13-7: Setting Up the UI Project for Internationalization


So far all of the text in the user interface is bound to data in the ADF BC model. Soon you begin
to add text that you enter into the application yourself. To make sure that this text is translatable,
you store it in a resource bundle. In this practice, you set up the UI project to use a resource
bundle.
1. Set up the project to use a single Properties Bundle file per project.
a. Right-click the StorefrontUI project in the Application Navigator and select Project
Properties, or just double-click the node to open the Project Properties editor.
b. In the list at the left of the Project Properties editor, select Resource Bundle. Make
sure that the Resource Bundle Type property is set to Properties Bundle and select
the One Bundle Per Project option. If necessary, set the Default Project Bundle Name

Oracle University and Datum, S.A. De C.V. use only


to oracle.storefront.ui.StorefrontUIBundle.

c. Click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13


Chapter 13 - Page 28
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 14


Chapter 14 - Page 1
Chapter 14

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 14

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 14


Chapter 14 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 14: Implementing Navigation on Pages


Practices Overview
So far you have created several pages that are part of task flows, and you have created control
flows between them with outcomes that can be used for navigation. However, you have not
implemented navigation on the pages, so there is no mechanism for moving from one activity to
the next within task flows.
In this set of practices, you implement navigation on pages by creating buttons, links,
breadcrumbs, and a train.
If you successfully completed all sections of the previous practice, including the optional steps,
you can continue working in the same project. However, if you prefer to start with a clean

Oracle University and Datum, S.A. De C.V. use only


application that contains everything completed up to the start of this lesson, open
Storefront-14.jws and edit the database information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the
next lesson by opening the starter application for that lesson.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 14-1: Creating Buttons for Navigation


In this practice, you create buttons on pages and set the Action property of the buttons to
correspond to a from-outcome of a control flow rule in the task flow. Then when the user
clicks the button, the navigation takes place. You create labels for the buttons as translatable
strings in the Bundle rather than as hard-coded values.
1. The ManageSupplierFlow task flow has a global control flow rule whose from-outcome is
cancel. Add a Cancel button to the page in the task flow to implement this global rule.
Create the label for the button as a translatable string.
a. Open the ManageSupplierFlow task flow by double-clicking it in the Application
Navigator. (The task flows are located under the Web Content > Page Flows > oracle
> storefront > ui > flow node.)

Oracle University and Datum, S.A. De C.V. use only


b. Double-click the SupplierUpdate view activity to open the page in the editor.
c. In the Component Palette, ensure that ADF Faces is selected from the drop-down list,
and drag a Button to the page just inside the top of the form in the editor.
(You may find it easier to drag it to the Structure windowexpand af:form and drag
the button just above af:panelFormLayout.)

The page should look similar to the following:

d. To define text for the button label and store it in a resource bundle, in the Property
Inspector, click the arrow to the right of the Text property and select Select Text
Resource from the context menu.

(Alternatively, you can right-click the button in the editor or in the Structure window and
select Select Text Resource for > Text from the context menu.)
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. In the Select Text Resource dialog box:


1) Ensure that StorefrontUIBundle is the selected resource bundle.
2) Enter a Display Value of Cancel, which populates the Key value with CANCEL.
3) Enter a Description of Label for the Cancel button.
4) Click Save and Select.

Oracle University and Datum, S.A. De C.V. use only


f. The label of the button changes to Cancel.
Note: The label of the button may appear at design time as the EL expression
#{storefrontuiBundle.CANCEL}.

g. Select the button and in the Property Inspector, click the Action drop-down list and
select cancel.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

This ensures that the cancel control flow is executed when the user clicks the Cancel
button.
h. To enable users to cancel and leave the form without entering the required fields, set
the Immediate property to true on the Behavior panel of the Property Inspector.

Oracle University and Datum, S.A. De C.V. use only


2. Optional step: (If you choose not to create this button, you must begin the practices
for the next lesson by opening the starter application.)
The ManageSupplierFlow task flow has a control flow rule from SupplierUpdate to the Save
task flow return activity whose from-outcome is save. Follow a similar series of steps to
add a Save button just to the right of the Cancel button on the SupplierUpdate page to
implement this navigation. Create the label for the button as a new translatable string and
select the save action. Do not change the default value of the Immediate property for this
button.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3. Similarly, in the ShoppingFlow task flow, open the ProductCatalog page. Add a button
above the panelHeader component, and using the Text Resource, label it Search. Set the
Action to search.

Oracle University and Datum, S.A. De C.V. use only


4. Optional step: (If you choose not to create these buttons, you must begin the
practices for the next lesson by opening the starter application.)
Following a similar series of steps, add the following buttons for navigation, optionally using
a text resource for the label of each:
Task Flow Page Button Label Button
Action
ShoppingFlow ProductDetails Search (use the search
existing text resource)
ShoppingFlow ProductDetails Shop (create a text shop
resource entry)
ShoppingCartFlow ShoppingCart Shop (use the existing shop
text resource)
ShoppingCartFlow ShoppingCart Checkout (create a checkout
text resource entry)
Save your work.
5. Examine the resource bundle.
a. In the Application Navigator, expand StorefrontUI > Application Sources >
oracle.storefront.ui.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. Double-click StorefrontUIBundle.properties to open it in the editor.

c. The file should look similar to the following (not all of these entries are present if you
skipped any optional steps):

Oracle University and Datum, S.A. De C.V. use only


Note: Although subsequent practices specify the use of a resource bundle to
store translatable strings, in the interest of time, you may choose to just enter
the strings as hard-coded text.
d. Close all editor windows.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 14-2: Creating Links for Navigation


In many cases, you want the user to be able to click some text, such as a product number, to
navigate to another page. In this practice, you create links that implement navigation.
1. The ShoppingFlow task flow has a control flow rule from ProductSearch to
ProductDetails whose from-outcome is detail. You want users to be able to click
the ProductName on the ProductSearch page to drill down to the details about the
products. Convert the ProductName on the ProductSearch page to a link that implements
this navigation. Clicking the link should not select a row.
a. Open the ProductSearch page.
b. Turn off automatic row selection on the table:
1) Select af:table in the Structure window or in the breadcrumbs at the bottom of the

Oracle University and Datum, S.A. De C.V. use only


editor.
2) Click Edit on the Property Inspector.

3) In the Edit Table Columns dialog box, deselect the Row Selection check box, and
then click OK.
c. Change the ProductName to be a link that calls the ADF method that sets the row and
then navigates to the detail page:
1) In the Structure window, expand the first af:column under af:table.
2) Right-click af:outputText for ProductName in the Structure window and select
Surround With.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3) In the Surround With dialog box, select ADF Faces > Link and click OK.

Oracle University and Datum, S.A. De C.V. use only


4) In the Property Inspector, remove the value in the Text property of the
af:commandLink and set Action to detail.

d. If you run the page from the task flow at this point (see step f below for how to do that if
you want to try), the link navigates to the detail page but always displays details for the
first product. The reason for this behavior is that when you disabled row selection you
also disabled row concurrency. Add a method called setCurrentRowWithKey that
sets the row of the Product iterator to whatever the current row is on the page.
1) In the Data Controls panel, expand FODProductAMDataControl >
BrowseProduct > Operations.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) Drag the setCurrentRowWithKey operation to the af:commandLink in either


the Structure window or the editor, and select Bind Existing Link.

Oracle University and Datum, S.A. De C.V. use only


3) Click OK to close the Edit Action Binding dialog box.
4) In the Confirm Component Rebinding dialog box, select the Keep Current Value
check boxes for the text and action properties. Click OK.

e. The setCurrentRowWithKeyValue method uses an argument (ND or Named Data) to


tell it which row is current. The collection model for the table knows which row is
selected and maintains a property named rowKeyStr, which holds the key to the
current row. Use this as an argument to setCurrentRowWithKey, which in turn
resets the BrowseProductIterator to reflect the correct row:
1) Right-click anywhere on the ProductSearch page and select Go To Page
Definition, or click the Bindings tab of the page.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 11
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) In the Structure window, select bindings > setCurrentRowWithKey > rowKey.

3) In the Property Inspector, set the NDValue property to #{row.rowKeyStr}, and

Oracle University and Datum, S.A. De C.V. use only


then click in any other field to apply this value, or press Tab or Enter. (By
changing field focus, the IDE accepts the value that you entered.)

f. Test the links in the ShoppingFlow task flow.


1) In the ShoppingFlow task flow, right-click the ProductCatalog view activity and
select Run.
2) On the ProductCatalog page, click Search.
3) On the Search page, enter % in the ProductName field and click Search.
Experiment with using the link on the product name.

4) If you did not complete the optional steps of defining additional buttons, click the
Back button of your browser, otherwise perform the following actions:
a) On the detail page, click Search to return to the search page to try another
link.
b) On the ProductDetails page, click Shop to return to the ProductCatalog page.
5) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 12
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2. In the ShoppingFlow task flow, add a drill-down link from the ProductCatalog page to the
ProductDetails page.
a. Open the ProductCatalog page.
b. Select the af:outputText of ProductName in the bottom table.
c. Press Ctrl + C to copy the Value property #{row.ProductName}.

Oracle University and Datum, S.A. De C.V. use only


d. Right-click the af:outputText and select Convert To.
e. In the Convert Output Text dialog box, select ADF Faces > Link and click OK.

Click OK to confirm Convert.


f. Paste the copied value into the Text property of the commandLink.

3. Coordinating the ProductCatalog and ProductDetails pages is made more complex by the
fact that the two pages use different iterators. The ProductDetails page uses the top-level
BrowseProduct iterator, whereas the ProductCatalog page uses the BrowseProduct1
iterator that is a detail of BrowseCategory > BrowseSubCategory. Therefore, you must use
the setCurrentRowWithKeyValue() method from the BrowseProduct data control to
coordinate the pages.
a. In the Data Controls panel, expand FODProductAMDataControl > BrowseProduct >
Operations.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 13
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. Drag setCurrentRowWithKeyValue to the af:commandLink you just converted and


select Bind Existing Link.
Note: Ensure that you select setCurrentRowWithKeyValue, and not just
setCurrentRowWithKey.

Oracle University and Datum, S.A. De C.V. use only


c. In the Edit Action Binding dialog box, click OK.
d. In the Confirm Component Rebinding dialog box, select the text check box to retain its
value and click OK.

e. Select af:commandLink and set the Action property to detail.


4. The setCurrentRowWithKeyValue method uses an argument (ND or Named Data) to
tell it which row is current. The argument for setting the current row of Product is ProductId.

When you created the Product table for this page, you excluded the ProductId because you
do not want to display it. Because it was excluded, it is not in the page bindings. Before you
can use ProductId as an argument to the setCurrentRowWithKeyValue method, you
have to add it to the bindings. After you add it, you can set the NDValue property of
setCurrentRowWithKeyValue.
a. Go to the Overview tab of the ProductCatalog page definition, or to the Bindings tab
of the page.
b. In the Bindings section, select the BrowseProduct1 binding and click Edit.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 14
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

c. In the Attributes section of the Tree Binding Editor, shuttle the ProductId from the
Available Attributes to the Display Attributes, and then click OK.

Oracle University and Datum, S.A. De C.V. use only


Note: This adds the attribute to the bindings, but it does not add it to the table on the
page. It simply makes the attribute available to the page.
d. The setCurrentRowWithKeyValue method uses an argument (ND or Named Data)
to tell it which row is current. The argument for setting the current row of Product is
ProductId.
In the Structure window, select bindings > setCurrentRowWithKeyValue > rowKey
and set the NDValue property to #{row.ProductId}. Be sure to tab out of the field or
click in another field so that the value is saved.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 15
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Test the page by running it from the ShoppingFlow task flow. (Open the task flow,
right-click the default activity, and select Run.) Remember that the Products table is
not yet coordinated with the Categories and Subcategories tables, so just scroll to the
bottom table and try out the ProductName links.

Oracle University and Datum, S.A. De C.V. use only


f. Click Shop to return to the ProductCatalog page to try different links. (If you did not
define the Shop button in the optional steps, use the browsers Back button to return to
the ProductCatalog page.)
Note: If the Products table at the bottom shows no data, you can test the links after
you coordinate the Products table with the Subcategories table in a later practice.
g. When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.
5. On the ShowSuppliersFlow task flow, create a task flow call activity to invoke the
ManageSupplierFlow task flow, a control flow case named update from BrowseSuppliers
to ManageSupplierFlow, and a control flow case named done from ManageSupplierFlow to
BrowseSuppliers. You want users to be able to click the SupplierId to be able to update the
supplier. Convert the SupplierId on the BrowseSuppliers page to a link that implements this
navigation. You do not need to disable row selection for this table.
a. Open the ShowSuppliersFlow task flow.
b. From the Application Navigator, drag ManageSupplierFlow to the diagram to create a
task flow call activity.

c. Create a control flow case from BrowseSuppliers to ManageSupplierFlow and set its
from-outcome to update.
d. Create a control flow case from ManageSupplierFlow to BrowseSuppliers and set its
from-outcome to done. (It should default to done because that is the outcome of the
task flow return activities in ManageSupplierFlow.)

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 16
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Open the BrowseSuppliers page.


f. Change the SupplierId to be a link that navigates to the SupplierUpdate page:
1) In the Structure window, expand the first af:column under af:table.
2) Right-click af:outputText for SupplierId in the Structure window and select
Surround With.

Oracle University and Datum, S.A. De C.V. use only


3) In the Surround With dialog box, select ADF Faces > Link and click OK.
4) In the Property Inspector of the af:commandLink:
a) Remove the value in the Text property
b) Set the Action to update
5) On the Behavior tab, set the PartialSubmit property to true.
g. Test the page by running BrowseSuppliers from the ShowSuppliersFlow task flow.
When you click a link, you should navigate to the supplier update page.

However, the page does not yet commit any updates you may make for the selected
supplier; you implement that in a later practice.
h. When you have finished, close the browser and undeploy the application as described
in step 6i of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 17
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 14-3: Using Breadcrumbs


In this practice, you add breadcrumb navigation to the ProductCatalog page. This application
uses explicitly defined breadcrumbs, rather than those that are tied to the XML Menu Model. In
this exercise, you define the breadcrumbs component and one navigation item. Later, in the
practice for the lesson titled Passing Values Between UI Elements, you add dynamic
navigation items to this breadcrumbs component by using parameters.
1. Open the ProductCatalog page from the ShoppingFlow diagram.
2. Drag a Bread Crumbs component from the Component Palette to the Structure window,
just below the af:form component and above the af:commandButton. It should be the first
component in the form.

Oracle University and Datum, S.A. De C.V. use only


3. Drag three Navigation Items to the af:breadCrumbs component.
4. Select the first af:commandNavigationItem and use a resource bundle to change its
Text property to Store, or optionally, just enter the text.
5. You will not be able to test the navigation until after you add the dynamic breadcrumbs
functionality in a later practice. For now, just leave the other two navigation items as they
are.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 18
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 14-4: Defining a Sequence of Steps


Another way to implement navigation is to use a Train component to manage the navigation for
you. This is particularly useful when there is a set navigation path and order. This is the case
with the CheckoutFlow.
In this practice, you define the CheckoutFlow task flow. Because checking out at the end of a
shopping session is a series of steps, you implement this task flow as a train, and you add a
train component to the first page in the train. In the later practice for the lesson titled Ensuring
Reusability, you use a page template for the pages.
1. From the StorefrontUI project, invoke the New Gallery.
2. Select Web Tier > JSF > ADF Task Flow and click OK.
3. In the Create Task Flow dialog box:

Oracle University and Datum, S.A. De C.V. use only


a. Enter a File Name of CheckoutFlow.
b. To the Directory path, append \oracle\storefront\ui\flow.
c. Ensure that Create as Bounded Task Flow is selected.
d. Ensure that Create with Page Fragments is not selected.
e. Select the Create Train check box.

f. Click OK.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 19
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

4. Create the following three View Activities on CheckoutFlow, and note that because of the
train choice, JDeveloper creates a navigation path as you create the activities:
CheckoutShipping
CheckoutPayment
CheckoutConfirm

Oracle University and Datum, S.A. De C.V. use only


5. Add two task flow returns:
a. Name one task flow return SubmitOrder, and set the name of its outcome in the
Property Inspector to submit.

b. Name the other task flow return CancelOrder, and set the name of its outcome in the
Property Inspector to cancel.
c. Add a wildcard control flow rule.
d. Add two control flow cases:
1) One named submit from CheckoutConfirm to SubmitOrder
2) One named cancel from the wildcard to CancelOrder

6. Create the CheckoutShipping page:


a. Double-click the CheckoutShipping view activity to create the page. Ensure that you
create the page in the \oracle\storefront\ui\pages directory.
b. Add a form that displays the ShippingAddress information:
1) Drag FODCheckoutAMDataControl > ShoppingCart1 > ShippingAddress to
the page (or to af:form in the Structure window) as an ADF Form.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 20
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) Include the following attributes in order, deleting all other attributes:


Address1
Address2
City
StateProvince

Oracle University and Datum, S.A. De C.V. use only


PostalCode
CountryId
3) Do not include Navigation Controls or a Submit Button.
4) Click OK to create the form.
7. Run the page from the CheckoutFlow task flow. It has no data on it because the shopping
cart context has not been established. Also note that there is currently no means of
navigation. You fix these problems in the next steps.

When finished, close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.
8. Establish the context for the shopping cart by calling the init() method defined in the
FODCheckoutAMDataControl application module. Add a reference to the init()
method and execute the method as part of the page load process. This init() method
retrieves the current username (now hard coded, but when security is implemented will be
set programmatically), sets the value in a named WHERE clause, and then reexecutes the
query. The result is that the shopping cart is populated with data from the current user.
To use the init() method, you define a reference for it in the page definition file. Then
you add an invokeAction to the page definition executables. invokeAction executes
when the page is loaded.
a. Open the Page Definition for the CheckoutShipping page (right-click anywhere on
the page and select Go To Page Definition), or click the Bindings tab on the page.
b. Click the Add icon (green plus sign) on the Bindings pane.

c. In the Insert Item dialog box:


1) Select Generic Bindings from the drop-down list.
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 21
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2) Select methodAction.
3) Click OK.
d. In the Create Action Binding dialog box:
1) Select FODCheckoutAMDataControl. Note that the Operation defaults to
init(). This is because the init() method is the only method in the application
module.

Oracle University and Datum, S.A. De C.V. use only


2) Click OK.
e. Now that you have a reference to the init() method, you can add it to the
Executables list:
1) Click Add in the Executables section.
2) Select Generic Bindings > invokeAction and click OK.
3) In the Insert InvokeAction dialog box, set id to invokeInit, and set Binds to init,
and then click OK.

4) In the Property Inspector, set the Refresh property to ifNeeded.


Note: By setting the Refresh property to ifNeeded, the framework refreshes the
executable when it has not been refreshed to this point. For example, when you have
an accessor hierarchy in which a detail is listed first in the page definition, the master
could be refreshed twice (once for the detail and again for the master's iterator). Using
ifNeeded avoids duplicate refreshes.
5) Drag the invokeInit action so that it is first in the list of executables.

9. Add the ability to navigate to the next page by adding a Train component to the page. The
Train component shows the users relative position in the train. It has train stops (small
boxes) for each of the pages in the train. The current position is highlighted with a slightly
larger box. The Train component can also be used for navigation. The user can click the
previous or next train stop to navigate to that page.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 22
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

a. In the page editor for the CheckoutShipping page, drag a Train component from the
Component Palette just inside the top of the form.

b. In the Bind Train dialog box, click OK to accept the default trainModel to bind to.
10. Add a train button bar to the page. A train button bar displays Back and Next buttons to
navigate to the next or previous train stop.

Oracle University and Datum, S.A. De C.V. use only


a. Drag a Train Button Bar from the Component Palette to the Structure window just
after the af:train.
b. In the Bind trainButtonBar dialog box, click OK to accept the default trainModel to
bind to.
Note: Ensure that the train button bar appears in the Structure window between the
train and the panel form layout. The Structure window should look like this (if not, drag
components to rearrange them):

11. Add labels for the train stops: Shipping, Billing, and Confirmation. JDeveloper
currently does not provide a way to use a text resource from a resource bundle file, so you
can just enter the text directly.
a. Open the CheckoutFlow task flow.
b. In the Structure pane, expand the view CheckoutShipping node.
c. Right-click the Train Stop and select Insert inside train-stop > Display Name from
context.

d. In the Property Inspector, set the display-name to Shipping.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 23
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

e. Similarly, set the display-name for CheckoutPayment to Billing and for


CheckoutConfirm to Confirmation.
12. Optional step: You may choose to skip this test in the interest of time without
affecting subsequent practices.
Test the train functionality. To see all the train stops, all the train stop view activities must
be associated with pages, so you have to create the other pages. However, because you
are going to delete them after testing the train, for now just create a temporary page for
each with only an output text item on it. Do not add any data binding. You can just create
the pages in the default directory to separate them from the more permanent pages that are
in your \oracle\storefront\ui\pages directory.
a. Double-click each view activity in turn (CheckoutPayment and CheckoutConfirm)
and click OK to accept the defaults in the Create JSF Page dialog box.

Oracle University and Datum, S.A. De C.V. use only


b. When the page opens in the designer, drag an Output Text to the page.
c. In the Property Inspector, change the Value of the Output Text item to reflect the title of
the pageCheckout Payment or Checkout Confirm. You do not need to place
that text in the resource bundle because you do not use it on the permanent page that
you create later. You use this Output Text value only to be able to determine which
page appears at run time for the next step.
d. Run the CheckoutShipping page from the task flow to see the results. The navigation
train and button bar appear, with labels for each train stop. You can use either the
Billing link or the Next button to navigate to the payment page.

However, because you have added the train component and train button bar to only the
first page, you cannot navigate to the other pages from the payment page. You take
care of that problem when you create the real pages.
e. When finished, close the browser and undeploy the application as described in step
6(i) of Practice 2-4.
f. Delete the two temporary pages:
1) In the CheckoutFlow task flow, select the CheckoutPayment and
CheckoutConfirm view activities and delete the value in their page property.
2) In the Application Navigator, multiselect the CheckoutConfirm and
CheckoutPayment pages. Right-click and select Delete.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 24
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 14


Chapter 14 - Page 25
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 14-5: Simplifying and Enhancing a Task Flow


When defining navigation and task flows, you may have noticed that the ShoppingFlow has
several control flows with the same name whose target is the same activity. For example, there
are two control flows named detail that have a target of ProductDetails. In this practice,
you simplify the shopping task flow by defining a global control flow rule, and you also add calls
to other task flows.
1. Simplify the ShoppingFlow task flow by defining a global rule.
a. Open the ShoppingFlow task flow.
b. Drag a Wildcard Control Flow Rule from the Component Palette to the task flow.
c. Select one of the search control flow cases and in the Property Palette, change its
From Activity Id to the wildcard rule by selecting it from the drop-down list.

Oracle University and Datum, S.A. De C.V. use only


d. Delete the other search control flow rule. The diagram should now look similar to the
following screenshot:

e. Select one of the detail control flow rules and in the Property Palette, change its
from-activity-id to the wildcard rule by selecting it from the drop-down list.
f. Delete the other detail control flow rule. The diagram should now look similar to the
following screenshot:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 26
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Oracle University and Datum, S.A. De C.V. use only


g. Select the shop control flow rule and in the Property Palette, change its from-activity-
id to the wildcard rule by selecting it from the drop-down list.
h. Rearrange the items on the diagram to look similar to the following screenshot:

2. Add three task flow call activities to the ShoppingFlow:


To call the checkout flow
To display the shopping cart
To add an item to the cart
a. From the Application Navigator, drag CheckoutFlow to the ShoppingFlow task flow
diagram in the editor to create a task flow call activity.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 27
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. Drag a Control Flow Case from the wildcard to CheckoutFlow and name the
outcome checkout.
c. From the Application Navigator, drag the ShoppingCartFlow to the ShoppingFlow
task flow diagram in the editor to create a task flow call activity.
d. In the Property Inspector, change the Activity ID of the task flow call activity to
AddShoppingCart. Do not change the ID in the Task Flow Reference section.

Oracle University and Datum, S.A. De C.V. use only


e. Drag a Control Flow Case from the wildcard to AddShoppingCart and name the
outcome add.

f. From the Application Navigator, again drag ShoppingCartFlow to the ShoppingFlow


task flow diagram in the editor to create a task flow call activity.
g. In the Property Inspector, change the Activity ID of the task flow call activity to
DisplayShoppingCart. Do not change the ID in the Task Flow Reference section.
h. Drag a Control Flow Case from the wildcard to DisplayShoppingCart and name the
outcome cart.

You later add logic to the application so that there is a difference between displaying
the cart and adding an item to the cart.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 28
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

i. Open the ProductCatalog page and to the right of the Search button, add a button.
1) Using the resource bundle, set the text property to Show Cart.
2) Set the action to cart to navigate to the DisplayShoppingCart activity.

Oracle University and Datum, S.A. De C.V. use only


3) Test the navigation with the Show Cart button by running the ProductCatalog
page from the ShoppingFlow task flow.

4) The Cart content should display now:

5) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14


Chapter 14 - Page 29
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 14


Chapter 14 - Page 30
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 15


Chapter 15 - Page 1
Chapter 15

Copyright 2010, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 15

Oracle University and Datum, S.A. De C.V. use only


THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 15


Chapter 15 - Page 2
Copyright 2010, Oracle and/or its affiliates. All rights reserved.
Oracle University and Datum, S.A. De C.V. use only
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practices for Lesson 15: Achieving the Required Layout


Practices Overview
In the practices so far, you have chosen the default layout for all the components that you have
used. That is a quick way to check whether your application is working and that data and flow
are handled correctly. This has resulted in pages that are functional, but not very visually
appealing. In this set of practices, you use layout components and techniques to enhance the
appearance of the application, and you implement partial page rendering to coordinate products
with a selected subcategory.
If you successfully completed all sections of the previous practice, including the optional steps,
you can continue working in the same project. However, if you prefer to start with a clean

Oracle University and Datum, S.A. De C.V. use only


application that contains everything completed up to the start of this lesson, open
Storefront-15.jws and edit the database information as described in step 4 of Practice 2-4.
This practice contains some optional steps that are similar to steps already done. If you want to
build the entire application yourself, you can complete the optional steps. However, in the
interest of time, you may want to skip them. If you do so, you must begin the practices for the
next lesson by opening the starter application for that lesson.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 3
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 15-1: Stretching Tables and Columns


To enhance the appearance of tables in the application, it is a good practice to stretch them so
that they occupy the entire browser space. Tables and other components are automatically
stretched if they are contained in a stretched component that automatically stretches its children
(Panel Splitter, Panel Stretch, or Decorative Box layout components). Even so, there is no harm
in stretching the table itself to avoid display problems no matter which type of layout component
contains the table.
In this practice, you stretch all tables and the last column of each table.
1. Stretch the last columns of the following tables, and stretch the tables themselves:
Page Table

Oracle University and Datum, S.A. De C.V. use only


ProductCatalog masterDetail1 table
ProductCatalog Subcategories table
ProductCatalog Products table
ProductSearch (optional) Search results table
ShoppingCart (optional) Items table
BrowseSuppliers (optional) Suppliers table
a. In the Application Navigator, select the ProductCatalog page.
b. In the Structure window or in the editor, select the af:table masterDetail1
component.
c. In the Property Inspector, set the Appearance > Width to 100%. Tab out or click in any
other field to apply the new value. You can see the effects of table stretching in the
editor, as the table boundaries expand to fill the horizontal space in the editor.
d. Select last from the Column Stretching drop-down list.
You can see the effects of column stretching in the editor, as the last column expands
to fill up the space.

e. Apply the same type of stretching to the other two tables on the page: the one for
subcategories and the one for products. However, in the Products table (table2),
stretch the middle column (column3), because it is the one that contains a large
amount of text. To do so, follow these steps:
1) Select the middle column and give it the Id of Description.
2) Optional: (You may get errors when nondefault values of Id and TestId are not
identical. To avoid this possibility, reset the TestId to its default value.)
3) Select the table and set Column Stretching to column:Description.
f. Save your work.
g. Optional step: (If you choose not to complete this step, you must begin the
practices for the next lesson by opening the starter application.)
Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 4
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Similarly, stretch the table and the last column for all tables on the following pages:
ProductSearch (Search results table)
ShoppingCart (Items table)
BrowseSuppliers (Suppliers table)

Oracle University and Datum, S.A. De C.V. use only

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 5
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 15-2: Adjusting JDevelopers Default Layout Components


When you created certain components on your pages, JDeveloper imposed some default
layout. In this practice, you modify some of these default layout components to enhance the
appearance of the pages.
1. Modify headings in the Panel Group Layout components on the ProductCatalog page.
Change the headings to Categories and Subcategories.
a. Open the ProductCatalog page.
b. In the Structure window, expand jsp:root > f:view > af:document > af:form >
af:panelGroupLayout.
c. When you dragged the Categories and Subcategories to your page as master table
and detail table, JDeveloper created these tables in af:panelHeader components with

Oracle University and Datum, S.A. De C.V. use only


default headings. Change these headings to Categories and Subcategories.
1) In the Structure window, select af:panelHeader BrowseCategory1.

2) In the Property Inspector, change the Text property to Categories. Ensure that
you use a resource bundle.
3) Similarly, set the Text property for the af:panelHeader BrowseSubCategory1
to Subcategories.
2. On the ProductCatalog page, two of the tables and panel headers are grouped under an
af:panelGroupLayout component. Enable this component to display scroll bars when the
browser is too small to display all of its contents, and place the third table in the same panel
group layout.
a. In the Structure window, select af:panelGroupLayout.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 6
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

b. In the Property Inspector, select scroll from the Layout drop-down list.

Oracle University and Datum, S.A. De C.V. use only


c. Drag the Products table to the af:panelGroupLayout scroll component.

3. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, open ProductSearch page and set the default Panel Group Layout component
to scroll.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 7
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Practice 15-3: Adding Layout Components to Existing Pages


In this practice, you add layout to pages to enhance their appearance.
1. Add a Panel Header named Products to contain the Products table on the
ProductCatalog page.
a. Open the ProductCatalog page.
b. In the Structure window, expand jsp:root > f:view > af:document > af:form >
af:panelGroupLayout-scroll.
c. In the Structure window, right-click af:table and select Surround With.

Oracle University and Datum, S.A. De C.V. use only


d. In the Surround With dialog box, select ADF Faces > Panel Header and click OK.
e. In the Property Inspector for the panel header, set the Text property to Products,
optionally using a resource bundle.
f. Save your work.
2. On the ProductDetails page, place the Product form, which is contained by default in a
panel form layout, into a panel header titled Product Detail. Add a toolbar for the existing
buttons.
a. Open the ProductDetails page.
b. In the Structure window, expand jsp:root > f:view > af:document > af:form.
c. Right-click af:panelFormLayout and select Surround With.
d. In the Surround With dialog box, select ADF Faces > Panel Header and click OK.
e. In the Property Inspector for the panel header, set the Text property to Product
Detail, optionally using the resource bundle.
f. In the Structure window, expand af:panelHeader > Panel Header facets.

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 8
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

g. Drag a Toolbar from the Component Palette to the toolbar facet of the panel header, in
either the Structure window or in the editor.

Oracle University and Datum, S.A. De C.V. use only


h. Drag the existing Search and Shop buttons to the toolbar, in either the Structure
window or in the editor.

i. Save your work. When you have finished, the page should look similar to this

and the Structure window should look similar to this:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 9
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

3. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application.)
Similarly, on the SupplierUpdate page, put the Supplier form that is contained in a panel
form layout into a panel header. You do not need to change the heading.
Hint: The SupplierUpdate page is in the supplier subdirectory of the
\oracle\storefront\ui\pages directory.
a. Surround the Panel Form Layout with a Panel Header, but do not change the Text
(heading).
b. Add a Toolbar component and move the existing buttons to the toolbar facet of the
panel header.
c. For now, do not change the text of the panel header, because later you add a
conditional text display.

Oracle University and Datum, S.A. De C.V. use only


d. Using the Style property group and the Box tab, set the Width of the panel header to
500 pixels.

e. Save your work. When you have finished, the page should look like this

and the Structure window should look like this:

Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15


Chapter 15 - Page 10
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

4. Optional step: (If you choose not to complete this step, you must begin the practices
for the next lesson by opening the starter application:)