Вы находитесь на странице: 1из 416

Volume III Student Guide

D53979GC11
Edition 1.1
May 2009
D60501

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

Oracle University and Egabi Solutions use only

Oracle Fusion Middleware 11g:


Build Applications with ADF I

Authors

Copyright 2009, Oracle. All rights reserved.

Pam Gamer
Gary Williams

Disclaimer

Glenn Maslen
Ken Cooper
Joe Huang
Taj-ul Islam
Duncan Mills
Kenichi Mizuta
Frank Nimphius
Dan Pillay
Blaise Ribet
Oliver Steinmeier
Editors
Steve Elwood
Jothi Lakshmi
Raj Kumar
Aju Kumar
Publisher
Jayanthy Keshavamurthy

This course in any form, including its course labs and printed matter, contains
proprietary information that is the exclusive property of Oracle. This course and the
information contained herein may not be disclosed, copied, reproduced, or distributed
to anyone outside Oracle without prior written consent of Oracle. This course and its
contents are not part of your license agreement nor can they be incorporated into any
contractual agreement with Oracle or its subsidiaries or affiliates.
This course is for informational purposes only and is intended solely to assist you in
planning for the implementation and upgrade of the product features described. It is
not a commitment to deliver any material, code, or functionality, and should not be
relied upon in making purchasing decisions. The development, release, and timing of
any features or functionality described in this document remain at the sole discretion
of Oracle.
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 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 is a registered trademark of Oracle Corporation and/or its affiliates. Other
names may be trademarks of their respective owners.

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

Oracle University and Egabi Solutions use only

Technical Contributors
and Reviewers

This course provides an overview of features and enhancements planned in release


11g. It is intended solely to help you assess the business benefits of upgrading to 11g
and to plan your IT projects.

Contents

Course Introduction: Oracle Fusion Middleware 11g: Build Applications with


ADF I
Course Objectives I-2
Course Agenda: Day 1 I-3
Course Agenda: Day 2 I-4
Course Agenda: Day 3 I-5
Course Agenda: Day 4 I-6
Course Agenda: Day 5 I-7

Introduction to Oracle Fusion and Oracle ADF


Objectives 1-2
Examining Oracle Fusion Architecture 1-3
Oracle Application Development Framework (ADF) 1-4
The Model-View-Controller Design Pattern 1-5
Implementing MVC with the ADF Framework: Business and Data Services 1-6
Implementing MVC: ADF Model 1-7
Implementing MVC: Controllers 1-8
Implementing MVC: View 1-9
Technology Choices for ADF BC Applications 1-10
Introducing JDeveloper: Oracles Java and Web Development Tool 1-11
Obtaining Additional Information 1-12
Summary 1-13

Getting Started with JDeveloper


Objectives 2-2
Describing the Benefits of Using JDeveloper 2-3
Launching JDeveloper 2-5
Defining JDK and Role 2-6
Using JDeveloper Features 2-7
Using JDevelopers Application Navigator 2-8
Using JDevelopers Database Navigator 2-10
Using JDevelopers Editors 2-11
Using JDevelopers Component Palette 2-13
Using JDevelopers Resource Palette 2-14
Using JDevelopers Structure Window 2-15

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

Oracle University and Egabi Solutions use only

Preface

Building a Business Model with ADF Business Components


Objectives 3-2
Describing ADF Business Components (ADF BC) 3-3
ADF BC Implementation Architecture 3-4
Types of ADF Business Components 3-5
Creating ADF Business Components 3-6
The Create Business Components from Tables Wizard: Entity Objects 3-7
The Create Business Components from Tables Wizard: Updatable View
Objects 3-8
The Create Business Components from Tables Wizard: Read-Only View
Objects 3-9
The Create Business Components from Tables Wizard: Application Module 3-10
The Create Business Components from Tables Wizard: Diagram 3-11
Examining Created Objects 3-12
Testing the Data Model 3-13
Exposing the Application Module to the User Interface 3-14
Summary 2-31
Practice 3 Overview: Building a Business Model 3-16

Querying and Persisting Data


Objectives 4-2
Using View Objects 4-3
Characteristics of a View Object (VO) 4-4
Creating View Objects for Queries 4-5
Testing View Objects with the Business Components Browser 4-10
Characteristics of an Entity Object (EO) 4-11

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

Oracle University and Egabi Solutions use only

Using JDevelopers Property Inspector 2-16


Using JDevelopers Log Window 2-17
Working with JDeveloper Windows 2-18
Setting IDE Preferences 2-19
Getting Started in JDeveloper 2-20
Creating an Application in JDeveloper 2-21
Using the Application Overview 2-23
Creating a Project in JDeveloper 2-24
Creating Database Connections 2-26
Creating a Database Connection in JDeveloper 2-27
Describing the Course Application 2-29
Presenting the Storefront User Interface 2-30
Summary 2-31
Practice 2 Overview: Using JDeveloper 2-32

Exposing Data
Objectives 5-2
Oracle ADF Application Module (AM) 5-3
Characteristics of an Application Module 5-4
Creating an Application Module 5-5
Defining the Data Model for the Application Module 5-6
Using MasterDetail View Objects in Application Modules 5-7
Determining the Size of an Application Module 5-8
Business Components Transactions 5-9
Using Nested Application Modules 5-11
Application Module Pooling 5-12
Managing Application State 5-13
The Role of ADF Model 5-14
Describing the Course Application: Database Objects 5-15
Describing the Course Application: View Objects 5-16
Describing the Course Application: Data Controls 5-18

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

Oracle University and Egabi Solutions use only

Using Entity Objects to Persist Data 4-12


Creating Entity Objects 4-13
Creating Entity Objects from Tables, Views, or Synonyms 4-15
Synchronizing an Entity Object with Changes to Its Database Table 4-16
Generating Database Tables from Entity Objects 4-17
Characteristics of Associations 4-18
Creating Associations 4-19
Association Types 4-20
Characteristics of Updatable View Objects 4-21
Creating Updatable View Objects 4-22
Creating Updatable View Objects: Attributes and Settings 4-23
Creating Updatable View Objects: Query 4-25
Creating Updatable View Objects: Additional Settings 4-27
Interaction Between Views and Entities: Retrieving Data 4-28
Interaction Between Views and Entities: Updating Data 4-29
Creating a Join View Object 4-30
Including Reference Entities in Join View Objects 4-31
Creating MasterDetail Relationships with View Objects 4-32
Linking View Objects 4-33
Comparing Join View Queries with View Links 4-34
Refactoring Objects 4-35
Summary 4-36
Practice 4 Overview: Creating Entity Objects and View Objects 4-37

Declaratively Customizing Data Services


Objectives 6-2
Using Groovy 6-3
Using Groovy Syntax in ADF 6-4
Internationalizing the Data Model 6-6
Editing Business Components 6-7
Modifying the Default Behavior of Entity Objects 6-8
Defining Attribute Control Hints 6-10
Modifying the Default Behavior of Entity Objects 6-12
Synchronizing with Trigger-Assigned Values 6-13
Modifying the Default Behavior of Entity Objects 6-15
Using Alternate Key Entity Constraints 6-16
Creating Alternate Key Entity Constraints 6-17
Editing View Objects 6-19
Modifying the Default Behavior of View Objects 6-20
Defining View Object Control Hints 6-22
Modifying the Default Behavior of View Objects 6-24
Performing Calculations 6-25
Modifying the Default Behavior of View Objects 6-26
Restricting and Reordering the Columns Retrieved by a Query 6-27
Modifying the Default Behavior of View Objects 6-28
Changing the Order of Queried Rows 6-29
Modifying the Default Behavior of View Objects 6-30
Restricting the Rows Retrieved by a Query 6-31
Using View Criteria (Structured WHERE Clauses) 6-32
Using Parameterized WHERE Clauses 6-34
Using Named Bind Variables 6-35
Modifying the Default Behavior of View Objects 6-36
Retaining and Reusing a View Link Accessor Row Set 6-37
Modifying the Default Behavior of View Objects 6-38
Creating View Accessors 6-39
Using a List of Values (LOV) 6-40
Defining the View Accessor for the List of Values 6-41
Defining the List of Values 6-42
Modifying Application Modules 6-43
Changing the Locking Behavior of an Application Module 6-44
Summary 6-45
Practice 6 Overview: Declaratively Modifying Business Components 6-46

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

Oracle University and Egabi Solutions use only

Summary 5-19
Practice 5 Overview: Defining Application Modules 5-20

Programmatically Customizing Data Services


Objectives 7-2
Generating Java Classes for Adding Code 7-3
Programmatically Modifying the Default Behavior of Entity Objects 7-4
The Supporting Entity Java Classes 7-5
Traversing Associations 7-7
Overriding Base Class Methods 7-8
Overriding Base Class Methods Example: Updating a Deleted Flag
Instead of Deleting Rows 7-9
Overriding Base Class Methods Example: Eagerly Assigning Values
from a Database Sequence 7-10
Programmatically Modifying the Default Behavior of View Objects 7-11
The Supporting View Object Java Classes 7-12
Examining View Object Methods 7-13
Changing View Object WHERE or ORDER BY Clause at Run Time 7-16
Using Named Bind Variables at Run Time 7-18
Programmatically Retaining and Reusing a View Link Accessor Row Set 7-19
Traversing Links 7-20
Application Module Files 7-22
Centralizing Implementation Details 7-23
Adding Service Methods to an Application Module 7-25
Coding the Service Method 7-27
Publishing the Service Method 7-28
Testing Service Methods in the Business Components Browser 7-30
Accessing a Transaction 7-31
Committing Transactions 7-33
Customizing the Post Phase 7-34
Customizing the Commit Phase 7-35
Using Entity Objects and Associations Programmatically 7-36
Finding an Entity Object by Primary Key 7-37
Updating or Removing an Existing Entity Row 7-38
Creating a New Entity Row 7-39
Using Client APIs 7-41
Creating a Test Client 7-42
Using View Objects in Client Code 7-43
Using Query Results Programmatically 7-44
Using View Criteria Programmatically 7-45
Iterating MasterDetail Hierarchy 7-47
Finding a Row and Updating a Foreign Key Value 7-48
Creating a New Row 7-49

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

Oracle University and Egabi Solutions use only

Validating User Input


Objectives 8-2
Validation Options for ADF BC Applications 8-3
Triggering Validation Execution 8-4
Handling Validation Errors 8-5
Specifying the Severity of an Error Message 8-6
Using Groovy Variables in Error Messages 8-7
Storing Error Messages as Translatable Strings 8-8
Defining Validation in the Business Services 8-9
Using Declarative Validation: Built-in Rules 8-10
Defining Declarative Validation 8-11
Using Declarative Validation: Built-in Rules 8-12
Using Declarative Built-in Rules: Collection Validator 8-13
Using Declarative Built-in Rules: Unique Key Validator 8-14
Using Declarative Validation: Built-in Rules 8-15
Using Declarative Built-in Rules: Compare Validator 8-16
Using Declarative Built-in Rules: Key Exists Validator 8-17
Using Declarative Built-in Rules: Length Validator 8-18
Using Declarative Built-in Rules: List Validator 8-19
Using Declarative Built-in Rules: Range Validator 8-20
Using Declarative Built-in Rules: Regular Expression Validator 8-21
Using Declarative Validation: Built-in Rules 8-22
Using Declarative Built-in Rules: Script Expression Validator 8-23
Using Declarative Custom Rules: Entity-Specific Rules (Method Validators) 8-24
Using Declarative Custom Rules: Creating an Entity-Specific Method Validator 8-25
Using Declarative Global Validation Rules 8-26
Creating the Java Class for a Global Rule 8-27
Examining the Generated Skeleton Code 8-28
Modifying the Code for the Global Rule 8-29
Assigning the Global Rule to an Object 8-31
Testing the Global Validation Rule 8-32
Using Programmatic Validation 8-33
Debugging Custom Validation Code with the JDeveloper Debugger 8-34
Using a Domain to Create Custom-Validated Data Types 8-35
Creating and Using a Domain 8-36
Coding Validation in a Domain 8-37
Specifying Validation Order 8-38

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

Oracle University and Egabi Solutions use only

Summary 7-50
Practice 7 Overview: Programmatically Modifying Business Components 7-51

Troubleshooting ADF BC Applications


Objectives 9-2
Troubleshooting the Business Service 9-3
Troubleshooting the UI 9-4
Using Logging and Diagnostics 9-5
Displaying Debug Messages to the Console 9-6
Java Logging 9-7
Core Java Logging 9-9
Using ADF Logging 9-10
Configuring ADF Logging 9-11
Creating Logging Configurations in JDeveloper 9-13
Viewing ODL Logs 9-14
Using Design-Time Code Validation 9-15
Design-Time XML Validation 9-16
Design-Time Java Code Validation 9-17
Design-Time JSPX Validation 9-18
Using Tools and Utilities 9-19
Testing Java Code with JUnit 9-20
Unit Testing with JUnit 9-21
Using JDevelopers Profiler 9-22
Running the Profiler 9-23
Identifying Search Paths on Windows with FileMon 9-24
Troubleshooting Web Services 9-25
Troubleshooting Web Services: Sample Client 9-26
Troubleshooting Web Services: HTTP Analyzer 9-27
Using the JDeveloper Debugger 9-28
Understanding Breakpoint Types 9-29
Using Breakpoints 9-31
Declarative UI Debugging 9-32
Using the EL Evaluator 9-33
ADF Structure Pane and ADF Data Window 9-34
Object Preferences 9-35
Using Oracle ADF Source Code for Debugging 9-36
Setting Up Oracle ADF Source Code for Debugging 9-37
Utilizing Quick Javadoc 9-38
Setting Breakpoints in Source Code 9-39
Using Common Oracle ADF Breakpoints 9-40
Debugging Interactions with the Model Layer 9-41

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

Oracle University and Egabi Solutions use only

Summary 8-39
Practice 8 Overview: Implementing Validation 8-40

10 Understanding UI Technologies
Objectives 10-2
Enabling the World Wide Web with HTML and HTTP 10-3
Describing the Java Programming Language 10-4
Using Java as a Language for Web Development 10-6
What Are Servlets? 10-8
What Are JavaServer Pages (JSP)? 10-9
What Are JavaBeans? 10-10
What Is JavaServer Faces (JSF)? 10-11
JSF Key Concepts 10-13
JSF Component Model 10-14
JSF Multiple Renderers 10-15
Traditional Navigation 10-16
Defining Navigation by Using the JSF Controller 10-17
JSF Navigation: Example 10-18
Using JSF Components 10-19
Using JSF Managed Beans 10-20
Overview of JSF Page Life Cycle 10-21
Formal Phases of the JSF Life Cycle 10-22
Key Characteristics of Rich User Interfaces 10-24
Adding to JSF with ADF Faces 10-25
Using the ADF Controller 10-26
ADF Life Cycle Phases 10-27
Summary 10-28
11 Binding UI Components to Data
Objectives 11-2
Creating a JSF Page 11-3
Adding UI Components to the Page 11-5
Using the Component Palette 11-6
Using the Context Menu 11-7

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

Oracle University and Egabi Solutions use only

Correcting Failures to Display Data 9-42


Correcting Failures to Invoke Actions and Methods 9-45
Debugging Life Cycle Events: Task Flows 9-47
Debugging Life Cycle Events: Parameters and Methods 9-48
Debugging Life Cycle Events: Switching Between Main Page and Regions 9-49
Obtaining Help 9-50
Requesting Help 9-51
Summary 9-52
Practice 9 Overview: Troubleshooting 9-53

12 Planning the User Interface


Objectives 12-2
Describing the Model-View-Controller (MVC) Design Pattern 12-3
Technology Choices for Fusion Applications 12-4
Characteristics of ADF Task Flows 12-5
Characteristics of Unbounded ADF Task Flows 12-6
Working with Unbounded Task Flows 12-7
Characteristics of Bounded Task Flows 12-8
Comparing Unbounded and Bounded Task Flows 12-10
Bounded and Unbounded ADF Task Flows: Example 12-11
Creating an Unbounded Task Flow 12-12
Creating a Bounded Task Flow 12-13
Converting Task Flows 12-14
Using a Bounded Task Flow 12-15
Using ADF Task Flow Components 12-16
Defining ADF Control Flow Rules 12-19
Example of ADF Control Flow Rules 12-20
Using the Navigation Modeler to Define Control Flow 12-21
Using the Configuration Editor to Define Control Flow 12-22
Editing the.xml File to Define Control Flow 12-23

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

Oracle University and Egabi Solutions use only

Using the Data Controls Panel 11-8


Describing the ADF Model Layer 11-9
Types of Data Bindings 11-10
Using Expression Language (EL) 11-12
Expression Language and Bindings 11-13
Creating and Editing Data Bindings 11-15
Rebinding: Example 11-16
Opening a Page Definition File 11-17
Editing Bindings in a Page Definition File 11-18
Editing Bindings from a Page 11-19
Tracing Data Binding: From Database to Databound Components 11-20
Tracing Data Binding: From AM to Data Control 11-21
Tracing Data Binding: Creating Databound Components 11-22
Tracing Data Binding: From Data Control to Databound Components 11-23
Examining Data Binding Objects and Metadata Files 11-26
Binding Existing Components to Data 11-28
Accessing Data Controls and Bindings Programmatically 11-29
Running and Testing the Page 11-30
Summary 11-31
Practice 11 Overview: Creating Databound Pages 11-32

13 Adding Functionality to Pages


Objectives 13-2
Internationalization 13-3
Resource Bundles 13-4
Steps to Internationalize an Application 13-5
Automatically Creating a Resource Bundle 13-7
Automatically Creating a Text Resource 13-8
Using Component Facets 13-9
Using ADF Faces Rich Client Components 13-10
Using ADF Faces Input Components 13-11
Defining a List 13-13
Defining Lists at the Model Layer 13-14
Selecting a Value from a List 13-15
Selecting a Date 13-16
Using ADF Faces Table and Tree Components 13-18
Using Tables 13-19
Rendering (Stamping) the Table Data 13-20
Setting Table Attributes 13-21
Using Trees 13-23
Using Tree Tables 13-24
Providing Data for Trees 13-26
Using ADF Faces Output Components 13-28
Using ADF Faces Query Components 13-29
Using the af:query Component 13-30
Using the af:quickQuery Component 13-32
Creating a Query Search Form 13-34
Modifying Query Behavior 13-35
Using ADF Data Visualization Components 13-36

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

Oracle University and Egabi Solutions use only

Using the Structure Window to Modify a Task Flow 12-24


Using Wildcards to Define Global Navigation 12-25
Using Routers for Conditional Navigation 12-27
Defining Router Activities 12-28
Calling Methods and Other Task Flows 12-29
Defining a Task Flow Return Activity 12-30
Making View Activities Bookmarkable (or Redirecting) 12-31
Adding UI Code 12-32
Incorporating Validation into the User Interface 12-33
Describing the Course Application: UI Functionality 12-34
Summary 12-35
Practice 12 Overview: Defining Task Flows 12-36

14 Implementing Navigation on Pages


Objectives 14-2
Using ADF Faces Navigation Components 14-3
Performing Navigation 14-4
Using Buttons and Links 14-5
Defining Access Keys 14-6
Defining Tool Tips 14-8
Using Toolbars, Toolbar Buttons, and Toolboxes 14-9
Using Menus for Navigation 14-10
Creating Menus 14-11
Creating Pop-Up Menus 14-13
Creating Context Menus 14-14
Using a Navigation Pane 14-16
Using Breadcrumbs 14-17
Using Explicitly Defined Breadcrumbs 14-18
Using XML Menu Model for Dynamic Navigation Items 14-19
Creating an ADF Menu Model 14-20
Examining the ADF Menu Model 14-22
Binding the Navigation Pane to an XML Menu Model 14-23
Binding Breadcrumbs to an XML Menu Model 14-25
Defining a Sequence of Steps 14-26
Creating a Train 14-28
Skipping a Train Stop 14-29
Summary 14-30
Practice 14 Overview: Using ADF Faces Navigation Components 14-31
15 Achieving the Required Layout
Objectives 15-2
Using ADF Faces Layout Components 15-3
Adding Spaces and Lines: Spacer and Separator 15-4
Stretching Components 15-5
Enabling Automatic Component Stretching: Panel Splitter or Panel Stretch
Layout 15-6
Stretching a Table Column 15-7
Creating Resizable Panes: Panel Splitter 15-8
Printing Layout Panel Content: Show Printable Page Behavior Operation 15-9
Creating Collapsible Panes: Panel Splitter 15-10

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

Oracle University and Egabi Solutions use only

Visualizing Data 13-37


Summary 13-39
Practice 13 Overview: Using ADF Faces Components 13-40

16 Ensuring Reusability
Objectives 16-2
Benefits of Reusability 16-3
Designing for Reuse 16-4
Using a Resource Catalog 16-5
Creating a Resource Catalog 16-6
Reusing Components 16-7
Creating an ADF Library 16-8
Adding an ADF Library to a Project by Using the Resource Palette 16-9
Removing an ADF Library from a Project 16-10
Restricting BC Visibility in Libraries 16-11
Types of Reusable Components 16-12
Using Task Flow Templates 16-13

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

Oracle University and Egabi Solutions use only

Creating Collapsible Panes: Panel Accordion 15-11


Panel Accordion Overflow 15-12
Setting Panel Accordion Properties 15-13
Arranging Items in Columns or Grids: Panel Form Layout 15-15
Creating Stacked Tabs: Panel Tabbed with Show Detail Item 15-17
Hiding and Displaying Groups of Content: Show Detail 15-18
Arranging Items Horizontally or Vertically, with Scrollbars: Panel Group
Layout 15-20
Displaying Table Menus, Toolbars, and Status Bars: Panel Collection 15-22
Creating Titled Sections and Subsections: Panel Header 15-24
Grouping Related Components: Group 15-25
Displaying a Bulleted List: Panel List 15-26
Displaying Items in a Content Container Offset by Color: Panel Box 15-27
Arranging Content Around a Central Area: Panel Border Layout 15-28
Arranging Content Around a Central Area: Panel Stretch Layout 15-30
Using ADF Faces Skins 15-31
Using Dynamic Page Layout 15-32
Using Expression Language to Conditionally Display Components 15-33
Characteristics of Partial Page Rendering (PPR) 15-34
Enabling PPR Declaratively 15-35
Native PPR: Example 15-37
Declarative PPR: Example 15-38
Enabling PPR Programmatically 15-40
Enabling Automatic PPR 15-41
Conforming to PPR Guidelines 15-42
Summary 15-43
Practice 15 Overview: Using ADF Faces Layout Components 15-44

17 Passing Values Between UI Elements


Objectives 17-2
Holding Values in the Data Model (Business Components) 17-3
Holding Values in Managed Beans 17-4
Using Managed Properties 17-5
Managed Properties: Examples 17-6
Using Memory-Scoped Attributes 17-7
Memory Scope Duration with a Called Task Flow 17-9
Memory Scope Duration with a Region 17-10
Accessing Memory-Scoped Attribute Values 17-11
Using Memory-Scoped Attributes Without Writing Java Code 17-12
Overview of Parameters 17-13
Using Page Parameters 17-14
The Job of the Page Parameter 17-15
Using Task Flow Parameters 17-16
The Job of the Task Flow Parameter 17-18
Using Region Parameters 17-19
The Job of the Region Parameter 17-20
Developing a Page Independently of a Task Flow 17-21
Using View Activity Parameters 17-22
The Job of the View Activity Parameter 17-23
Summary: Passing a Value from a Containing Page to a Reusable Page Fragment in
Region 17-24
Passing Values to a Task Flow from a Task Flow Call Activity 17-25
xv
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle University and Egabi Solutions use only

Characteristics of Page Templates 16-14


Creating a Page Template 16-15
Editing a Page Template 16-17
Applying a Page Template to a Page 16-18
Characteristics of Declarative Components 16-19
Creating a Declarative Component 16-21
Using a Declarative Component on a Page 16-22
Characteristics of Page Fragments 16-23
Creating a Page Fragment 16-24
Using a Page Fragment on a Page 16-25
Characteristics of Regions 16-26
Wrapping a Task Flow as a Region 16-27
Converting a Bounded Task Flow to Use Page Fragments 16-28
Deciding Which to Use 16-29
Summary 16-30
Practice 16 Overview: Implementing Reusability 16-31

18 Responding to Application Events


Objectives 18-2
Adding UI Code 18-3
Creating Managed Beans 18-4
Registering Existing Java Classes as Managed Beans 18-5
Configuring Managed Beans 18-6
Referencing Managed Beans 18-7
Describing JSF and ADF Life-Cycle Roles 18-8
Coordinating JSF and ADF Life Cycles 18-9
Specifying When to Refresh Binding Executables 18-11
Specifying Whether to Refresh Binding Executables 18-13
Describing Types of Events 18-14
Using Phase Listeners 18-15
Using Event Listeners 18-16
Responding to Action Events 18-17
Creating Action Methods 18-18
Using Action Listeners 18-19
Value Change Events 18-20
Listening for Value Change Events 18-21
Event and Listener Execution Order 18-22
ADF Faces Enhanced Event Handling 18-23
Using JavaScript in ADF Faces Applications 18-24
Other ADF Faces Server Events 18-25
Using Table Model Methods in a Selection Listener 18-27
Using Tree Model Methods in a Selection Listener 18-28
Additional AJAX Events 18-29
Characteristics of the Contextual Event Framework 18-30
Contextual Events: Overview 18-31
Using the Contextual Event Framework to Coordinate Page Regions 18-32
Using the Contextual Event Framework to Coordinate Page Regions: Step 1
Using the Contextual Event Framework to Coordinate Page Regions: Step 2
Using the Contextual Event Framework to Coordinate Page Regions: Step 3
Using the Contextual Event Framework to Coordinate Page Regions: Step 4
Using the Contextual Event Framework to Coordinate Page Regions: Step 5
Using the Contextual Event Framework to Coordinate Page Regions: Step 6
Using the Contextual Event Framework to Coordinate Page Regions: Step 7

Oracle University and Egabi Solutions use only

Returning Values to a Calling Task Flow 17-27


Deciding Which Type of Parameter to Use 17-29
Summary 17-30
Practice 17 Overview: Passing Values Between Pages 17-31

18-33
18-34
18-35
18-36
18-37
18-38
18-39

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

19 Implementing Transactional Capabilities


Objectives 19-2
Handling Transactions with ADF BC 19-3
Default ADF Model Transactions 19-4
Transactions in Task Flows 19-5
Controlling Transactions in Task Flows 19-6
Transaction Support Features of Bounded Task Flows 19-7
Specifying Task Flow Transaction Start Options 19-8
Specifying Task Flow Return Options 19-9
Enabling Transactions on a Task Flow 19-11
Sharing Data Controls 19-13
Handling Transaction Exceptions 19-15
Designating an Exception Handler Activity 19-16
Defining Response to the Back Button 19-17
Saving for Later 19-19
Enabling Explicit Save for Later 19-21
Enabling Implicit Save for Later 19-23
Restoring Savepoints 19-24
Setting Global Save for Later Properties 19-26
Summary 19-27
Practice 19 Overview: Controlling Transactions 19-28
20 Implementing Security in ADF Applications
Objectives 20-2
Benefits of Securing Web Applications 20-3
Examining Security Aspects 20-4
ADF Security Framework: Overview 20-5
Configure ADF Security Wizard: Configuring ADF Security Authentication 20-6
Configure ADF Security Wizard: Choosing the Authentication Type 20-7
Using Form-Based Authentication 20-8
Configure ADF Security Wizard: Choosing the Identity Store 20-9
Configure ADF Security Wizard: Choosing the Welcome Page 20-10
Configure ADF Security Wizard: Enabling ADF Authorization 20-11
Files Modified by Configure ADF Security Wizard: web.xml 20-12
Other Files Modified or Created by Configure ADF Security Wizard 20-13
Enabling Users to Access Resources 20-14

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

Oracle University and Egabi Solutions use only

Using the Contextual Event Framework to Coordinate Page Regions: Step 8 18-40
Using the Contextual Event Framework to Coordinate Page Regions: Step 9 18-41
Summary 18-42
Practice 18 Overview: Responding to Events 18-43

Appendix A: Modeling the Database Schema


Objectives A-2
Modeling Database Schemas A-3
Goals of Database Modeling A-4
Characteristics of the JDeveloper Database Modeler A-5
Database Modeling Tools in JDeveloper A-6
Modeling Database Objects Offline A-7
Creating a New Offline Database A-8
Creating New Schema Objects in an Offline Database A-9
Creating a Database Diagram A-10
Importing Tables to the Diagram from an Offline Database A-11
Editing Objects on the Diagram A-12
Generating Changes from the Diagram to the Database A-13
Reconciling Changes to the Database A-14
Generating Changes from the Offline Database Object to the Database A-15
Importing Database Objects Without a Diagram A-16
Presenting the Storefront Schema A-17
Summary A-18
Practice Overview: Modeling the Schema for the Course Application A-19

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

Oracle University and Egabi Solutions use only

Defining Users and Roles in the Identity Store 20-15


Defining Security Policies 20-16
Defining Application Roles in the Policy Store 20-17
Assigning Identity Store Roles to Application Roles 20-18
Granting Permissions to Roles 20-19
Securing Groups of Pages (Bounded Task Flows) 20-20
Securing Individual Pages (Page Definitions) 20-21
ADF BC Model Authorization 20-22
Securing Row Data (Entity Objects or Attributes) 20-23
Granting Privileges on Entity Objects or Attributes 20-24
Application Authentication at Run Time 20-25
ADF Security: Implicit Authentication 20-26
ADF Security: Explicit Authentication 20-28
ADF Security: Authorization at Run Time 20-29
Programmatically Accessing ADF Security Context 20-30
Using Expression Language to Extend Security Capabilities 20-31
Using Global Security Expressions 20-32
Using a Security Proxy Bean 20-33
Summary 20-34
Practice 20 Overview: Implementing ADF Security 20-35

Appendix C: Practices and Solutions

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

Oracle University and Egabi Solutions use only

Appendix B: Deploying ADF Applications


Objectives B-2
Steps in the Deployment Process B-3
Configuring Deployment Options B-5
Creating Deployment Profiles B-6
Specifying Deployment Profile Options B-7
Creating a Business Components Deployment Profile B-8
Web Module Deployment B-9
Typical Web Application Deployment Example B-10
Example: Creating a WAR Deployment Profile for the UI Project B-11
Example: Creating an EAR Deployment Profile for the Application B-12
Using Deployment Descriptors B-13
Steps in the Deployment Process B-14
Preparing the Oracle WebLogic Server B-15
Installing the ADF Runtime to the WebLogic Installation B-16
Creating and Configuring the WebLogic Domain B-17
Creating a JDBC Data Source B-19
Configuring the Data Control to Use the Data Source B-21
Steps in the Deployment Process B-23
Creating a Connection to an Application Server B-24
Example: Deploying the Application B-25
Steps in the Deployment Process B-26
Deploying the Application from the WebLogic Administration Server Console B-27
Steps in the Deployment Process B-28
Using Ant to Automate the Deployment Process B-29
Creating an Ant Buildfile in JDeveloper B-30
Defining Ant Deployment Tasks B-31
Adding Elements to the Buildfile B-32
Running Ant on Buildfile Targets B-33
Creating an External Ant Tool B-35
Implementing Security in Deployed Applications B-36
Deployment Testing During Development B-38
Deployment Testing for Production B-39
Summary B-40
Practice Overview: Deploying the Web Application B-41

Oracle University and Egabi Solutions use only


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

Oracle University and Egabi Solutions use only

Preface

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

Oracle University and Egabi Solutions use only


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

Profile
Before You Begin This Course
Before you begin this course, you should have:

Experience with the basic Java language

A basic understanding of XML

Some experience with Oracle JDeveloper


How This Course Is Organized

Oracle University and Egabi Solutions use only

Oracle Fusion Middleware 11g: Build Applications with ADF is an instructor-led


course featuring lectures and hands-on exercises. Online demonstrations and written
practice sessions reinforce the concepts and skills that are introduced.

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

Related Publications
Oracle Publications
Title

Part Number

Oracle Fusion Middleware Fusion Developer's


Guide for Oracle Application Development
Framework 11 g Release 1 (11.1.1)

B31974-01

B31973-01

System release bulletins


Installation and users guides
read.me files
International Oracle Users Group (IOUG) articles
Oracle Magazine

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

Oracle University and Egabi Solutions use only

Oracle Fusion Middleware Web User Interface


Developer's Guide for Oracle Application
Development Framework 11 g Release 1 (11.1.1)
Additional Publications

Typographic Conventions
The following two lists explain Oracle University typographical conventions for
words that appear within regular text or within code samples.

Convention

Object or Term

Example

Courier New

User input;
commands;
column, table, and
schema names;
functions;
PL/SQL objects;
paths

Use the SELECT command to view


information stored in the LAST_NAME
column of the EMPLOYEES table.
Enter 300.
Log in as scott

Initial cap

Triggers;
Assign a When-Validate-Item trigger to
user interface object the ORD block.
names, such as
button names
Click the Cancel button.

Italic

Titles of
courses and
manuals;
emphasized
words or phrases;
placeholders or
variables

For more information on the subject see


Oracle SQL Reference
Manual

Lesson or module
titles referenced
within a course

This subject is covered in Lesson 3,


Working with Objects.

Quotation marks

Do not save changes to the database.


Enter hostname, where
hostname is the host on which the
password is to be changed.

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

Oracle University and Egabi Solutions use only

1. Typographic Conventions for Words Within Regular Text

Typographic Conventions (continued)

Convention

Object or Term

Example

Uppercase

Commands,
functions

SELECT employee_id
FROM employees;

Lowercase,
italic

Syntax variables

CREATE ROLE role;

Initial cap

Forms triggers

Form module: ORD


Trigger level: S_ITEM.QUANTITY
item
Trigger name: When-Validate-Item
. . .

Lowercase

Column names,
table names,
filenames,
PL/SQL objects

. . .
OG_ACTIVATE_LAYER
(OG_GET_LAYER ('prod_pie_layer'))
. . .
SELECT last_name
FROM
employees;

Bold

Text that must


be entered by a
user

CREATE USER scott


IDENTIFIED BY tiger;

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

Oracle University and Egabi Solutions use only

2. Typographic Conventions for Words Within Code Samples

Copyright 2009, Oracle. All rights reserved.

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

Oracle University and Egabi Solutions use only

Modeling the Database Schema

After completing this lesson, you should be able to do the


following:
Describe JDevelopers tool for database modeling
Create a schema model
Modify the schema model
Reconcile the modifications to the database
Import database object definitions to an offline database
Reconcile offline database objects with the database

Copyright 2009, Oracle. All rights reserved.

Lesson Aim
When designing an application to interact with the database, an understanding of the database
schema is essential, along with the ability to modify the schema as needed. This lesson shows
you how to use JDeveloper tools to define a model of a database schema and to use the model to
modify the schema.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 2

Oracle University and Egabi Solutions use only

Objectives

With JDevelopers database modeler, you can:


Create a schema model
Modify the schema model
Reconcile changes to the database

Copyright 2009, Oracle. All rights reserved.

Modeling Database Schemas


Offline database object modeling in projects has been extended to provide for:
Index-organized tables
External tables
Partitioned tables and indexes
Materialized (including partitioned and indexed) views and view logs
Object Collections
Triggers
Domain indexes
Storage properties (tablespace and so on)
Auto-generated column values
SXML definition generation
Cross-referencing multiple database objects within or between projects

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 3

Oracle University and Egabi Solutions use only

Modeling Database Schemas

Goals of Database Modeling

Visualize the schema to help analyze whether it meets


requirements.
Make any necessary modifications.

For new database objects:


Design schema to support business requirements.
Generate DDL to create the required database objects.

Copyright 2009, Oracle. All rights reserved.

Why Perform Database Modeling?


Visualizing existing tables in a data diagram can help you understand whether the schema might
need modifications to support the business requirements.
If the tables do not already exist, you can use the same diagrammer to design them and generate
the DDL scripts to create the tables.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 4

Oracle University and Egabi Solutions use only

Database modeling can help you achieve the following goals:


For existing database objects:

Characteristics of the JDeveloper Database


Modeler

Model existing objects, such as

Use Property Inspector to set


tables and foreign keys, by
properties on diagram and its
dragging from Database
objects
Navigator

Create new objects by


dragging from
Component Palette.

Copyright 2009, Oracle. All rights reserved.

Characteristics of the JDeveloper Database Modeler


Although this course concentrates on working with an existing database schema, it is important
to understand that you also can use JDevelopers database diagrammer to design and create new
tables.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 5

Oracle University and Egabi Solutions use only

With the JDeveloper Database Modeler you can:

Database Modeling Tools in JDeveloper

Model metadata for database objects outside the context of a


database schema.
Import objects from online database.
Generate changes to online schemas.

Diagrammer:
Create and modify objects by dragging from Component
Palette and Database Navigator.
Import objects from offline database model.
Generate changes to online schemas.
Copyright 2009, Oracle. All rights reserved.

Database Modeling in JDeveloper


You can use JDeveloper to work directly with database objects through a database connection.
Alternatively you can work with offline database definitions, which you can subsequently
generate to a database schema.
JDeveloper provides the tools you need to create and edit database objects such as tables and
constraints outside the context of a database. You can create new tables and views and generate
the information to a database, or you can import database objects from a database schema, make
the changes you want and then generate the changes back to the same database schema, to a new
database schema, or to a file that you can run against a database at a later date. Alternatively,
you can use JDevelopers modeling tools to visualize your offline database objects on a diagram.
You can use JDevelopers database diagrammer to design and create new tables as well. You
can import database objects from the offline database into the diagrammer. The diagrammer
allows you to import database objects from online schemas and also generate changes to online
schemas.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 6

Oracle University and Egabi Solutions use only

You can work with database objects in the following ways:


Online: Create and modify schema objects directly in a
database through a JDeveloper connection.
Offline:

You can create offline database definitions in the following


ways:
Create new offline database objects
Copy from database with filters

Copyright 2009, Oracle. All rights reserved.

Modeling Database Objects Offline


You can create offline database definitions based on objects that exist in a database schema in
one of the following ways:
Using Drag and Drop: You can drag tables, views, synonyms and sequences from a
database schema onto a database diagram, where they become accessible as offline
database objects.
Using Import with Filters: You can import tables, views, sequences and synonyms from a
database schema to an offline schema where they become available as offline database
objects. You can apply filters in the wizard to display only the objects that you are
interested in, and when there are a large number of objects in the schema you can turn off
auto-query so that the wizard does not refresh every time you type a filter character.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 7

Oracle University and Egabi Solutions use only

Modeling Database Objects Offline

Creating a New Offline Database

To create a definition for an offline database in which you


can model database objects, perform the following steps:
1. In the Application Navigator, right-click a project and choose
New to display the New Gallery.
2. In the New Gallery, expand Database Tier, and select Offline
Database Objects.
3. Select Offline Database to launch the Create Offline
Database Wizard.
4. In the pages of the wizard, enter properties for the database,
such as its name.

After an offline database is created, you can create various


database object definitions within it.
Copyright 2009, Oracle. All rights reserved.

Creating a New Offline Database


To create an offline database definition, perform the following steps:
1. In the Application Navigator, expand the application and the project you want to work in.
Right-click a project and choose New to display the New Gallery.
2. From the New Gallery, expand Database Tier, and select Offline Database Objects.
3. Select Offline Database to launch the Create Offline Database Wizard.
4. In the pages of the wizard, enter properties for the database, such as its name.
After an offline database is created, you can create various database object definitions within
this database.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 8

Oracle University and Egabi Solutions use only

Create new schema objects in an offline database by using


wizards to define:
Functions
Materialized views and view logs
Packages
Procedures
Sequences
Synonyms
Tables
Triggers
Types
Views
Copyright 2009, Oracle. All rights reserved.

Creating New Schema Objects in an Offline Database


You can create new schema objects in an offline database by invoking one of the New Database
Object wizards and entering the required information.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 9

Oracle University and Egabi Solutions use only

Creating New Schema


Objects in an Offline Database

Copyright 2009, Oracle. All rights reserved.

Creating a Database Diagram


After creating a named connection in the Database Navigator to browse database schema
objects, you can create a database diagram in any JDeveloper project. To create a new diagram,
perform the following steps:
1. Select the project in which you want to create the diagram.
2. Select File > New to invoke the New Gallery.
3. In the New Gallery, expand the General category and select Diagrams.
4. Select Database Diagram from the Items list and then click OK.
5. In the Create Database Diagram dialog box, specify a name for the diagram and optionally
a package name, and then click OK.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 10

Oracle University and Egabi Solutions use only

Creating a Database Diagram

Copyright 2009, Oracle. All rights reserved.

Importing Tables to the Diagram from an Offline Database


You can import tables from an offline database as follows:
1. In the Offline Database Navigator, select the desired offline object and drag it to the
diagram.
2. A depiction of the offline object appears on the diagram.
When you drag related tables to the diagram, the foreign key relations are also depicted visually.
Offline objects attributes can be modified in the Offline Database Navigator or on the diagram,
and are kept in synch.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 11

Oracle University and Egabi Solutions use only

Importing Tables to the Diagram


from an Offline Database

Editing Objects on the Diagram


In-place editing:

Copyright 2009, Oracle. All rights reserved.

Editing Objects on the Diagram


There are two ways to edit objects on the diagram:
In-place editing: Click inside the object, such as an attribute, then click it again to put the
text in edit mode.
Double-click the object to invoke the editor, such as the table editor shown in the slide.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 12

Oracle University and Egabi Solutions use only

Edit Table dialog box:

Generating Changes from the Diagram


to the Database
Invoke wizard.
In the wizard:

Select objects.
Specify operation.
Set database options.
Set SQL script options.

SQL script opens in


editor;
right-click to run it.

Copyright 2009, Oracle. All rights reserved.

Generating Changes to the Database


If you created a database diagram, you can right-click the object or objects on the diagram to
generate DDL to create, replace, or alter those objects. From the context menu, select
Synchronize with Database > Generate To > SQL Script. This invokes a wizard where you
specify the object, operations, and SQL script options that you want to use. When you complete
the wizard, the script that it generates opens in the editor, where you can run it.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 13

Oracle University and Egabi Solutions use only

Reconciling Changes to the Database

Copyright 2009, Oracle. All rights reserved.

Reconciling Changes to the Database


If you choose the Alter operation, the offline objects are compared with the online objects and
DDL is generated to make the online objects match the offline objects. You can optionally
specify that you want to manually reconcile the objects. After the wizard is completed, if you
specified manual reconciliation, an additional dialog box is displayed that enables you to
compare the objects to be generated to the database with the objects in the database, so that you
can choose which changes to generate to the database.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 14

Oracle University and Egabi Solutions use only

Choosing ALTER with Manual Reconcile enables you to


choose changes to be generated to the database.

To generate imported offline database objects to the database:


Right-click the object
in the Applications
Navigator
Select Generate To
Select the JDeveloper
connection, or choose
to create a SQL script
or SXML

Copyright 2009, Oracle. All rights reserved.

Generating Changes from the Offline Database Object to the Database


Whether or not you have created a database diagram, you can generate changes to the database
by right-clicking the database object or objects in the Applications Navigator and selecting
Generate To. You can then select a JDeveloper connection, or you can generate a SQL script or
SXML.
When you choose to generate to a JDeveloper connection as depicted in the slide, or to SQL
Scripts, this also invokes the Generate SQL from Offline Database Objects Wizard. Its pages
enable you to specify whether to create, replace, or alter, and whether to generate a SQL script,
along with script options. If you choose to generate to SXML, an XML file is created and opens
in the editor.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 15

Oracle University and Egabi Solutions use only

Generating Changes from the Offline Database


Object to the Database

You can import database


objects to an offline
database without using a
diagram:

Copyright 2009, Oracle. All rights reserved.

Importing Database Objects Without a Diagram


If you do not want to create a database diagram, you can use the Copy Database Objects to a
Project item in the New Gallery by expanding Database Tier and selecting Offline Database
Objects in the categories list. This invokes the Copy Database Objects to a Project Wizard,
which has the following pages:
Specify Source (shown in the slide): Choose the JDeveloper connection from which to
import.
Specify Target: Select the application and project to import to, and select or create a new
offline database to contain the imported objects.
Object Picker: Select the database objects to import.
Choose Operation: Choose whether to create, replace, or alter offline database objects.
Finish: A summary of the specified import. Click Finish to start it.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 16

Oracle University and Egabi Solutions use only

Importing Database Objects Without a Diagram

Copyright 2009, Oracle. All rights reserved.

Presenting the Storefront Schema


The schema used for the course application is a subset of the Fusion Order Demo (FOD)
schema. You can read about how to obtain the Fusion Order Demo in Section 2.2 of the Oracle
Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework
11g Release 1 (11.1.1).
The main tables that are used in the course application are Persons, Suppliers, Orders, and Order
Items. The application also uses some views, such as Products and ProductCategories.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 17

Oracle University and Egabi Solutions use only

Presenting the Storefront Schema

In this lesson, you should have learned how to:


Describe JDevelopers tool for database modeling
Create a schema model
Modify the schema model
Reconcile the modifications to the database
Import database object definitions to an offline database
Reconcile offline database objects with the database

Copyright 2009, Oracle. All rights reserved.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 18

Oracle University and Egabi Solutions use only

Summary

This practice covers the following topics:


Creating a database diagram
Adding existing schema objects to the diagram
Adding a new database object to the diagram
Creating the DDL to add the new object to the database

Copyright 2009, Oracle. All rights reserved.

Practice Overview: Modeling the Schema for the Course Application


(optional)
In this practice, you use the database diagrammer to create a visual representation of the
database schema. You also create a new database component (a table) and create the DDL to add
it to the schema.
This practice may be found in the Optional Practices section of Appendix A.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I A - 19

Oracle University and Egabi Solutions use only

Practice Overview:
Modeling the Schema for the Course Application

Oracle University and Egabi Solutions use only


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

Copyright 2009, Oracle. All rights reserved.

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

Oracle University and Egabi Solutions use only

Deploying ADF Applications

After completing this lesson, you should be able to do the


following:
Create deployment profiles
Configure deployment options
Use JDeveloper to deploy an application
Use WebLogic Server administration console to deploy an
application
Use Ant to deploy an application
Test the deployed application

Copyright 2009, Oracle. All rights reserved.

Lesson Aim
This lesson teaches you how to deploy an ADF BC application by using JDeveloper or by using
the WebLogic Server console. You also learn how to use Ant to automate the deployment
process.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 2

Oracle University and Egabi Solutions use only

Objectives

Deployment tasks:
Prepare application or project for deployment.
Prepare Oracle WebLogic Server (WLS) for ADF
deployment.
Deploy the application with one of the following
techniques:
Deploy directly from JDeveloper to WLS.
Deploy to an EAR file and use application server tool for
deploying to the application server.
Use a script to deploy.

Copyright 2009, Oracle. All rights reserved.

Steps in the Deployment Process


Deployment is the process of packaging application files as an archive file and transferring it to
a target application server.
The following are some common deployment techniques that you can use during the application
development and deployment cycle:
Deploy directly from JDeveloper to an application server. You would most likely do this
while developing the application so that you can quickly deploy it for frequent testing (see
later slides in this lesson regarding testing), but you also can use JDeveloper to deploy an
application to the production server.
Deploy from JDeveloper to an EAR file, and then use tools of the application server to
deploy the EAR file to the target server. You can do this when you are ready to test
features such as LDAP and SSO that may not be available on the development server. You
can also use this technique to deploy the application for production.
Use an automated script. Scripts are used in testing, and system administrators typically
run scripts to deploy applications in production environments.
Whether you use JDeveloper to deploy directly to the application server or to an EAR file, you
must first create the appropriate deployment profile to define how the application is packaged. If
deploying to Oracle WebLogic Server (WLS), you also must prepare WLS for ADF application
deployment. These tasks are discussed in subsequent slides.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 3

Oracle University and Egabi Solutions use only

Steps in the Deployment Process

Deployment tasks:
Prepare application or project for deployment.
Prepare Oracle WebLogic Server (WLS) for ADF
deployment.
Deploy the application with one of the following
techniques:
Deploy directly from JDeveloper to WLS.
Deploy to an EAR file and use application server tool for
deploying to the application server.
Use a script to deploy.

Copyright 2009, Oracle. All rights reserved.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 4

Oracle University and Egabi Solutions use only

Steps in the Deployment Process

Configuring Deployment Options

ADF Business Components: Business Component Java


ARchive (JAR)
Fusion Web application: Enterprise ARchive (EAR) and Web
ARchive (WAR) deployment profiles
Fusion Web application with customizations: Oracle ARchive
(OAR) and Metadata ARchive (MAR)

Deployment descriptors

Copyright 2009, Oracle. All rights reserved.

Configuring Deployment Options


Deployment is a two-step process. First you package the application into deployable artifacts by
using deployment profiles and deployment descriptors. Then you deploy these artifacts to the
target environment.
There are different types of deployment, whose options are configured in deployment profiles:
Applications based on ADF Business Components use a Business Component archive
(JAR).
Fusion Web applications typically use EAR and WAR deployment profiles.
Fusion Web applications that include customizations deploy to a target repository using
OAR, a type of deployment that allows for the packaging of metadata customizations. An
OAR can contain a MAR packaged inside it; a MAR is a compressed archive of selected
metadata.
This lesson discusses the first two types of deployment. For further information about deploying
Fusion Web applications with MDS customizations, see the Fusion Developers Guide for ADF.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 5

Oracle University and Egabi Solutions use only

To configure an application for deployment, you create:


Deployment profile, which can be one of three types:

Creating Deployment Profiles

Creating an application
deployment profile

For the Model project

For the
View-Controller
project

Copyright 2009, Oracle. All rights reserved.

Creating Deployment Profiles


A deployment profile defines the way the application is packaged into the archives that are
deployed into the target environment. The deployment profile:
Specifies the format and contents of the archive file to be created
Lists the source files, deployment descriptors, and other auxiliary files to be packaged
Describes the type and name of the archive file to be created
Highlights dependency information, platform-specific instructions, and other information
You can define and store deployment profiles at application or project level, giving you more
flexibility and enabling direct referencing and sharing. For example, you could create a WAR
profile for projects associated with the View and Controller layers and a Business Components
JAR for the model project. You could then create an application-level EAR profile that
assembles the model and view-controller profiles for deployment.
You can create a deployment profile by using the New Gallery, or by using application
properties or project properties. The types of profiles that are available for you to choose depend
on the type of project or application for which you are creating a profile. For example, as the
slide shows, application deployment profiles are EAR files, whereas project deployment profiles
offer different choices depending on the type of project.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 6

Oracle University and Egabi Solutions use only

Deployment profiles:
Specify how application is packaged for deployment
Can be application level or project level

Deployment profile options:


Specified in profile
properties
Different depending on
type of profile

Copyright 2009, Oracle. All rights reserved.

Specifying Deployment Profile Options


After you choose the type of deployment profile to create and give it a name, you are presented
with a Deployment Profile Properties dialog box. There is a tree in the left pane of the dialog
box, and the options in that tree are different depending on the type of deployment profile you
are creating. You can get more information about the choices that are available from online
Help.
Subsequent slides discuss the different types of deployment profiles in greater detail.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 7

Oracle University and Egabi Solutions use only

Specifying Deployment Profile Options

You can create business components deployment profiles by


using one of the following:
Context menu
Project Properties dialog box
New Gallery

Copyright 2009, Oracle. All rights reserved.

Creating a Business Components Deployment Profile


To create a deployment profile for the ADF BC library, do the following:
1. In the Application Navigator, right-click the application module and select Business
Components Deployment from the context menu.
2. In the Create Business Components Deployment Profiles Wizard, ensure that Simple
Archive Files is in the Selected list, and then click Next.
3. On the second page of the wizard, you can name the profile, then click Finish.
Another way to create a deployment profile is to invoke the Project Properties dialog box, select
Deployment, and then click New.
These methods of creating a deployment profile do not give you the ability to set a path for
deploying the JAR file, but set it to deploy to a default path, which is a \deploy directory
under your project. If you want to specify where to deploy the JAR file, you can create the
deployment profile by using the New Gallery instead (General > Deployment Profiles > ADF
Library JAR File). This invokes a dialog box where you can specify a path to the JAR file,
which is important if you want to deploy it to a central location for sharing with other
developers.
After you create the deployment profile, you can use it to create the JAR. Right-click the project,
select Deploy, select the JAR to create, and select Deploy again.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 8

Oracle University and Egabi Solutions use only

Creating a Business Components


Deployment Profile

It is used for deploying ADF BC applications to a Web tier.


It contains ADF BC components and JSPs and servlets.
It is used for deploying JSP, JSF, and servlet applications.
Deployment is to a Java EE archive (.ear or .war file).

JDeveloper creates the archive file and deployment


descriptors.

Copyright 2009, Oracle. All rights reserved.

Web Module Deployment


A Web module deployment is a standard Java EE deployment model designed to be deployed to
an application server such as Oracle Application Server. It contains all of the components of the
business logic layer and JSPs or servlets. The deployment is created as a WAR file or an EAR
file that contains all of the ADF Business Components code and JSP or servlet code.
JDeveloper provides complete deployment in this model and creates all the parts necessary for
Web module deployment automatically.
This deployment model has the business logic tier and client tier sharing the same JVM, which is
hosted by an application server.
The next few pages outline the steps in creating and deploying a Web module.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 9

Oracle University and Egabi Solutions use only

Web Module Deployment

To deploy a typical Web application that uses ADF Business


Components:
Create a WAR deployment profile for the UI project
Create an EAR deployment profile for the application
Deploy the application to the EAR file or directly to an
application server

Copyright 2009, Oracle. All rights reserved.

Typical Web Application Deployment Example


The following slides illustrate the process of deploying a Web application to an application
server.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 10

Oracle University and Egabi Solutions use only

Typical Web Application Deployment Example

Example: Creating a WAR Deployment Profile for


the UI Project
1

2
4
Context root becomes part of URL
to access the Web application.
Copyright 2009, Oracle. All rights reserved.

Creating a WAR Deployment Profile for the UI Project


You create a new deployment profile for a UI project by selecting Deployment Profiles and
WAR File from General category of the New gallery, or by modifying project properties and
creating a new deployment profile. After you give the profile a name, JDeveloper launches the
WAR Deployment Profile Properties dialog box.
The default setting for the profile selects all of the client JSP code, in the example, and all of the
ADF BC components. When deployed, the profile creates both .war and .ear files. The .war
file contains the JSPs and the ADF BC components, whereas the .ear file contains the
deployment descriptor files.
You should specify a context root for the application, because the one supplied by default is
rather lengthy, and the component root becomes part of the URL for accessing the application.
To create a WAR deployment profile, perform the following steps:
1. For the project that contains your user interface, invoke the Project Properties dialog box,
select Deployment, and click New (or select the project and use the New Gallery > General
> Deployment Profiles > WAR File).
2. Choose the archive type (WAR) and give the profile a name.
3. Edit the profile that you just created.
4. Specify a short and descriptive Web Context Root.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 11

Oracle University and Egabi Solutions use only

Creates both .war and


.ear files

Copyright 2009, Oracle. All rights reserved.

Creating an EAR Deployment Profile for an Application


To create the application-level EAR deployment profile, perform the following steps:
1. Invoke the Application Properties dialog box, select Deployment, and click New (or from
the Application menu select New and use the New Gallery > General > Deployment
Profiles > EAR File).
2. Choose the archive type (EAR) and give the profile a name.
3. Edit the profile that you just created.
4. In the EAR Deployment Profile Properties dialog box there are several options that you
can specify for the EAR file. At a minimum, you should select the Application Assembly
node from the tree, and then select the modules to include in the EAR. The example in the
slide shows the selection of the WAR file that was previously created for the UI project,
but you typically would be deploying multiple modules that compose an application.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 12

Oracle University and Egabi Solutions use only

Example: Creating an EAR Deployment Profile for


the Application

Deployment descriptors are:


Project configuration files deployed with the application
XML files of several types depending on project
technologies and deployment target
Created in various ways:
By JDeveloper wizards
As XML source files
By using the New Gallery

Copyright 2009, Oracle. All rights reserved.

Using Deployment Descriptors


Deployment descriptors are configuration files associated with projects and deployed with Java
EE applications and modules. Deployment descriptors contain the declarative data required to
deploy the components as well as the assembly instructions that describe how the components
are composed into an application. Projects require different deployment descriptors depending
on the technologies the project uses and on the type of the target application server. In addition
to the standard Java EE deployment descriptors such as application.xml and web.xml,
you can also have deployment descriptors that are specific to your target application server. For
example, if you are deploying to Oracle WebLogic Server, you can also have weblogic.xml
and weblogic-application.xml.
JDeveloper provides dialog boxes to inspect and set the properties of many deployment
descriptors. You also can create and edit them as XML source files. The essential descriptors are
created by the wizards that create deployment profiles. Add other descriptors only if you want to
override default behavior. New deployment descriptors are placed in a META-INF subfolder of
a projects Application Sources or Web Contents folders.
Warning: Avoid creating any deployment descriptors that apply to EAR files for more than one
project in an application or workspace. These files are assigned to projects, but have workspace
scope. If multiple projects in an application or workspace have the same deployment descriptor,
the one belonging to the launched project will supersede the others. This restriction applies to
THESE application.xml,
eKIT MATERIALS ARE FORweblogic-jdbc.xml,
YOUR USE IN THIS CLASSROOM
ONLY. COPYINGand
eKITweblogic.xml.
MATERIALS FROM THIS
jazn-data.xml,
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 13

Oracle University and Egabi Solutions use only

Using Deployment Descriptors

Deployment tasks:
Prepare application or project for deployment.
Prepare Oracle WebLogic Server (WLS) for ADF
deployment.
Deploy the application with one of the following
techniques:
Deploy directly from JDeveloper to WLS.
Deploy to an EAR file and use application server tool for
deploying to the application server.
Use a script to deploy.

Copyright 2009, Oracle. All rights reserved.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 14

Oracle University and Egabi Solutions use only

Steps in the Deployment Process

To deploy an application to Oracle WebLogic Server:


Install the ADF Runtime to the WebLogic installation
Create and configure the WebLogic domain
Create a JDBC data source
Additionally, you must configure the application to use the WLS
data source that you created.

Copyright 2009, Oracle. All rights reserved.

Preparing the Oracle WebLogic Server


There are three basic steps that must be done to prepare the WebLogic Server for an ADF
application. Subsequent slides describe these steps.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 15

Oracle University and Egabi Solutions use only

Preparing the Oracle WebLogic Server

If you need to, use the Oracle


Installer to add ADF Runtime to
the existing WebLogic installation.
Not needed if you:
Are using integrated WLS
Installed WLS with the
JDeveloper installer and selected
ADF Runtime option when
installing

Copyright 2009, Oracle. All rights reserved.

Installing the ADF Runtime to the WebLogic Installation


The Oracle WebLogic Server requires the ADF Runtime to run Oracle ADF applications.
Installing the ADF Runtime is not required if you are using JDeveloper to run applications in the
Integrated WLS. If you installed the Oracle WebLogic Server 10gR3 together with JDeveloper
11g by using the Oracle JDeveloper 11g Installer with the Application Development Framework
Runtime option selected, then the ADF Runtime is already installed.
To install the ADF Runtime into an existing WebLogic Server, perform the following steps:
1. Start the Oracle JDeveloper 11g Installer as described in the Installation Guide. You can
download the installer from Oracle Technology Network (OTN).
2. In the Choose Middleware Home directory page, select Use an existing Middleware Home,
select the directory in which your Oracle WebLogic Server 10gR3 resides, and click Next.
3. In the Choose Products and Components page, choose Application Development
Framework Runtime, deselect JDeveloper Studio if you do not want to install the
JDeveloper IDE, and click Next. The Oracle WebLogic Server product and components
should be gray and unselectable. If it is enabled and selected, you must check whether you
have selected the correct Oracle WebLogic Server installation directory.
4. Follow the instructions in the Oracle JDeveloper 11g Installation Guide to complete the
installation.
5. When the installation is complete, click Done.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 16

Oracle University and Egabi Solutions use only

Installing the ADF Runtime to the WebLogic


Installation

Creating and Configuring the WebLogic Domain

You need to have a WebLogic domain that is configured to


accept ADF applications.
Use the Oracle WebLogic Configuration Wizard to:
Create a new domain that is configured for ADF

OR

Configure an existing
domain for ADF
Copyright 2009, Oracle. All rights reserved.

Creating and Configuring a WebLogic Domain


You need to create and configure a WebLogic domain to accept ADF applications. If you do not
already have a domain, you need to create a new domain. If you already have a domain, you
must extend the domain before it can run ADF applications.
To create a new WebLogic domain configured for ADF, perform the following steps:
1. Start the configuration by choosing Oracle WebLogic > WebLogic Server 10.3 > Tools >
Configuration Wizard from the Windows Start menu.
2. In the Welcome page, select Create a New WebLogic Domain and click Next.
3. In the Select Domain Source page, select Generate a domain configured automatically to
support the following products:, then select Application Development Framework and
click Next. The option WebLogic Server (Required) is already selected.
4. In the Configure Administrator Username and Password page, enter the username and
password and click Next.
5. In the Configure Server Start Mode and JDK page, select whether the domain is for a
development or a production system, choose the JDK to use, and click Next.
6. In the Customize Environment and Services Setting page, select No when asked to
customize further domain options and click Next.
7. In the Create WebLogic Domain page, enter the name and location of the new domain and
click Create.
8. MATERIALS
Click DoneARE
when
the
creation
process
has finished.ONLY. COPYING eKIT MATERIALS FROM THIS
THESE eKIT
FOR
YOUR
USE IN
THIS CLASSROOM
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 17

Oracle University and Egabi Solutions use only

You can now start the Oracle WebLogic Server by running the command-line script
<ORACLE_HOME>\user_projects\domains\domain_name\bin\startWebLogi
c.cmd and stop the server using the stopWebLogic.cmd script in the same directory.
Access the Oracle WebLogic Server Administration Console by using the URL
http://localhost:7001/console.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 18

Oracle University and Egabi Solutions use only

Creating and Configuring a WebLogic Domain (continued)


If you are extending an existing WebLogic domain for Oracle ADF, rather than creating a new
domain, you need to perform the following steps:
1. Start the Configuration Wizard by choosing Oracle WebLogic > WebLogic Server 10.3 >
Tools > Configuration Wizard from the Windows Start menu.
2. In the Welcome page, select Extend an existing WebLogic domain and click Next.
3. In the Select a WebLogic Domain Directory page, select the location of the domain you
want to configure for ADF, and click Next.
4. In the Select Extension Source page, select Extend my domain automatically to support
the following added products:, then select Application Development Framework and click
Next.
5. In the Customize JDBC and JMS File Store Settings page, leave No selected to update the
domain as specified in the template and click Next.
6. In the Extend WebLogic Domain page, enter the domain name and location and then click
Extend.
7. Click Done when the configuration has finished.
8. After you have extended the domain, check the POST_CLASSPATH entry to make sure
that setDomainEnv is set to the correct location, which should be
ORACLE_HOME\jdeveloper\modules\features\adf.share_11.1.1.jar.
This configures the rest of the run-time .jar files using the manifest file.
Note: Your applications EAR file must have a weblogic-application.xml file
containing a reference to the adf.oracle.domain shared library.

Creating a JDBC Data Source

2
4

Copyright 2009, Oracle. All rights reserved.

Creating a JDBC Data Source


To set up a data source in the WebLogic server, perform the following steps:
1. With the server started, invoke the WebLogic Server Administration Console:
- Enter the URL for the administration console, such as http://localhost:7101/console,
or use the Start menu.
- When the console application is deployed, enter credentials, such as weblogic /
weblogic, and click Log In.
2. Invoke the Data Sources Wizard:
- In the Domain Structure section at the left of the page, click Services > JDBC > Data
Sources.
- In the Summary of JDBC Data Sources section of the page, click New.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 19

Oracle University and Egabi Solutions use only

Name

Any name, such as FODLocal, to denote that you are


using the FOD schema and a local database

JNDI Name

jdbc/<connection name>DS: This is the name that


you will use to configure the application module, such as
jdbc/FODDS.

Database Type

Oracle

Database Driver

Oracles Driver (Thin) Versions: 9.0.1,9.2.0,10,11

On the Transaction Options page of the wizard, accept the defaults.


On the Connection Properties page of the wizard:
Database Name

SID of the database in your JDev connection, such as XE

Host Name

Host of the database in your JDev connection, such as


localhost

Port

Port of the database in your JDev connection, such as


1521

Database User
Username and password of the schema in your JDev
Name and Password connection, such as fod / fusion
-

On the Test Database Connection page of the wizard, review the values and click
Test Configuration, which should return a message Connection test succeeded.
Click Next (do not click Finish until you complete the next page.)
- On the Select Targets page of the wizard, select the DefaultServer check box and
click Finish.
4. So that the configuration takes effect, stop and then restart the WLS Server instance by
using the Start menu (or JDeveloper if stopping the integrated server).

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 20

Oracle University and Egabi Solutions use only

Creating a JDBC Data Source (continued)


3. Define the new data source:
- On the JDBC Data Source Properties page of the wizard:

Configuring the Data Control to Use


the Data Source

Configure the data control:

Copyright 2009, Oracle. All rights reserved.

Configuring the Data Control to Use the Data Source


Each application module that is used as a data control in the application must use the WLS data
source when running a page in a browser. To configure an application module to use the data
source, perform the following steps:
1. In the Application Navigator, right-click the application module and select Configurations.
2. In the Manage Configurations dialog box:
a. Select the Local configuration and click Copy.
b. Select the new configuration and click Edit.
c. In the Edit Business Components dialog box:
Set the following properties on the Application Module tab:
Business Component
Configuration Name

Any unique name, such as


FODProductAMLocalWeb

Connection Type

JDBC DataSource

Datasource Name

The JNDI name of your WLS data source, such as


jdbc/fod

On the Properties tab, set jbo.locking.mode to optimistic, the preferred locking mode
for Web applications.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 21

Oracle University and Egabi Solutions use only

Define a new AM configuration:

Oracle University and Egabi Solutions use only

Configuring the Data Control to Use the Data Source (continued)


Next you set the data control to use the new configuration:
1. In the Application Navigator, select DataBindings.cpx.
2. In the Structure window, expand dataControlUsages and select the data control.
3. In the Property Inspector, select the new configuration from the Configuration drop-down
list.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 22

Deployment tasks:
Prepare application or project for deployment.
Prepare Oracle WebLogic Server (WLS) for ADF
deployment.
Deploy the application with one of the following
techniques:
Deploy directly from JDeveloper to WLS.
Deploy to an EAR file and use application server tool for
deploying to the application server.
Use a script to deploy.

Copyright 2009, Oracle. All rights reserved.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 23

Oracle University and Egabi Solutions use only

Steps in the Deployment Process

Creating a Connection to an
Application Server

Start the Application Server Connection Wizard: Right-click


IDE Connections > New Application Server Connection.
Enter the following:
Connection name
Connection type
Username and
password
Host name and RMI port

Test the connection.

Copyright 2009, Oracle. All rights reserved.

Creating a Connection to an Application Server


Before you can use the JDeveloper built-in deployment utility, you must create a connection
object. The deployment wizards use this connection to build the deployment archives and
physically copy the deployment files to the target environment.
You start the process by right-clicking the IDE Connections node in the Application Server
Navigator (View > Application Server Navigator) or in the Resource Palette and selecting New
Application Server Connection. This launches the Create Application Server Connection
Wizard. You can also launch the wizard from the New Gallery.
Enter the required information into the wizard such as:
Connection name
Connection type (WebLogic 10.3, Tomcat 6.x, WebSphere Server 6.x or JBoss 4.x)
Administrative username and password for the application server
Host name and RMI port
Before leaving the wizard, be sure to visit the Test page of the wizard and click Test to ensure
that the connection functions correctly. The application server must be running in order for the
connection to be successful.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 24

Oracle University and Egabi Solutions use only

1. Invoke the Application


menu.
2. Select Deploy.

3. Select a deployment
profile.
4. Select to deploy to an
EAR file, an existing
connection, or a new
connection.

3
4

Copyright 2009, Oracle. All rights reserved.

Deploying the Application


Now that you have created an application deployment profile, the rest of the process is almost
automatic.
To actually deploy the application, right-click the deployment profile, click Deploy to, and
select the connection you want to use. JDeveloper now uses the connection information to copy
the required deployment files to the target environment.
Alternatively, you could deploy to an EAR file and then use tools of the application server to
deploy the EAR file.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 25

Oracle University and Egabi Solutions use only

Example: Deploying the Application

Deployment tasks:
Prepare application or project for deployment.
Prepare Oracle WebLogic Server (WLS) for ADF
deployment.
Deploy the application with one of the following
techniques:
Deploy directly from JDeveloper to WLS.

Deploy to an EAR file and use application server tool


for deploying to the application server.
Use a script to deploy.

Copyright 2009, Oracle. All rights reserved.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 26

Oracle University and Egabi Solutions use only

Steps in the Deployment Process

Deploying the Application from the WebLogic


Administration Server Console
1

Copyright 2009, Oracle. All rights reserved.

Deploying the Application from the WebLogic Administration Server Console


To deploy on Oracle WebLogic Server, perform the following steps:
1. Start the WebLogic Server instance.
2. Invoke the Administration Console.
3. Navigate to Deployments panel.
4. Install the EAR that you created in JDeveloper.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 27

Oracle University and Egabi Solutions use only

Deployment tasks:
Prepare application or project for deployment.
Prepare Oracle WebLogic Server (WLS) for ADF
deployment.
Deploy the application with one of the following
techniques:
Deploy directly from JDeveloper to WLS.
Deploy to an EAR file and use application server tool for
deploying to the application server.

Use a script to deploy.

Copyright 2009, Oracle. All rights reserved.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 28

Oracle University and Egabi Solutions use only

Steps in the Deployment Process

Using Ant to Automate the Deployment Process

Ant is an XML scripting syntax


that enables you to build and deploy
Java EE applications.
Define named series of tasks
(called targets).
Define dependencies between targets.

Advantages of Ant:

Well-documented
Widely adopted
Easy to configure
Extensible

Obtain Ant information at: http://ant.apache.org


Copyright 2009, Oracle. All rights reserved.

Deploying with Ant


The Java-based Ant tool is a programmatic approach for building and deploying Java EE
applications. It offers many advantages, such as an abundance of documentation and expertise,
wide adoption of the tool, and the relative ease with which developers can configure this tool to
help them automate the build-and-deploy cycle. In addition, because Ant is written in Java,
developers can extend the functionality by writing their own custom tasks. Ant has built in
support for CVS, JUnit, and other tasks so you can automate the entire build, deployment, and
unit test process.
An Ant buildfile defines targets and dependences between targets. A target is a sequence of
programmatic tasks. When Ant is run to make a target, it first makes other targets on which it
depends, and then executes the targets own tasks.
Oracle JDeveloper supports creating and running Ant tasks. Ant buildfiles can be added to or
created for projects. Ant buildfiles can be edited with JDevelopers XML Source Editor. Ant can
be invoked from the user interface to make targets defined in buildfiles.
The buildfile may vary depending on the target application server. For deployment to other
application servers, see the application servers documentation. If your application server does
not provide specific Ant tasks, you may be able to use generic Ant tasks. For example, the
generic ear task creates an EAR file for you.
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 29

Oracle University and Egabi Solutions use only

Creating an Ant Buildfile in JDeveloper

Copyright 2009, Oracle. All rights reserved.

Creating an Ant Buildfile


Ant buildfiles are XML files, and as such can be maintained by using JDeveloper XML editing
tools. Buildfiles use a target tree to define various tasks. A target is a set of tasks to be executed,
such as compiling or packaging into JAR files for distribution. Targets may have dependencies
on other targets as defined in the tree.
To create a buildfile, perform the following steps:
1. Select a project in the Applications Navigator.
2. Select File > New from the menu.
3. In the New Gallery, expand the General category and select Ant, and then select Buildfile
from Project in the items list. Click OK.
4. In the Create Buildfile from Project dialog box, specify the file name and directory, and
optionally indicate if you want this to be the project buildfile. Click OK.
5. The buildfile opens in the editor with some default targets, along with a Component Palette
of Ant-related elements that you can add to the XML file.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 30

Oracle University and Egabi Solutions use only

Defining Ant Deployment Tasks

Tasks for local server deployment:


<copy>
<delete>
<java>
Tasks for remote deployment:
<ftp>
<sleep>
<condition> <get>
Copyright 2009, Oracle. All rights reserved.

Defining Ant Deployment Tasks


The set of core Ant tasks that you can find in the Component Palette includes several that you
can use in the deployment process. For example, to create and use archive files, you can employ
the tasks <jar>, <ejbjar>, <ear>, <war>, <unjar>, and <unwar>.
You use the following tasks for local server deployment:

<copy>: Copies a file or FileSet (group of files) to a new file or directory

<delete>: Deletes a single file, a specified directory and all its files and subdirectories,
or a set of files specified by one or more FileSets

<java>: Executes a Java class within the running (Ant) VM or forks another VM if
specified
The following core Ant tasks are useful for remote deployment:

<ftp>: Implements a basic FTP client that can send, receive, list, and delete files, and
create directories

<condition>: Sets a property to true by default if a certain condition holds true;


otherwise, the property is not set. You can set the value to something other than the default
by specifying the value attribute.
<sleep>: A task for pausing for a short period of time. It is useful when a build or
deployment process requires an interval between tasks.

<waitfor>: Blocks execution until a set of specified conditions becomes true

<get>: Gets a file from a URL


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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 31

Oracle University and Egabi Solutions use only

Tasks for handling archive files:


<war>
<jar>
<unjar>
<ejbjar>
<unwar>
<ear>

Adding Elements to the Buildfile

Adding a target:

Adding a task:
1

Copyright 2009, Oracle. All rights reserved.

Adding Elements to the Buildfile


With the buildfile opens in the editor, you can add elements to it by dragging them from the
Component Palette to the Structure window. For example, to add a target to the buildfile,
perform the following steps:
1. In the Component Palette, select Apache Ant from the drop-down list and click target.
2. Drag target to the desired location in the Structure window.
3. In the Insert target dialog box, name the target and then click OK. You can optionally
define advanced properties, such as dependencies, in the Property Inspector.
To add tasks to a target, perform the following steps:
1. In the Component Palette, select the desired task type, such as Core Ant Tasks, from the
drop-down list and click the desired task, such as copy.
2. Drag the task to the desired target in the Structure window.
3. In the insert dialog box (if there is one) or in the Property Inspector, define attributes of the
task as needed.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 32

Oracle University and Egabi Solutions use only

Defining project buildfile and default target

Invoking the Run Ant Wizard


to specify advanced options.

Running
on a target

Running on
a project
Running Ant from the toolbar
Copyright 2009, Oracle. All rights reserved.

Running Ant on Buildfile Targets


You can run Ant on buildfile targets in one of the following ways:
On targets in the project buildfile: A project can contain several Ant buildfiles, but one can
be designated as the project buildfile. You can configure the Run Ant toolbar button and
drop-down menu to give easy access to the project buildfiles targets.
From the Structure window when editing an Ant buildfile: When an Ant buildfile is open
in an XML source editor, its targets are listed in the Structure window and can be run.
From external tools that you define: Use the Create External Tool Wizard to define menu
items and toolbar buttons that make Ant targets. The projects that external tools act on
need not be open in JDeveloper.
Running Ant on Project Buildfile Targets
To select and configure a project buildfile, go to the Ant project properties page (choose Tools >
Project Properties).
You can run Ant on targets in the project buildfile in one of the following ways:
From the toolbar Run Ant drop-down menu, choose a target.
From the toolbar, click Run Ant without invoking the drop-down menu.
From the main menu, choose Build > Run Ant on <Project>.
If you use one of the last two methods, Ant makes (compiles) the projects designated default
THESE target.
eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS
COMPUTER IS STRICTLY PROHIBITED

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 33

Oracle University and Egabi Solutions use only

Running Ant on Buildfile Targets

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 34

Oracle University and Egabi Solutions use only

Running Ant on Buildfile Targets (continued)


Running Ant from the Structure Window
From the Structure window, you can run Ant by using either the project configuration or a
distinct buildfile configuration. The buildfile configuration is derived initially from the project
configuration, and persists with the buildfile from session to session.
You can invoke a target from the Structure window in one of the following ways:
Run Ant using the project configuration.
1. Open an Ant buildfile or give focus to a buildfile that is already open. The Structure
window displays the buildfiles elements.
2. Right-click a target element, and choose Run Target <target>. Ant runs to make the
target, and the log window displays the results.
Run Ant using a buildfile-specific configuration.
1. Open an Ant buildfile or give focus to a buildfile that is already open. The Structure
window displays the buildfiles elements.
2. Right-click in the editor window and select Run Ant Target > <target> or select Run
Ant Target > Advanced to open the Run Ant Wizard where you can configure
advanced options.
3. Ant runs to make (compile) the target, and the log window displays the results.

Creating an External Ant Tool

Copyright 2009, Oracle. All rights reserved.

Creating an External Ant Tool


An external Ant tool enables you to build a project from a custom menu item or toolbar button
without first opening the project in JDeveloper. To create an external Ant tool, perform the
following steps:
1. From the main menu, choose Tools > External Tools.
2. In the External Tools dialog box, click New to open the Create External Tool Wizard.
3. On the Type page of the wizard, select Apache Ant in the Tool Type drop-down menu and
click Next.
4. On the remaining pages of the wizard, describe the Ant target, configure the build
parameters, and select UI items to represent the external Ant tool. Click Help on any page
for more information.
5. On the last page of the wizard, click Finish to create the external Ant tool.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 35

Oracle University and Egabi Solutions use only

Implementing Security in Deployed Applications

After deployment, you need to migrate to WLS the


applications:
Database credential store
Security policies

To help with this migration, you can:


Run command-line script
OR
Use simplified method with the supplied Ant script

Copyright 2009, Oracle. All rights reserved.

Implementing Security in Deployed Applications


Although JDeveloper 11g migrates application identities to the integrated WebLogic Server for
single-user testing and debugging, there is no automated migration of the identities to an
external, stand-alone WLS. Typically the file-based identities in an application include only a
few test usernames in the necessary roles for development testing purposes. The full set of
usernames, roles, and role memberships needs to be defined on the stand-alone WebLogic server
as a separate step if these have not already been set up for other applications environment.
After deploying to WLS, you must therefore migrate your applications credential store and any
security policies outside of JDeveloper. There are some tools to assist you with this process:
The command-line script
<JDev_Home>/jdeveloper/modules/oracle.jps_11.1.1/
scripts/migrateSecurityStore can merge the credentials of your application with

the existing data store, and can also merge application-level security policies with domainlevel policies. Refer the JDeveloper online Help.
For the most common use cases (migrating an applications credentials in cwallet.sso
or the security policies in jazn-data.xml to the WLS domains cwallet.sso or
system-jazn-data.xml file), you can use a simplified method that uses an Ant
script.
(http://www.oracle.com/technology/products/jdev/tips/muench/credmig111100/index.htm)

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 36

Oracle University and Egabi Solutions use only

Oracle University and Egabi Solutions use only

Implementing Security in Deployed Applications (continued)


There is a simplified method that uses an Ant script (see http://www.oracle.com/
technology/products/jdev/tips/muench/credmig111100/index.html.) You can use this
method for the most common use cases:
- Migrating the credentials in an application's cwallet.sso file to the stand-alone
WebLogic domains cwallet.sso file.
- Migrating the security policies in an application jazn-data.xml file to the standalone WebLogic domains system-jazn-data.xml file.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 37

Deployment Testing During Development

Copyright 2009, Oracle. All rights reserved.

Deployment Testing During Development


JDeveloper enables you to create an instance in any compatible Oracle WebLogic Server
installation (which could be the integrated server) as a test environment to simulate the
production server. This enables you to specify a full WebLogic Server instance to use as your
primary run-time environment for development within JDeveloper. You can configure the
environment with the services you are using, so that you can exactly simulate your production
server for testing.
In JDeveloper there is one Application Server instance that you can leave running, and each run
operation deploys and runs the application in that Application Server instance. This mode allows
for complete configuration of the server, and is recommended for developers who are building
SOA applications. At the same time, you retain the productivity features of the integrated server
for application development, such as implicit starting/stopping, automatic deployment, in-place
editing, and more.
You can configure WebLogic Server instances for development testing in the Run dialog box for
Application Properties (Tools > Application Properties >Run).

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 38

Oracle University and Egabi Solutions use only

Bind to an Oracle WebLogic Server instance:

Deployment Testing for Production

Copyright 2009, Oracle. All rights reserved.

Deployment Testing for Production


After you deploy the application, you can test it from the application server. To test run your
application, open a browser window and enter a URL:
For Oracle AS: http://<host>:port/<context root>/<page>
For Faces pages: http://<host>:port/<context root>/faces/<page>
Note: /faces has to be in the URL for Faces pages. This is because JDeveloper configures
your web.xml file to use the URL pattern of /faces to be associated with the Faces Servlet.
The Faces Servlet does its per-request processing, strips out the /faces part in the URL, then
forwards to the JSP. If you do not include the /faces in the URL, then the Faces Servlet is not
engaged (because the URL pattern doesnt match). Your JSP is run without the necessary JSF
per-request processing.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 39

Oracle University and Egabi Solutions use only

Use a URL for production testing:

In this lesson, you should have learned how to:


Create deployment profiles
Configure deployment options
Use JDeveloper to deploy an application
Use WebLogic Server administration console to deploy an
application
Use Ant to deploy an application
Test the deployed application

Copyright 2009, Oracle. All rights reserved.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 40

Oracle University and Egabi Solutions use only

Summary

This practice covers the following topics:


Creating deployment profiles
Using a WebLogic Server data source
Creating an application server connection
Deploying the application from JDeveloper
Deploying the application from the WLS console
Running the deployed application

Copyright 2009, Oracle. All rights reserved.

Practice Overview: Deploying the Web Application


In this practice, you create a deployment profile and configure deployment options for the
Storefront application that you have developed. You then configure a data source in the standalone Oracle WebLogic Server, and you configure the application to use a data source. Finally,
you deploy the application to the stand-alone Oracle WebLogic Server, and you test the
deployment.
This practice may be found in the Optional Practices section of Appendix A.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I B - 41

Oracle University and Egabi Solutions use only

Practice Overview:
Deploying the Web Application

Oracle University and Egabi Solutions use only


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

Oracle University and Egabi Solutions use only

Appendix C
Practices and Solutions

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

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


Practices for Lesson 2 ......................................................................................................... 6
Practice 2-1: Setting IDE Preferences............................................................................. 7
Practice 2-2: Creating a JDeveloper Application and Project ........................................ 9
Practice 2-3: Initializing the Project and Creating a Database Connection .................. 11
Practice 2-4: Examining the Course Application.......................................................... 13
Practices for Lesson 3 ....................................................................................................... 23
Practice 3-1: Creating Default Business Components .................................................. 24
Practice 3-2: Testing the Business Model..................................................................... 28
Practices for Lesson 4 ....................................................................................................... 30
Practice 4-1: Creating Read-Only View Objects .......................................................... 31
Practice 4-2: Creating Multiple Read-Only View Objects at Once.............................. 34
Practice 4-3: Creating Entity Objects Based on Database Views................................. 36
Practice 4-4: Creating Multiple Entity Objects at Once ............................................... 38
Practice 4-5: Creating Associations .............................................................................. 39
Practice 4-6: Creating Updatable View Objects ........................................................... 41
Practice 4-7: Refactoring Associations and Links ........................................................ 45
Practices for Lesson 5 ....................................................................................................... 47
Practice 5-1: Creating an Application Module to Display Categories.......................... 48
Practice 5-2: Creating an Application Module to Display the Shopping Cart.............. 49
Practices for Lesson 6 ....................................................................................................... 50
Practice 6-1: Defining Control Hints ............................................................................ 51
Practice 6-2: Declaratively Populating a Primary Key with a Database Sequence ...... 54
Practice 6-3: Designating History Columns ................................................................. 55
Practice 6-4: Creating and Using View Criteria ........................................................... 58
Practice 6-5: Creating Join View Objects..................................................................... 61
Practice 6-6: Creating LOVs......................................................................................... 65
Practices for Lesson 7 ....................................................................................................... 69
Practice 7-1: Adding Code to Entity Objects................................................................ 70
Practice 7-2: Programmatically Assigning a Database Sequence................................. 73
Practic0e 7-3: Populating History Columns When There Is No Logged-in User......... 76
Practice 7-4: Creating and Running a Test Client ........................................................ 79
Practice 7-5: Creating an Application Module Base Class........................................... 82
Practice 7-6: Editing an Application Module to Extend the New Base Class .............. 85
Practice 7-7: Adding and Exposing Service Methods .................................................. 86
Practice 7-8: Restrict the Shopping Cart Query............................................................ 89
Practices for Lesson 8 ....................................................................................................... 92
Practice 8-1: Adding Declarative Validation: List Validator ....................................... 93
Practice 8-2: Adding Declarative Validation: Unique Key Validator .......................... 96
Practice 8-3: Adding Programmatic Validation: Method Validator ............................. 98
Practice 8-4: Creating and Using a Domain for Validation........................................ 100
Practice 8-5: Testing the Validation ........................................................................... 102
Practices for Lesson 9 ..................................................................................................... 105
Practice 9-1: Discovering Application Problems........................................................ 106

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 2

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

Oracle University and Egabi Solutions use only

Table of Contents

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 3

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

Oracle University and Egabi Solutions use only

Practice 9-2: Setting Breakpoints in the Debugger..................................................... 107


Practice 9-3: Running the Application Module in Debug Mode ................................ 109
Practices for Lesson 10 ................................................................................................... 114
Practices for Lesson 11 ................................................................................................... 115
Practice 11-1: Creating Databound Pages................................................................... 116
Practice 11-2: Examining the Pages Data Bindings .................................................. 121
Practice 11-3: Adding an Additional Detail Table ..................................................... 124
Practice 11-4: Renaming a Page ................................................................................. 126
Practices for Lesson 12 ................................................................................................... 130
Practice 12-1: Creating an Unbounded Task Flow ..................................................... 131
Practice 12-2: Creating Bounded Task Flows ............................................................ 138
Practice 12-3: Extracting Part of a Task Flow ............................................................ 143
Practices for Lesson 13 ................................................................................................... 146
Practice 13-1: Creating a Table with Row Selection .................................................. 147
Practice 13-2: Creating a Search Page ........................................................................ 153
Practice 13-3: Creating a Read-Only Form ................................................................ 160
Practice 13-4: Creating a Sortable Table .................................................................... 162
Practice 13-5: Creating a Category Tree..................................................................... 165
Practice 13-6: Creating LOVs..................................................................................... 169
Practice 13-7: Setting Up the UI Project for Internationalization............................... 172
Practices for Lesson 14 ................................................................................................... 173
Practice 14-1: Creating Buttons for Navigation.......................................................... 174
Practice 14-2: Creating Links for Navigation............................................................. 179
Practice 14-3: Using Breadcrumbs ............................................................................. 188
Practice 14-4: Defining a Sequence of Steps.............................................................. 189
Practice 14-5: Simplifying and Enhancing a Task Flow ............................................ 196
Practices for Lesson 15 ................................................................................................... 200
Practice 15-1: Stretching Tables and Columns........................................................... 201
Practice 15-2: Adjusting JDevelopers Default Layout Components......................... 203
Practice 15-3: Adding Layout Components to Existing Pages................................... 205
Practice 15-4: Creating New Pages with Required Layout ........................................ 210
Practice 15-5: Setting Conditional Display................................................................. 219
Practice 15-6: Implement PPR to Coordinate Products Display with Selected
Subcategory................................................................................................................. 224
Practices for Lesson 16 ................................................................................................... 226
Practice 16-1: Converting Bounded Task Flows to Use Page Fragments .................. 227
Practice 16-2: Creating a Page Template and Applying It to Existing Pages............. 229
Practice 16-3: Creating a Page Template and Applying It to a New Page ................. 233
Practice 16-4: Using Bounded Task Flows as a Region on a Page ............................ 239
Practices for Lesson 17 ................................................................................................... 242
Practice 17-1: Conditional Rendering Based on Parameters ...................................... 243
Practice 17-2: Using Parameters for Dynamic Breadcrumbs ..................................... 249
Practice 17-3: Implementing the Add to Cart Functionality....................................... 251
Practice 17-4: Implementing Create Supplier Functionality (OPTIONAL)............... 254
Practices for Lesson 18 ................................................................................................... 258
Practice 18-1: Defining Task Flow Parameters .......................................................... 259
Practice 18-2: Creating a Helper Method to Evaluate EL .......................................... 261
Practice 18-3: Creating the Producer (Payload) Method ............................................ 264

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 4

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

Oracle University and Egabi Solutions use only

Practice 18-4: Initiating the Contextual Event............................................................ 267


Practice 18-5: Creating the Consumer (Handler) Method .......................................... 269
Practice 18-6: Mapping the Contextual Event ............................................................ 271
Practice 18-7: Passing Values Through Region Parameters....................................... 273
Practice 18-8: Modifying the JSF Life Cycle (Optional Exercise)............................. 275
Practices for Lesson 19 ................................................................................................... 277
Practice 19-1: Saving the Shopping Cart .................................................................... 278
Practice 19-2: Updating, Deleting, and Displaying Details of Shopping Cart Items . 279
Practice 19-3: ControllingTransactions in the Checkout Flow................................... 285
Practice 19-4: Adding CRUD Functionality for Suppliers (Optional Exercise)......... 286
Practices for Lesson 20 ................................................................................................... 289
Practice 20-1: Configuring the Application to Use ADF Security ............................. 290
Practice 20-2: Defining Users in the Identity Store .................................................... 293
Practice 20-3: Defining Roles..................................................................................... 294
Practice 20-4: Implementing Security on Task Flows and Pages............................... 296
Practice 20-5: Testing Application Authentication and Authorization....................... 298
Practice 20-6: Implementing Entity Object Security .................................................. 300
Practice 20-7: Testing Entity Object Security ............................................................ 302
Practice 20-8: Accessing Security Context Programmatically ................................... 303
Practice 20-9: Conditionally Displaying a Component Based on User Role ............. 305
Practice 20-10: Modifying the Hard-Coded User Name to Use the API.................... 308
Practices for Appendix A................................................................................................ 310
Practice A-1: Creating a Database Diagram with Existing Schema Objects.............. 311
Practice A-2: Adding New Schema Objects............................................................... 315
Practices for Appendix B ................................................................................................ 318
Practice B-1: Creating Deployment Profiles............................................................... 319
Practice B-2: Using a WebLogic Server Data Source ................................................ 321
Practice B-3: Creating an Application Server Connection ......................................... 325
Practice B-4: Deploying the Application from JDeveloper........................................ 326
Practice B-5: Deploying the Application from the WebLogic Server Administration
Console ....................................................................................................................... 328

Practices for Lesson 1

Oracle University and Egabi Solutions use only

There is no practice for lesson 1.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 5

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

Practices for Lesson 2

Oracle University and Egabi Solutions use only

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 Fusion Middleware 11g: Build Applications with ADF I C - 6

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.
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 on the right of its tab (the X is not visible
until you position the cursor over the tab.)
2) Set 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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 7

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

Oracle University and Egabi Solutions use only

c) In the Migrate User Settings dialog box, click No.

Practice 2-1: Setting IDE Preferences (continued)


Entity

entity

View Object

uiview

Application Module

module

d) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 8

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

Oracle University and Egabi Solutions use only

c) Select Packages in the list at the left and set the following values:

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:
ii) Enter oracle.fod.storefront as the application package prefix.
iii) Select Generic Application as the Application Template.

iv) Click Next.


c) In the Name your Generic project page of the wizard:
i) Enter StorefrontModel as the project name.
ii) 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.)
iii) Click Finish.
d) Notice that the Application Navigator displays your application and project.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 9

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

Oracle University and Egabi Solutions use only

i) Enter Storefront as the application name.

e) Also notice that the application overview page, Storefront.jws, 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.
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 ever want
to redisplay it, you can do so by right-clicking a project and selecting Show
Overview.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 10

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

Oracle University and Egabi Solutions use only

Practice 2-2: Creating a JDeveloper Application and Project


(continued)

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 needs.
1) Initialize the StorefrontModel project for business components. This requires a
database connection, so create that as part of this initialization.

b) In the Project Properties dialog box, select Business Components from the tree at
the left.
c) In the Business Components panel, select the Initialize Project for Business
Components check box.
d) Click Create a new database connection
field.

to the right of the Connection

e) In the Create Database Connection dialog box:


i)

Supply the information in the table below.


Connection Name

FOD

Connection Type

Oracle (JDBC)

Username

fodxx (where xx is the group number given by


your instructor if you are using a shared
database, or enter fod01 if using a local database)

Password

fusion

Deploy Password

Check the box

ii) 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.
iii) Click Test Connection. You should see that the Status box displays the word
Success!.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 11

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

Oracle University and Egabi Solutions use only

a) Double-click the StorefrontModel project (or right-click it and select Project


Properties).

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


Connection (continued)

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

h) Click Save All


to save your work. You should get into the habit of frequently
saving your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 12

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

Oracle University and Egabi Solutions use only

g) Click OK to set the project properties and dismiss the Project Properties dialog
box.

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.

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:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 13

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

Oracle University and Egabi Solutions use only

a) If there is no open application currently, you can click the Open Application link
in the Application Navigator

Practice 2-4: Examining the Course Application (continued)


i) Navigate to your courses \lab directory and open the StorefrontCompletedApp folder.

The application opens in the Application Navigator.


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. Select the Thumbnail tab, and then drag the
viewport rectangle so that the view activities are visible in the editor.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 14

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

Oracle University and Egabi Solutions use only

ii) Select Storefront-CompletedApp.jws and click Open.

Practice 2-4: Examining the Course Application (continued)


4) Examine the connection information and change if necessary to point to your
database.
a) Right-click the StorefrontModel project and select Project Properties. (You can
also double-click StorefrontModel to bring up 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).)
f) Click OK to dismiss the Project Properties Editor and save the settings.
5) To run the application, right-click the FODShoppingDashboard view and select
Run. Test the functionality of the shopping 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. Notice 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.

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 Fusion Middleware 11g: Build Applications with ADF I C - 15

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

Oracle University and Egabi Solutions use only

e) Test the connection, and if successful, click OK.

Practice 2-4: Examining the Course Application (continued)

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

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 16

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

Oracle University and Egabi Solutions 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.

Practice 2-4: Examining the Course Application (continued)

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 dismiss the pop-up window, and then click Checkout to begin the
checkout process.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 17

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

Oracle University and Egabi Solutions use only

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 to 2. Click Update to show the updated line total.

Practice 2-4: Examining the Course Application (continued)

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 18

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

Oracle University and Egabi Solutions use only

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

Practice 2-4: Examining the Course Application (continued)


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.

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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 19

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

Oracle University and Egabi Solutions use only

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.

Practice 2-4: Examining the Course Application (continued)

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.

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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 20

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

Oracle University and Egabi Solutions use only

c) The New Supplier page initially displays an error because the required field is
blank. Ignoring that error, enter any supplier name and select a supplier status
from the drop-down list, then click Save.

h) Close the browser when you are finished.


i) To make the application start a little faster the next time you run it, you can
undeploy the application:
i) Select View > Run Manager.
ii) In the Run Manager window, select the Storefront-CompletedApp
DefaultServer deployment 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.

j) The application is undeployed when the log window displays the message:
[Application Storefront-CompletedApp stopped and
undeployed from Server Instance DefaultServer].

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 21

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

Oracle University and Egabi Solutions use only

Practice 2-4: Examining the Course Application (continued)

Practice 2-4: Examining the Course Application (continued)


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.

Oracle University and Egabi Solutions use only

b) Select Remove Application from the IDE.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 22

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

Practices for Lesson 3


This exercise is to familiarize you with the default capabilities of JDeveloper and ADF
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, then you need to open
Storefront-03.jws, and edit the database information as described in step 4 of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 23

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

Oracle University and Egabi Solutions use only

In this practice, you create a business model 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.

Practice 3-1: Creating Default Business Components


In this practice, you create some default business components that comprise 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.

Oracle University and Egabi Solutions use only

d) Click OK.

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 into 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 24

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 (continued)

f) In a similar fashion, 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) Control-click to select the entities OrderEO and OrderItemEO.


c) Click Add

to move the selected items to the Selected list.

d) Rename the 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 25

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

Oracle University and Egabi Solutions use only

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

Practice 3-1: Creating Default Business Components (continued)

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.
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 Fusion Middleware 11g: Build Applications with ADF I C - 26

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

Oracle University and Egabi Solutions use only

e) Similarly, rename OrderItemVO to ShoppingCartItemVO.

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:

Notice 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 27

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

Oracle University and Egabi Solutions use only

Practice 3-1: Creating Default Business Components (continued)

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 navigation tab or panel to see the attributes. From this view,
you could double-click any of the attributes to open the Attribute Editor.

d) Click the Source tab at the bottom of the editor to view and examine the XML
source.
2) Test the default components by running the application module in the Business
Component Browser.
a) In the Application Navigator, right-click the application module (TestAM) in the
oracle.fod.storefront.test package and select Run.
b) In the Select Business Components Configuration dialog box, note that the
Connection name is FOD (the connection information is disabled) and click
Connect.
c) The Business Component Browser may take a few minutes to appear, and it may
come up behind other windows. You can click its icon
on the taskbar to
display it. The Browser should initially look similar to this (the objects may be in
a different order):

d) 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 28

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

Oracle University and Egabi Solutions use only

c) Each of the other panels (General, Validators, Java, and View Accessors) shows
different aspects of the OrderEO entity. Click and examine each panel.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 29

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

Oracle University and Egabi Solutions use only

Practice 3-2: Testing the Business Model (continued)

Practices for Lesson 4

Now you begin to create components that are more customized for your application. First
you determine the LOVs that your application needs, 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 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, then you need to 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
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 30

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

Oracle University and Egabi Solutions use only

In the last 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.

Practice 4-1: Creating Read-Only View Objects

Because these read-only view objects are based on SQL queries, you do not need 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, using a bind
variable for the LOOKUP_TYPE. Name the view object LookupCodeVVO. Create it in
the 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 choose


New from the context menu.
b) In the New Gallery, expand the Business Tier node in the Categories list and
choose ADF Business Components. Select View Object in the Items list and
click OK.
c) In the Name page of the Create View Object Wizard:
i) 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 the VO suffix that you used for the updatable view objects, and that you
are placing the read-only VOs in a separate package).
ii) Specify that the view object should have Read-only access through SQL
query.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 31

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

Oracle University and Egabi Solutions use only

Most of the view objects in your application are needed 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.

iii) Click Next.


d) In the Query page of the wizard:
i) Enter the query statement shown above (copy from LookupCodes.txt, or
you can click Query Builder to build the query if desired, but make sure that
the finished query is as shown above.)
ii) Click Test to verify that the query is valid.
iii) Click Next.
e) On the Bind Variables page of the wizard:
i) Click New.
ii) 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.
iii) Click Next.
f) Continue clicking Next until you reach the Application Module page:
i) Select the Application Module check box.
ii) Click Browse next to the Package field.
iii) Select the Hierarchy tab in the Package Browser and browse to and select the
oracle > fod > storefront > test package. Click OK.
iv) If the Name field is not automatically populated with TestAM:
(1) Click Browse next to the Name field.
(2) In the Select Parent dialog box, expand oracle > fod > storefront >
test.
(3) Select the TestAM application module to enable you to test the query.
v) Click Finish to create the view object. The Application Navigator should look
similar to the following screenshot:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 32

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

Oracle University and Egabi Solutions use only

Practice 4-1: Creating Read-Only View Objects (continued)

g) Save your work.


2) Test the query:
a) Run TestAM as you did previously.
b) In the Business Component Browser, double-click the LookupCodeV1 node.
c) In the Bind Variables dialog box, enter a Value of PAYMENT_TYPE_CODE and
click OK.
d) Navigate through the rows to see all the payment type codes. Notice that all fields
are disabled, because this view object is read-only.
to invoke the Bind Variables dialog box to
e) Click Edit Bind Parameters
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
CONTACT_METHOD_CODE
OWNER_TYPE_CODE
DISCOUNT_TYPE_CODE
PERSON_TYPE_CODE
GENDER_CODE
MARITAL_STATUS_CODE
VERIFICATION_METHOD_CODE
PAYMENT_TYPE_CODE

USAGE_TYPE_CODE
PRODUCT_STATUS_CODE
PERSON_TITLE_CODE
CARD_TYPE_CODE
MEMBERSHIP_TYPE_CODE
ORDER_STATUS_CODE
ID_TYPE_CODE
SUPPLIER_STATUS_CODE

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 33

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

Oracle University and Egabi Solutions use only

Practice 4-1: Creating Read-Only View Objects (continued)

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.

VO

Query Table or View

CountryVVO

COUNTRY_CODES

CustomerVVO

PERSONS

PaymentOptionVVO

PAYMENT_OPTIONS

ProductVVO

PRODUCTS

WarehouseVVO

WAREHOUSES

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 will need to start 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) Navigate to the Read-Only View Objects page of the wizard:
i) Set the package name to oracle.fod.storefront.view.
ii) Select your schema (FODxx) from the drop-down list.
iii) 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.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 34

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

Oracle University and Egabi Solutions use only

1) Create the following read-only view objects (note the VVO suffix) in the
oracle.fod.storefront.view package:

iv) Click Next.


c) On the Application Module page of the wizard, place the view objects in your
application module as you did before, 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 Fusion Middleware 11g: Build Applications with ADF I C - 35

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

Oracle University and Egabi Solutions use only

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


(continued)

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.

In this practice, you create several database view-based 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.
a) To invoke the Entity Object Wizard, you could use the New Gallery. However,
there is an even easier way to invoke the wizards:
i) In the Application Navigator, expand the StorefrontModel project.
ii) Expand the Application Sources and oracle.fod.storefront nodes.
iii) Right-click the entity node and select New Entity Object.

b) In the Name page of the Create Entity Object Wizard:


i) Ensure that oracle.fod.storefront.entity is the package name.
ii) Enter ProductCategoryEO as the entity object name.
iii) Ensure that the Database Schema Object option is selected and that the
database schema is FODxx (where xx is your group number).
iv) Click Browse to the right of the Schema Object field.
(1) In the Select Schema Object dialog box, select the Views object type
and deselect Tables.
(2) Click Query.
(3) In the list of schema objects, select PRODUCT_CATEGORIES.
Notice that you cannot multiselect more than one schema object,
because you are creating only one entity object with this wizard.
(4) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 36

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

Oracle University and Egabi Solutions use only

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.

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


(continued)
v) Click Next.
c) In the Attributes page, click Next to accept all columns. This wizard enables you
to remove or add attributes if needed.
d) In the Attribute Settings page:
i) Select CategoryId from the Select Attribute drop-down list.
ii) Select the Primary Key check box.

Oracle University and Egabi Solutions use only

iii) Click Finish to create your ProductCategoryEO entity object.

2) Optional step (if you choose not to create these objects, you can begin the
practices for the next lesson by opening the starter application): In a similar
fashion, 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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 37

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 dont need 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.
EO

Based on

AddressEO

ADDRESSES

AddressUsageEO

ADDRESS_USAGES

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 will need to start 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 choose New Business Components from Tables.
b) In the Entity Objects page of the Business Components from Tables Wizard,
check that the package name is oracle.fod.storefront.entity and the
schema is FODxx. 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 38

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

Oracle University and Egabi Solutions use only

1) Create the following entity objects that are based on tables:

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 need to create for the EOs that are based on
database views, and others that you need to create where there are no foreign keys. In this
practice, you create these additional associations.
1) Create an association that relates the CategoryId of the ProductCategoryEO entity
object to the ParentCategoryId of the same entity object. Name the association
ProductCategoriesSubProductCategoriesAssoc.
b) On the Name page of the Create Association Wizard:
i) Ensure that the package is oracle.fod.storefront.entity.
ii) Enter a name of ProductCategoriesSubProductCategoriesAssoc.
iii) Click Next.
c) On the Entity Objects page of the wizard:
i) Expand ProductCategoryEO in the Select Source Attribute list and select the
CategoryId attribute.
ii) Expand ProductCategoryEO in the Select Destination Attribute list and
select the ParentCategoryId attribute.
iii) Click Add, and then click Next.

d) On the Association Properties page of the wizard:


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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 39

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

Oracle University and Egabi Solutions use only

a) Right-click the oracle.fod.storefront.entity package and select New Association.

Practice 4-5: Creating Associations (continued)

Name

Source

Destination

OrdersOrderItemsAssoc

OrderEO.OrderId

OrderItemEO.OrderId

ProductCategoriesProductsAssoc

ProductCategoryEO.
CategoryId

ProductEO.CategoryId

3) Optional step (if you choose not to create this association, you must begin the
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. The entity package in the Application Navigator should now look
like this:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 40

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

Oracle University and Egabi Solutions use only

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):

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.

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.
a) In the Application Navigator, right-click the
oracle.fod.storefront.uiview package and select New View Object
from the context menu.
b) In the Name page of the Create View Object Wizard:
i) Ensure that the package is oracle.fod.storefront.uiview.
ii) Enter RootCategoryVO as the view object name.
iii) Select the Updatable access through entity objects option.
iv) Click Next.
c) In the Entity Objects page:
i) Expand the oracle.fod.storefront.entity package node.
ii) Shuttle ProductCategoryEO into the Selected pane.
iii) Click Next.
d) In the Attributes page:
i) Click Add All

to shuttle all attributes into the Selected pane.

ii) Click Next.


e) On the Attribute Settings page, click Next.
f) On the Query page:
i) Add the following WHERE clause:
ProductCategoryEO.PARENT_CATEGORY_ID IS NULL

ii) Click Test to ensure that the query is valid, and click OK to acknowledge the
message.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 41

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

Oracle University and Egabi Solutions use only

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 masterdetail relationship.

iii) Click Next.


g) Navigate through subsequent pages until you reach the Application Module page:
i) Add the view object to the TestAM application module as you have been
doing.
ii) Click Finish to create the updatable view object.
iii) In a similar fashion, create the SubCategoryVO view object based on the
same entity object, with all attributes. 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.
e) Click Add.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 42

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

Oracle University and Egabi Solutions use only

Practice 4-6: Creating Updatable View Objects (continued)

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 can begin the practices
for the next lesson by opening the starter application):
In a similar fashion, 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 that the RootCategory1 view object instance displays the data you expect
(only those categories without a ParentCategoryId.)
c) Check that the SubCategory1 view object instance displays the data you expect
(only those categories with a ParentCategoryId.)
d) Test that the RootCategoriesSubCategoriesLink displays the masterdetail
relationship between root categories and subcategories, similar to the following:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 43

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

Oracle University and Egabi Solutions use only

Practice 4-6: Creating Updatable View Objects (continued)

e) Close the Business Component Browser when you have finished testing.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 44

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

Oracle University and Egabi Solutions use only

Practice 4-6: Creating Updatable View Objects (continued)

Practice 4-7: Refactoring Associations and Links


If you inadvertently create objects in the wrong package, or if you want to reorganize
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.

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.
e) JDeveloper creates the assoc package and moves the associations into it. This
may take several minutes.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 45

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

Oracle University and Egabi Solutions use only

b) Right-click and select Refactor > Move.

2) In a similar fashion, move all view links into the package


oracle.fod.storefront.link. Refactor links in both the uiview and the view
packages.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 46

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

Oracle University and Egabi Solutions use only

Practice 4-7: Refactoring Associations and Links (continued)

Practices for Lesson 5

In the interest of time, you create only two of the five application modules that are
needed 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 need.
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, then
you need to open Storefront-05.jws, and edit the database information as
described in step 4 of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 47

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

Oracle University and Egabi Solutions use only

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.

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 the ProductCategoryEO and the view link that establishes a
masterdetail 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.

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.
c) On the Data Model page, expand oracle.fod.storefront.uiview and
RootCategoryVO.
d) Select RootCategoryVO and shuttle it to the Data Model.
e) With RootCategory1 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 Component Browser when
you have finished.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 48

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

Oracle University and Egabi Solutions use only

a) Right-click the oracle.fod.storefront package and select New Application


Module.

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.

b) On the Name page of the Create Application Module Wizard, enter the name
FODShoppingCartAM and click Next.
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 ShoppingCart1 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 Component 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 49

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

Oracle University and Egabi Solutions use only

a) Right-click the oracle.fod.storefront.module package and select New


Application Module.

Practices for Lesson 6


In this set of practices, you make declarative modifications to your business components.

This practice contains some optional steps that are similar to steps already done. If you
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 50

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

Oracle University and Egabi Solutions use only

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, then you need to open
Storefront-06.jws, and edit the database information as described in step 4 of
Practice 2-4.

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, double-click OrderEO to open it in the editor.

c) Select the OrderTotal attribute and click Edit


the attribute to open its editor.)

. (You could also double-click

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:
i) Click the ellipsis to the right of the Label Text field.
ii) In the Select Text Resource dialog box:
(1) 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.
(2) Enter the following in the Description field: Label for OrderTotal
attribute.
(3) Click Save and Select.
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 type in the hard-coded text.
g) Set appropriate tool tip text, using a resource bundle.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 51

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

Oracle University and Egabi Solutions use only

b) Select the Attributes navigation tab at the left of the editor.

h) Click OK to dismiss the attribute editor for OrderTotal.


i) Optional step: Using a resource bundle, enter appropriate Label and Tool tip
Text for OrderDate and OrderShippedDate. For example:

2) Optional step: In a similar fashion, 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) Look at the labels and formatting that you defined.
b) Position the cursor over OrderTotal, OrderDate, and OrderShippedDate to see the
tool tip text.
c) Close the Business Component Browser when you have finished.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 52

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

Oracle University and Egabi Solutions use only

Practice 6-1: Defining Control Hints (continued)

Oracle University and Egabi Solutions use only

Practice 6-1: Defining Control Hints (continued)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 53

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

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
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 navigation 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.

f) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 54

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

Oracle University and Egabi Solutions use only

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:

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.

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 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) In a similar fashion, 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 in
order 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.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 55

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

Oracle University and Egabi Solutions use only

In this practice, you modify three of the entity objects so that the history columns are
populated automatically.

Practice 6-3: Designating History Columns (continued)


2) Optional step (if you choose not to complete this step, you can begin the practices
for the next lesson by opening the starter application):
In a similar fashion, 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.
a) Run the TestAM application module.

c) Click Insert

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

e) Enter a SupplierName, such as ABC Plumbing, and a SupplierStatus, such as


ACTIVE.
f) Click Save

g) Ensure that the SupplierId is populated from the database sequence.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 56

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

Oracle University and Egabi Solutions use only

b) Double-click Supplier1.

Practice 6-3: Designating History Columns (continued)


5) Optional step (do this 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 > OrderItemsOrderFkLink1.
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.

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 Component Browser when you have finished.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 57

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

Oracle University and Egabi Solutions use only

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

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 the
CustomerId is equal to a bind variable named PersonId.
a) In the Application Navigator, double-click the PaymentOptionVVO view object
(in the oracle.fod.storefront.view package) to open it in the editor.

c) In the View Criteria section, click Add

d) In the Create View Criteria dialog box, select the Edit Query Criteria tab and
click Add Item.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 58

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

Oracle University and Egabi Solutions use only

b) Select the Query navigation tab at the left of the editor.

Practice 6-4: Creating and Using View Criteria (continued)


e) In the Criteria Item section of the Create View Criteria dialog box, select the
following values from the drop-down lists:
Value

Attribute

CustomerId

Operator

Equal to

Operand

Bind Variable

Parameter

Click New and define a variable named


PersonId of type Number

Usage

Optional

Oracle University and Egabi Solutions use only

List Name

f) Click OK to create the named query.


2) Test the query by applying the view criteria in the Business Component Browser,
using values 110, 114, 117, or 119 for the bind variable.
a) Run TestAM in the Business Component 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.
e) In the Bind Variables dialog box, enter a value of 110 and click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 59

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

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 Component Browser when you have finished testing.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 60

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

Oracle University and Egabi Solutions use only

Practice 6-4: Creating and Using View Criteria (continued)

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.

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.
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, double-click the ShoppingCartVO view object in
the oracle.fod.storefront.uiview package to open it in the editor.
b) Click the Entity Objects navigation tab at 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 61

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

Oracle University and Egabi Solutions use only

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.

e) Click the Attributes tab at the left of the editor.


f) Check to be sure that all the attributes from PersonEO have been added to the VO.
i) If they have not been added automatically, click Add from Entity to add
them.
ii) In the Attributes Editor, select PersonEO in the Available list and shuttle it to
the Selected listthis adds all of its attributes.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 62

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

Oracle University and Egabi Solutions use only

Practice 6-5: Creating Join View Objects (continued)

iii) Click OK.


2) Optional step (if you choose not to create these objects, you can begin the
practices for the next lesson by opening the starter application):
In a similar fashion 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.
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 Fusion Middleware 11g: Build Applications with ADF I C - 63

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

Oracle University and Egabi Solutions use only

Practice 6-5: Creating Join View Objects (continued)

3) Optional step (do this 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 navigation tab and delete the following attributes:
CreatedBy, CreationDate, LastUpdatedBy, LastUpdateDate, and
ObjectVersionId.
c) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 64

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

Oracle University and Egabi Solutions use only

Practice 6-5: Creating Join View Objects (continued)

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.

c) On the View Accessors panel, click Add

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 at the left of the editor.
c) Select the ProductId attribute.
d) Expand the List of Values section in the editor and click Add list of values

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 65

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

Oracle University and Egabi Solutions use only

b) Click the View Accessors tab at the left of the editor.

e) In the List of Values dialog box:


i) On the Configuration tab:
(1) Select OrderItemEO.ProductVVO1 as the List Data Source.
(2) Select ProductId as the List Attribute.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 66

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

Oracle University and Egabi Solutions use only

Practice 6-6: Creating LOVs (continued)

ii) On the UI Hints tab:


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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 67

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

Oracle University and Egabi Solutions use only

Practice 6-6: Creating LOVs (continued)

Practice 6-6: Creating LOVs (continued)


iii) Click OK.
3) Test the LOV.
a) Run the TestAM application module.

c) Change the product to some other product.


d) Double-click OrderItemsOrdersFkLink1 under ShoppingCart1.
e) Query for the same order that appears in the ShoppingCartItem1 window (order
1012 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 Component Browser.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 68

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

Oracle University and Egabi Solutions use only

b) Double-click the first-level ShoppingCartItem1. You should see that ProductId


appears as a drop-down list that shows the ProductId and ProductName.

Practices for Lesson 7


In this set of practices, you add programmatic functionality to your business components.

This practice contains some optional steps that are similar to steps already done. If you
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 69

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

Oracle University and Egabi Solutions 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, then
you need to open Storefront-07.jws, and edit the database information as
described in step 4 of Practice 2-4.

Practice 7-1: Adding Code to Entity Objects


In the application 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 first need to generate a Java class for the 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.

b) Click Edit

c) Select the Generate Entity Object Class check box and click OK.
d) Save your work.
2) Generate the 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):
/**
* 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 = (Number)row.getQuantity();
if (qty == null)
qty = new Number(1);
else
qty = qty.add(1);
row.setQuantity(qty);
} else {

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 70

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

Oracle University and Egabi Solutions use only

a) Open OrderItemEO in the editor and click the Java navigation tab.

Practice 7-1: Adding Code to Entity Objects (continued)


OrderItemEOImpl newItem =
(OrderItemEOImpl)orderItems.createRow();
EntityDefImpl productEODef =
EntityDefImpl.findDefObject("oracle.fod.storefront.entity.ProductEO"
);
EntityImpl productEO =
productEODef.findByPrimaryKey(getDBTransaction(),

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());
}

}
}

a) In a similar fashion, generate the entity object class for OrderEO.


b) Click the Entity Object Class link to open OrderEOImpl.java in the editor.

c) Notice that the Structure window shows the methods that are included in the class
(if the Structure window is not visiblethe default location is the lower left of the
IDEthen you can select View > Structure to open it.) You can see accessors
(getters and setters) for all of the OrderEO attributes. You can double-click any
method to navigate to it in the editor.
d) In the editor, scroll to the bottom of the file and just above the closing right brace
add the code shown above. You can copy the code from the
addItemToOrder.txt file in the \files subdirectory of your \labs
directory.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 71

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

Oracle University and Egabi Solutions use only

new Key(new
Object[] { productId }));
Number unitPrice = (Number)productEO.getAttribute("ListPrice");

Practice 7-1: Adding Code to Entity Objects (continued)


e) Press [Alt] + [Enter] if prompted to import oracle.jbo.TxnValException
and oracle.jbo.JboException.

Oracle University and Egabi Solutions use only

f) Right-click the editor and select Make from the context menu, then save your
work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 72

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 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.

1) Set the OrderItemEO to use a database sequence for the line item ID by
supplementing the initDefaults() method with the following code (ou can copy
the code from the 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 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 typing the method name to navigate to it, or use the scroll bar.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 73

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

Oracle University and Egabi Solutions use only

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.

Practice 7-2: Programmatically Assigning a Database Sequence


(continued)
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.

f) Right-click the method name initDefaults and then select the option Quick
JavaDoc from the context menu. JDeveloper displays an explanation of the
method.
g) Right-click the editor and select Make.
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 masterdetail window
for Orders and OrderItems.
c) Click Insert a new row
section).

in the bottom pane of the window (the OrderItems

d) Notice the row is created with a LineItemId value defaulted from the database
sequence ORDER_SEQ.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 74

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

Oracle University and Egabi Solutions use only

e) Press [Alt] + [Enter] when prompted to import


oracle.jbo.server.SequenceImpl.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 75

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

Oracle University and Egabi Solutions use only

Practice 7-2: Programmatically Assigning a Database Sequence


(continued)

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


Logged-in User
You previously designated some attributes as history columns in the OrderEO,
OrderItemE0O, 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.

1) In SupplierEO modify the CreatedBy and LastUpdatedBy columns as


follows:
a) Delete the anonymous default value.
b) 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):
In a similar fashion, 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 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; }

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 76

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

Oracle University and Egabi Solutions use only

In this practice, you add code to entity objects to automatically populate the CreatedBy
and LastUpdatedBy history columns.

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


Logged-in User (continued)
a) Open the Java class in the editor.
b) From either the main menu or the context menu, select Source > Override
Methods.

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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 77

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

Oracle University and Egabi Solutions use only

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

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


Logged-in User (continued)
5) Optional step (if you choose not to complete this step, you can begin the practices
for the next lesson by opening the starter application):
In a similar fashion, override the getHistoryContextForAttribute()
method with the same code in the entity object classes for OrderEO and
OrderItemEO.

Oracle University and Egabi Solutions use only

6) Run the TestAM application module and perform the same tests as you did in Step 4
of practice 6-3, 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 78

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 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:
i) Select General in the Categories list.
iii) Click OK.
c) In the Create Java Class dialog box:
i) Enter a name of StorefrontTest.
ii) Ensure that the Generate Default Constructor check box is not selected.
iii) Select the Generate Main Method check box, 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 type
bc4jclient, and press [Control] + [Enter].
3) Add code to print out the number of rows in the PaymentOption view object, to
execute the query on the PaymentOption view object, and to print out the 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";

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 79

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

Oracle University and Egabi Solutions use only

ii) Select Java Class in the Items list.

Practice 7-4: Creating and Running a Test Client (continued)


b) In the test client, change the line:
ViewObject vo = am.findViewObject("TestView");

to:
ViewObject vo = am.findViewObject("PaymentOptionV1");

c) After the line:


// Work with your appmodule and view object here

and above the line:

System.out.println("The table contains " +


vo.getEstimatedRowCount() + " rows:");
vo.executeQuery();
while (vo.hasNext()){
Row paymentOptionRow = vo.next();
System.out.println(" CustomerID: " +
paymentOptionRow.getAttribute("CustomerId") +
" Payment Type Code: " +
paymentOptionRow.getAttribute("PaymentTypeCode"));
}

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 Fusion Middleware 11g: Build Applications with ADF I C - 80

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

Oracle University and Egabi Solutions use only

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):

Oracle University and Egabi Solutions use only

Practice 7-4: Creating and Running a Test Client (continued)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 81

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 needs to 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.

1) Create a new Java Class named BaseApplicationModuleImpl in the


oracle.fod.storefront.module package, extending the default base
application module.
a) Right-click the oracle.fod.storefront.module package and select New.
b) In the New Gallery:
i) Select General in the Categories list.
ii) Select Java Class in the Items list.
iii) Click OK.
c) In the Create Java Class dialog box:
i) Enter a name of BaseApplicationModuleImpl.
ii) Ensure that the package name is set to
oracle.fod.storefront.module.
iii) Next to the Extends field, click Browse.
(1) In the Class Browser dialog box, select the Search tab and enter AMI
(uppercase) in the Match Class Name field, which displays a list of
matching classes.
(2) Select the ApplicationModuleImpl(oracle.jbo.server) class and click
OK.
iv) 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;

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 82

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

Oracle University and Egabi Solutions use only

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.

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.
b) In the Override Methods dialog box, select the check box next to the method
getUserPrincipalName():String and click OK (whereas in the Override Methods
dialog box, you can just start typing 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
*/

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 83

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

Oracle University and Egabi Solutions use only

Practice 7-5: Creating an Application Module Base Class


(continued)

Practice 7-5: Creating an Application Module Base Class


(continued)

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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 84

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

Oracle University and Egabi Solutions use only

if (mCurrentUser == null) {
String userPrincipal = "DRAPHEAL";
mCurrentUser = userPrincipal;
}
return mCurrentUser;

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.
d) In the Select Java options dialog box:
i) Select the Generate Application Module Class check box.
ii) Because you need to use the method in the BaseApplicationModuleAMImpl
class that you created earlier, this application module class must extend that
one, so click Classes Extend.
iii) In the Override Base Classes dialog box:
(1) Click Browse next to the Object field.
(2) In the Find Superclass dialog box, select the Search tab and enter BA
in the Match Class or Package Name field. This should populate
Matching Classes and Packages.
(3) Select the BaseApplicationModuleImpl class and click OK.
(4) Click OK again to dismiss the Override Base Classes dialog box.
e) Click OK to generate the application module class.
f) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 85

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

Oracle University and Egabi Solutions use only

c) Click Edit (pencil icon.)

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.

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 user
name 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.
cart.setAttribute("OrderDate",
((DBTransactionImpl)getDBTransaction()).getCurrentDbTime());
cart.setAttribute("OrderStatusCode", "CART");

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 86

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

Oracle University and Egabi Solutions use only

a) Expand the Data Controls panel and expand each of the FOD application
modules.

Practice 7-7: Adding and Exposing Service Methods (continued)


vo.insertRow(cart);
}

}
}

a) In the Application Navigator, expand FODShoppingCartAM and double-click


FODShoppingCartAMImpl.java to open it in the editor.

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 right brace in


FODShoppingCartAMImpl.java.
b) Press [Alt] + [Enter] when prompted to import oracle.jbo.ViewObject,
oracle.jbo.server.ViewRowImpl, and
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.
b) Edit FODShoppingCartAM and click the Java tab.
c) In the Client Interface section of the Java panel, click Edit

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 87

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

Oracle University and Egabi Solutions use only

b) Add the code shown above just before the closing right brace (press [Alt] +
[Enter] if prompted to import oracle.jbo.Row,
oracle.jbo.server.DBTransactionImpl, and
oracle.jbo.server.ApplicationModuleImpl):

Practice 7-7: Adding and Exposing Service Methods (continued)


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:
i) An FODShoppingCartAM interface
g) Examine the Data Controls panel again. You can now see the 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 88

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

Oracle University and Egabi Solutions use only

ii) An FODShoppingCartAMClient class that implements the interface

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) Open ShoppingCartVO in the editor.
c) Click Edit.
d) In the Edit Query dialog box:
i) 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

ii) Select Query > Bind Variables in the tree at the left.
iii) In the Bind Variables panel, click New.
iv) Enter a variable Name of CurrentUser and click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 89

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

Oracle University and Egabi Solutions use only

b) Click the Query tab.

Practice 7-8: Restrict the Shopping Cart Query (continued)


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.

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


d) Click Execute. The Result should be success.

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.
g) One record should be returned by the query: the status CART order for DRAPHEAL.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 90

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

Oracle University and Egabi Solutions use only

b) When the Business Component Browser comes up, right-click the


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

Oracle University and Egabi Solutions use only

Practice 7-8: Restrict the Shopping Cart Query (continued)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 91

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

Practices for Lesson 8

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, then
you need to open Storefront-08.jws, and edit the database information as
described in step 4 of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 92

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

Oracle University and Egabi Solutions use only

In this practice, you add several types of both declarative and programmatic validation to
entity objects.

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, right-click the OrderEO entity object and select
Open OrderEO from the context menu.

c) You can invoke the Add Validation Rule dialog box either from the Attribute
Editor, or 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:
i) With the OrderStatusCode attribute selected, click Edit. Then in the
Attribute Editor, select Validation in the tree at the left, and then click New.

ii) 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:


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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 93

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

Oracle University and Egabi Solutions use only

b) In the Entity Object Editor, select the Attributes node, and then select the
OrderStatusCode attribute.

Practice 8-1: Adding Declarative Validation: List Validator


(continued)
iii) 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.
iv) In the Enter SQL statement field, enter the following query:
select distinct lookup_code from lookup_codes
where lookup_type = 'ORDER_STATUS_CODE'

Oracle University and Egabi Solutions use only

v) Click Test to test the query. A message should inform you that the query is
valid; click OK to dismiss the message.

e) On the Failure Handling tab, check that 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 choose to do so, in the

interest of time, you can simply type in the text rather than clicking
to define a
text resource. If you choose this option, type You have entered an invalid
value in the Message Text field and skip to step (g) below.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 94

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

f) In the Select Text Resource dialog box:


i) In the DisplayValue field, enter: You have entered an invalid value
ii) In the Key field, enter: INVALID_VALUE
iii) In the Description field, enter: Error message for invalid value
iv) Click Save and Select.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 95

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

Oracle University and Egabi Solutions use only

Practice 8-1: Adding Declarative Validation: List Validator


(continued)

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.
b) In the Validators section, select Entity 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.)

c) In the Add Validation Rule dialog box:


i) Select UniqueKey from the Rule Type drop-down list.
ii) Select OrdersPk(ORDER_ID) in the Keys list.

iii) On the Failure Handling tab:


(1) Check that the Validation Failure Severity option button is set to
Error.
(2) As you did previously, 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
(or alternatively, simply type in the hard-coded Message Text.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 96

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

Oracle University and Egabi Solutions use only

a) In the Entity Object Editor for the OrderEO entity, select the Validators node.

iv) 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 test this validation after all validation is defined.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 97

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

Oracle University and Egabi Solutions use only

Practice 8-2: Adding Declarative Validation: Unique Key


Validator (continued)

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.

public boolean validateShippedDateAfterOrderDate(Date


ordershippeddate) {
return ordershippeddate == null ||
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:
i) Select Method in the Rule Type drop-down list.
ii) Ensure that the Create and Select Method check box is selected.
iii) For Method Name, enter the value
validateShippedDateAfterOrderDate

d) On the Failure Handling tab:


i) Check that the Validation Failure Severity option button is set to
Informational Warning.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 98

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

Oracle University and Egabi Solutions use only

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 may copy the code from the
ShippedDateAfterOrderDate.txt file in the \files subdirectory of your
\labs directory):

Practice 8-3: Adding Programmatic Validation: Method Validator


(continued)
ii) 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 may just type the message in
the Message Text field.

f) In the Application Navigator, 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 method
validateShippedDateAfterOrderDate to locate it in the editor.

h) Replace the method with the code above.


i) Right-click and select Make.
j) Save your work. You test this validation after all validation is defined.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 99

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

Oracle University and Egabi Solutions use only

e) Click OK to save your validation definition and OK again to dismiss the


Attribute Editor if you used it to invoke the Add Validation Rule dialog box.

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 that is 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:
ii) Set the Name to PhoneNumber.
iii) Ensure that the Domain for an Oracle Object Type check box is not
selected.
iv) Click Next.
c) On the Settings page of the wizard:
i) Select String from the Type drop-down list.
ii) Click Next, then 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 may 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);
}

g) Press [Alt] + [Enter] when prompted to accept the import of


oracle.jbo.domain.DataCreationException.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 100

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

Oracle University and Egabi Solutions use only

i) Set the package name to oracle.fod.storefront.domain.

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


(continued)

2) Apply the domain to the PhoneNumber attribute of SupplierEO.


a) Open SupplierEO in the editor.
b) Select the Attributes tab.
c) Select the PhoneNumber attribute and click Edit (or simply double-click the
attribute.)
d) In the Edit Attribute dialog box:
i) Select Entity Attribute in the list at the left.
ii) From the Type drop-down list, select
oracle.fod.storefront.domain.common.PhoneNumber.

iii) Click OK.


3) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 101

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

Oracle University and Egabi Solutions use only

h) Right-click and select Make. Save your work.

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.
c) When the Business Component Browser comes up, 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 click Cancel to 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 typing in 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 102

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

Oracle University and Egabi Solutions use only

b) Click Connect to establish the connection.

Practice 8-5: Testing the Validation (continued)

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 typed in hard-coded message text rather than defining a text
resource.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 103

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

Oracle University and Egabi Solutions use only

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

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 Component 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) Click Connect to establish the connection.
c) When the Business Component Browser comes up, 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 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 Component Browser when you have finished.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 104

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

Oracle University and Egabi Solutions use only

Practice 8-5: Testing the Validation (continued)

Practices for Lesson 9

Note: This practice is optional, and does not affect subsequent practices. Do this
practice only if you have extra time.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 105

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

Oracle University and Egabi Solutions use only

Most of the techniques for troubleshooting are used mainly for debugging a user
interface. However, you can run the JDeveloper debugger with the Business Component
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 features of the JDeveloper
debugger.

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, then display the shopping cart.

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) Modify the connection to point to your schema and edit the database information
as described in step 4 of Practice 2-4.
d) Run FODShoppingCartAM.
e) Initialize the shopping cart:
i) In the Business Component Browser, double-click FODShoppingCartAM.
ii) Select init from the Method drop-down list.
iii) Click Execute to execute the init method.
f) Display the shopping cart:
i) Double-click ShoppingCart1.
ii) In the Bind Variables dialog box, click Cancel so that the value that was set
by the init() method is used.
iii) The cart does not display a users order, as expected, but instead displays a
blank (except for default values) new record.
g) Close the Business Component Browser.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 106

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

Oracle University and Egabi Solutions use only

a) From the JDeveloper application menu, select Open Application.

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
Component 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.

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, select BaseApplicationModuleImpl.java.
b) In the Structure window, right-click mCurrentUser:String and select Create
Watchpoint.
3) View all of the breakpoints that are set on the application.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 107

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

Oracle University and Egabi Solutions use only

b) In the Structure window, right-click init():void and select Go to Source.

Practice 9-2: Setting Breakpoints in the Debugger (continued)

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.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 108

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

Oracle University and Egabi Solutions use only

a) From the JDeveloper main menu, select View > Debugger > Breakpoints (or use
the shortcut key combination [Ctrl] + [Shift] +[R].)

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 utilize some of the features of the JDeveloper debugger.
1) Run FODShoppingCartAM in debug mode.

b) Before the Business Component Browser comes up, the debugger is invoked in
the JDeveloper IDE. Examine the information in the IDE.
i) 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.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 109

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

Oracle University and Egabi Solutions use only

a) In the Application Navigator, right-click FODShoppingCartAM and select


Debug.

c) Step through the code and use debugger features to figure out the problem.
i) Click Step Into on the JDeveloper toolbar. You can see the pointer move
to the next executable line of code in the editor window.
ii) In either the Data or the Smart Data panel of the debugger, expand this. Note
that the value of mCurrentUser is null. 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.

on the toolbar to continue execution until the next time a


iii) Click Resume
breakpoint is encountered. No breakpoint is encountered, so the Business
Component Browser comes up.
iv) Now set up the shopping cart as you have 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. Control
passes to the debugger again, so click back into JDeveloper.
v) 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 110

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

Oracle University and Egabi Solutions use only

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


(continued)

vi) 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 dont
have the source, just click Step Over
to advance to the next line of code in
this classeverything still executes, but you just dont step into the called
classes. Note: Be sure to click Step Over and not Step To End of Method,
whose icon looks similar.
vii) 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.
viii) 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.)
ix) On the Smart Data tab, right-click user and select Watch.

The Watches tab now shows both the this.mCurrentUser and user
variables so that you can easily track their values.
x) 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 111

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

Oracle University and Egabi Solutions use only

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


(continued)

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


(continued)
xi) 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.
xii) Click the Smart Data tab and notice that the value of userPrincipal is
"DRAPHAEL" this user name is misspelled.

xiv) 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.

xv) Click Step Into (you may have to click it twice.) On the Watches tab, you
should see that mCurrentUser now has the value DRAPHEAL, the correct
spelling.
xvi) Click Step Out to execute the remaining lines of code in this method and
return to the FODShoppingCartImpl class.
xvii) Click the Watches tab, and then click Step Into
value DRAPHEAL being assigned to user.

-- you should see the

four times until the pointer is at the line of code that


xviii) Click Step Over
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.
xix) Click the Smart Data tab and expand vo > mViewRowSet, then place
mWhereParams on your watch list.
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 112

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

Oracle University and Egabi Solutions use only

xiii) In the Smart Data panel, right-click the userPrincipal variable and select
Modify Value.

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


(continued)
xx) 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.

So 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 113

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

Oracle University and Egabi Solutions use only

xxi) Click Resume , and then in the Business Component Browser doubleclick ShoppingCart1. Click Cancel in the Bind Variables dialog box so that
the value set by the init method is used. You should see the correct record
now appear.

Practices for Lesson 10

Oracle University and Egabi Solutions use only

There is no practice for this lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 114

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

Practices for Lesson 11


In this set of practices, you create a databound JSF page. You then examine the data
bindings and manipulate the data binding files.

Oracle University and Egabi Solutions use only

Even if you successfully completed all sections of previous practices, do not continue
working in the same project, because there was not time to create all of the elements
needed for the UI. You need to open Storefront-11.jws, and then edit the database
information as described in step 4 of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 115

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.
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 could right-click

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:
i) Enter a file name of Products.
ii) To the Directory path, add \oracle\storefront\ui\pages.
iii) 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 116

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

Oracle University and Egabi Solutions use only

StorefrontUI and select New from the context menu, or you could click New
in the toolbar.)

Practice 11-1: Creating Databound Pages (continued)

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 you dont 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.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 117

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

Oracle University and Egabi Solutions use only

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


Master Table, Detail Table from the Create menu.

Practice 11-1: Creating Databound Pages (continued)


b) Delete the columns you dont 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 reoder 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.

arrow to move it to the top of


CategoryDescription) and then click the Top
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 checked in the Enable ADF Behavior section at
the top of the window, and then click OK to apply the changes.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 118

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

Oracle University and Egabi Solutions use only

NOTE: Although this short list of attributes is easy to reorder, a quick way to
reorder attributes is to select the one you want last in the list (in this case,

Practice 11-1: Creating Databound Pages (continued)

4) Test the page.


a) If the Products.jspx page is still 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 you run a page
because the server is already started.
c) Select one of the Categories and notice that the SubCategories change to reflect
the selected row. Select another category and notice the change. You may have to
scroll down to see the SubCategories.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 119

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

Oracle University and Egabi Solutions use only

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:

Practice 11-1: Creating Databound Pages (continued)

Notice 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 120

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

Oracle University and Egabi Solutions use only

The page should look similar to the following screenshot, in which some of
the extra white space has been cut out:

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) Notice the difference in the way the table columns appear in the JDeveloper editor
and the way they appear at run time.
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.bindings.CategoryName.inputValue}
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, open the ProductCategoryEO entity object and edit the CategoryName
attribute. Where does the Category Name label in the UI come from?
__________________________________________________________________
__________________________________________________________________
Answer: Category Name comes from the entity object attributes control hints
for Label.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 121

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

Oracle University and Egabi Solutions use only

__________________________________________________________________

Practice 11-2: Examining the Pages Data Bindings (continued)


6) At run time, what appears in the browser for the first columns values? Where do
these values come from?
__________________________________________________________________
__________________________________________________________________

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.)
__________________________________________________________________
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 on
the Overview page for the data binding registry file.
__________________________________________________________________
Answer: The file is created the first time you bind a UI component to data in the
application.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 122

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

Oracle University and Egabi Solutions use only

Answer: Office, Electronics, and Media are the category names in the
rowset; they are the input values for the category names in the rows.

Practice 11-2: Examining the Pages Data Bindings (continued)


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?
__________________________________________________________________
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 Fusion Middleware 11g: Build Applications with ADF I C - 123

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

Oracle University and Egabi Solutions use only

__________________________________________________________________

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) If the Products.jspx page is still open, click its tab, or reopen it in the editor.
2) In the Data Controls panel, expand FODProductAMDataControl >
BrowseCategory1 > BrowseSubCategory1.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 124

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

Oracle University and Egabi Solutions use only

3) Drag the BrowseSubCategory1 > BrowseProduct1 data control to the af:form node
in the Structure window.

7) 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.
a) You should notice 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 are finished and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 125

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

Oracle University and Egabi Solutions use only

Practice 11-3: Adding an Additional Detail Table (continued)

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 need to do to reestablish data binding in a renamed page.
1) Rename the Products page to ProductCatalog.
a) Shut down JDeveloper, saving any unsaved work and terminating any running
processes if prompted.
c) In the StorefrontUI\public-html\oracle\storefront\ui\pages
directory, change the name of Products.jspx to ProductCatalog.jspx.
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 are 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 126

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

Oracle University and Egabi Solutions use only

b) Open Windows Explorer and navigate to your application directory.

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 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 127

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

Oracle University and Egabi Solutions use only

Practice 11-4: Renaming a Page (continued)

Practice 11-4: Renaming a Page (continued)


d) Reopen JDeveloper.
e) In the Application Navigator, navigate to StorefrontUI > Application Sources >
oracle.storefront.ui > pages and select ProductCatalogPageDef.xml.
f) In the Structure window, right-click the ProductsPageDef node and select
Refactor > Rename.

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 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 path from ProductsPageDef to
ProductCatalogPageDef.

j) Save your work and then retest the page.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 128

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

Oracle University and Egabi Solutions use only

g) In the Rename dialog box, change ProductsPageDef to


ProductCatalogPageDef.

Practice 11-4: Renaming a Page (continued)


k) Although it is not necessary, if you also want to change the page mapping usageId
and the page definition usages id, you need to 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:
i) Select the Source tab of the Databindings.cpx editor.

iii) 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.

iv) If desired, retest the page.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 129

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

Oracle University and Egabi Solutions use only

ii) In the <pageMap><page> section, change the 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.

Practices for Lesson 12


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.

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, then you need to 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
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 130

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

Oracle University and Egabi Solutions use only

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.

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.

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 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 131

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

Oracle University and Egabi Solutions use only

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.

Practice 12-1: Creating an Unbounded Task Flow (continued)

2) Create two additional view activities in the unbounded task flow named
ProductSearch and ProductDetails.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 132

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

Oracle University and Egabi Solutions use only

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.

Practice 12-1: Creating an Unbounded Task Flow (continued)

Oracle University and Egabi Solutions use only

a) In the Component Palette, ensure that ADF Task Flow is selected in the dropdown list at the top. Expand the Components category and drag a View activity
to the editor.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 133

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 (continued)

c) In a similar fashion, add another view activity named ProductDetails.

Notice the yellow warning symbol on the view activities that you just created.
This means that they do not yet point to pages.
3) Add a Control Flow Case from ProductSearch to ProductDetails and name it detail.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 134

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

Oracle University and Egabi Solutions use only

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.

Practice 12-1: Creating an Unbounded Task Flow (continued)


a) Click Control Flow Case in the Component Palette.

c) Enter detail as the name of the case. You can type directly on the diagram, or
it may be easier to use the Property Inspector and enter the name as the fromoutcome of the control flow case.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 135

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

Oracle University and Egabi Solutions use only

b) Click inside ProductSearch and then click inside ProductDetails.

Practice 12-1: Creating an Unbounded Task Flow (continued)

5) Add a Control Flow Case from ProductCatalog to ProductSearch and name it


search. You can move the view activities to make the diagram look better. For
example, you could arrange the view activities as shown:

6) Add a control flow case named detail from ProductCatalog to ProductDetails.


7) Add a control flow case named shop from ProductDetails to ProductCatalog.
8) Create a fourth View activity named ProductCategory. The page is to display a
category tree for user navigation.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 136

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

Oracle University and Egabi Solutions use only

4) In the same way, add a Control Flow Case from ProductDetails to ProductSearch
and name it search.

Practice 12-1: Creating an Unbounded Task Flow (continued)

10) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 137

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

Oracle University and Egabi Solutions use only

9) 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.

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.

d) In the Create Task Flow dialog box:


i) Set File Name to ShoppingCartFlow.
ii) To the directory path, add \oracle\storefront\ui\flow. This is the
path you should use for all task flows.
iii) Ensure that Create as Bounded Task Flow is selected.
iv) Ensure that Create with Page Fragments is not selected.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 138

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

Oracle University and Egabi Solutions use only

c) In the Items list, select ADF Task Flow and click OK.

Practice 12-2: Creating Bounded Task Flows (continued)

e) Notice that the newly created task flow appears in the Application Navigator in
two places, both under WEB-INF and under Page Flows.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 139

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

Oracle University and Egabi Solutions use only

v) Click OK.

Practice 12-2: Creating Bounded Task Flows (continued)

Notice 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.

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 Fusion Middleware 11g: Build Applications with ADF I C - 140

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

Oracle University and Egabi Solutions use only

f) The Shopping Cart flow opens in the editor. Add a view activity and name it
ShoppingCart.

Practice 12-2: Creating Bounded Task Flows (continued)

j) In a similar fashion, add another task flow return activity called Checkout, with a
control flow case named checkout from ShoppingCart to it and with an outcome
also named checkout.

k) 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):
In a similar fashion, create additional bounded task flows, being sure to create them in
the \oracle\storefront\ui\flow subdirectory and not 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) ManageSupplierFlow with:
i) A view activity named SupplierUpdate that is the default activity
ii) A task flow return activity named Save whose outcome is named done

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 141

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

Oracle University and Egabi Solutions use only

i) Add a Control Flow Case from ShoppingCart to the Shop task flow return
activity and name it too as shop.

Practice 12-2: Creating Bounded Task Flows (continued)


iii) A task flow return activity named Cancel whose outcome is also named
done

iv) A wildcard control flow rule

From

To

Name

SupplierUpdate
Wildcard

Save
Cancel

save
cancel

b) ShowSuppliersFlow with one view activity named BrowseSuppliers

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 142

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

Oracle University and Egabi Solutions use only

v) Control flow cases between the activities:

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 unbounded task flow adfc-config.xml.
ii) Expand either the WEB-INF or the PageFlows node.
iii) Double-click adfc-config.xml to open it in the editor.
b) In the editor, drag a rectangle to encompass the ProductSearch, ProductDetails,
and ProductCatalog view activities, with their control flows.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 143

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

Oracle University and Egabi Solutions use only

i) In the Application Navigator, expand StorefrontUI and WebContent.

Practice 12-3: Extracting Part of a Task Flow (continued)

d) 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 Fusion Middleware 11g: Build Applications with ADF I C - 144

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

Oracle University and Egabi Solutions use only

c) Right-click one of the selected objects and select Extract Task Flow.

Practice 12-3: Extracting Part of a Task Flow (continued)

f) Right-click the ProductCatalog view activity and select Mark Activity >
Default Activity.

The ProductCatalog activity is now surrounded with a green halo indicating


that it is the default activity, or entry point, for the task flow.
g) 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. This is not needed, so
you can just delete it from the adfc-config task flow.
i) Open or switch to adfc-config.xml.
ii) In the visual editor, right-click the ShoppingFlow activity and select Delete,
or you can delete task-flow-call-ShoppingFlow in the Structure window.
h) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 145

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

Oracle University and Egabi Solutions use only

e) In the editor, arrange the ShoppingFlow activities in a visually pleasing manner,


such as shown below:

Practices for Lesson 13

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, then
you need to open Storefront-13.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
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 146

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

Oracle University and Egabi Solutions use only

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.

Practice 13-1: Creating a Table with Row Selection


In this practice, you create the Shopping Cart page. This page displays 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.

d) Leave the file name as ShoppingCart.jspx.


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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 147

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

Oracle University and Egabi Solutions use only

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.)

Practice 13-1: Creating a Table with Row Selection (continued)

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 148

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

Oracle University and Egabi Solutions use only

a) The ShoppingCart page opens in the editor. From the Data Controls panel, drag
FODShoppingCartAMDataControl > ShoppingCart1 > ShoppingCartItem1
to the page as an ADF Read-only table.

Practice 13-1: Creating a Table with Row Selection (continued)


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.
a) Right-click the editor for the ShoppingCart page and select Run.
b) In the Confirm Run JSF JSP dialog box, click Yes.

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 utilizing 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 doesnt show any data. The ShoppingCart is tied to specific
user; however, you havent yet told it what user.
d) Close the browser 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 user name for the shopping cart. Hint:
This involves adding a method action binding and an invoke action binding to the
page definition.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 149

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

Oracle University and Egabi Solutions use only

3) Test the page.

Practice 13-1: Creating a Table with Row Selection (continued)


a) Click the Bindings tab in the editor for the Shopping Cart page.
b) Add a Method Action binding to the init() method in the
FODShoppingCartAMDataControl:

ii) In the Insert Item dialog box, select methodAction and click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 150

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

Oracle University and Egabi Solutions use only

i) In the Bindings section, click Add.

Practice 13-1: Creating a Table with Row Selection (continued)

c) Add an InvokeAction to the executables that runs init(). Name it


invokeInit and set the Refresh property to ifNeeded. Make sure it is the first
executable so that it runs before the iterator.
i) In the Executables section, click Add.

ii) In the Insert Item dialog box, select invokeAction and then click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 151

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

Oracle University and Egabi Solutions use only

iii) In the Create Action Binding dialog box, select


FODShoppingCartAMDataControl, choose init() from the Operations
drop-down list, and then click OK.

Practice 13-1: Creating a Table with Row Selection (continued)

iv) In the Property Inspector, set Refresh to ifNeeded.


v) In the Executables panel, drag the invokeInit executable to the top position,
so that the init() method is invoked prior to the iterator.
d) 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 and undeploy the application as described in step 6(i) of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 152

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

Oracle University and Egabi Solutions use only

iii) In the Insert invokeAction dialog box:


Enter an id of invokeInit, select init from the Binds drop-down list, and
click OK.

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.

d) Leave the file name as ProductSearch.jspx.


e) To the Directory path, append \oracle\storefront\ui\pages, and then
click OK.

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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 153

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

Oracle University and Egabi Solutions use only

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).

Practice 13-2: Creating a Search Page (continued)

b) In the Edit Table Columns dialog box:


i) Enable Row Selection.
ii) Include only the following four attributes in this order:
ProductName
CategoryName
ListPrice
Description

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 154

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

Oracle University and Egabi Solutions use only

a) The ProductSearch page opens in the editor. Drag FODProductAMDataControl


> BrowseProduct > Named Criteria > SearchByName to the page in the editor
and select QueryADF Query Panel with Table from the context menu.

Practice 13-2: Creating a Search Page (continued)

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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 155

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

Oracle University and Egabi Solutions use only

iii) Click OK. The page should look similar to the following:

Practice 13-2: Creating a Search Page (continued)

Notice that the table does not fill up the page. You must scroll to see all of 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.
i) Enter a percent sign (%) in the ProductName field and click Search. All of the
products appear.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 156

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

Oracle University and Egabi Solutions use only

b) The page runs and looks similar to the following:

ii) Resize columns in the table by dragging the lines between the column
headers.
iii) Reorder columns in the table by dragging column headers.
iv) Click Advanced to enable more search options.
v) Select Contains from the operators drop-down list.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 157

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

Oracle University and Egabi Solutions use only

Practice 13-2: Creating a Search Page (continued)

Practice 13-2: Creating a Search Page (continued)

vii) 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.

viii) Select Price from the Add Fields drop-down list.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 158

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

Oracle University and Egabi Solutions use only

vi) Enter Pla in the ProductName search field and click Search. Notice that the
table displays products that contain Pla.

ix) 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.

x) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 159

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

Oracle University and Egabi Solutions use only

Practice 13-2: Creating a Search Page (continued)

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.

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, including product name, category name, and list price.
a) Drag the Data Control FODProductAMDataControlBrowseProduct to the
visual editor and select FormsADF Read-only form from the context menu.

b) In the Edit Form Fields dialog box:


i) Include only the following fields in order:
ProductName
CategoryName
ListPrice

Note: Select and remove the other attributes by clicking the X icon. The
attributes can be reordered by selecting an attribute and using the up and
down arrows as required.
ii) Do not include Submit Button or Navigation Controls.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 160

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

Oracle University and Egabi Solutions use only

b) Double-click the ProductDetails view activity, or right-click it and select Create


Page.

Practice 13-3: Creating a Read-Only Form (continued)

The page should look similar to the following:

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:

4) When you have finished, close the browser and undeploy the application as described
in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 161

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

Oracle University and Egabi Solutions use only

iii) Click OK.

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
can begin the practices for the next lesson by opening the starter application.
1) Create the BrowseSuppliers page on the ShowSuppliersFlow.
a) From the Application Navigator, open the ShowSuppliersFlow.

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 be able to select a row.
a) Create an ADF Read-only Table on the page from
FODSupplierAMDataControl Supplier1.

b) Use only the first five attributes.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 162

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

Oracle University and Egabi Solutions use only

b) Open the BrowseSuppliers page, being sure to create it in your


\oracle\storefront\ui\pages directory.

Practice 13-4: Creating a Sortable Table (continued)

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 Fusion Middleware 11g: Build Applications with ADF I C - 163

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

Oracle University and Egabi Solutions use only

c) Enable Row Selection and Sorting.

Practice 13-4: Creating a Sortable Table (continued)

c) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 164

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

Oracle University and Egabi Solutions use only

b) Test that you are able to sort columns and select rows.

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.

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 Trees > ADF Tree.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 165

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

Oracle University and Egabi Solutions use only

b) Either double-click the ProductCategory view, or right-click it and select Create


Page.

Practice 13-5: Creating a Category Tree (continued)

c) Select the oracle.fod.storefront.uiview.RootCategoryVO(<SubCategory>) tree


level rule. Shuttle CategoryName from the Available Attributes list to the
Display Attributes list, and remove Category Description from the Display
Attributes list.
d) Select the oracle.fod.storefront.uiview.BrowseSubCategoryVO tree-level rule.
Shuttle CategoryName from the Available Attributes list to the Display
Attributes list, and remove Category Description from the Display Attributes list.
e) Click OK to create the binding.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 166

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

Oracle University and Egabi Solutions use only

b) In the Edit Tree Binding dialog box, select SubCategory from the Add Rule
(green plus) drop-down list.

Practice 13-5: Creating a Category Tree (continued)

f) The page should look similar to the following:

3) Convert the output text to a command link.


a) In the ProductCategory page, select af:outputText in either the Structure
window or the visual editor (you need to keep expanding the af:tree node all
the way to find af:outputText).
b) Right-click af:outputText and select Convert.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 167

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

Oracle University and Egabi Solutions use only

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.

Practice 13-5: Creating a Category Tree (continued)


c) Select ADF Faces from the drop-down list at the top and then select Link in the
items section.
d) Click OK. You will get a Confirm Convert dialog box informing that the Value
attribute will be removed. Click OK to continue.
e) In the Properties Inspector, set the Text to #{node} (you can use Expression
Builder and select the expression from JSP Objects.)
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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 168

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

Oracle University and Egabi Solutions use only

4) Test the ProductCategory page.

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 the 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.
e) Select the SupplierStatus attribute.
f) In the List of Values section in the lower portion of the editor, select
LOV_SupplierStatus and click Edit.
g) In the List of Values editor:
i) 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.
ii) Click the UI Hints tab, where you can see that the attribute should appear as a
Choice List containing the LookupCode and Description.
iii) 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.
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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 169

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

Oracle University and Egabi Solutions use only

d) Click the Attributes tab.

Practice 13-6: Creating LOVs (continued)


2) In the ManageSupplierFlow task flow, create the SupplierUpdate page, using an
LOV for the SupplierStatus attribute. Place this page in a \supplier subdirectory of
the one 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.

c) Drag the data control FODSupplierAMDataControl Supplier1 to the page


and create an ADF Form, using only the following fields:
SupplierName
SupplierStatus
PhoneNumber
Email

Do not include Navigation Controls or a Submit Button.


Notice 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 could change the setting here, it is better to let
the model determine the list type.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 170

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

Oracle University and Egabi Solutions use only

b) Create the SupplierUpdate page, placing it in a supplier subdirectory of


oracle\storefront\ui\pages.

Practice 13-6: Creating LOVs (continued)

d) Test the page by running it directly. The page should look similar to the following
with the list of values dropped down:

e) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 171

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

Oracle University and Egabi Solutions use only

The page should look something like the following:

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 type 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.

b) In the list at the left of the Project Properties editor, choose Resource Bundle.
Make sure the Resource Bundle Type property is set to Properties Bundle and
select the One Bundle Per Project option. Set the Default Project Bundle Name
to oracle.storefront.ui.StorefrontUIBundle.

c) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 172

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

Oracle University and Egabi Solutions use only

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.

Practices for Lesson 14


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.

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, then
you need to 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
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 173

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

Oracle University and Egabi Solutions use only

In this set of practices, you implement navigation on pages by creating buttons, links,
breadcrumbs, and a train.

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.

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.)
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 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:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 174

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

Oracle University and Egabi Solutions use only

1) The ManageSupplierFlow task flow has a global control flow rule whose fromoutcome 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.

Practice 14-1: Creating Buttons for Navigation (continued)

(Alternatively, you could right-click the button in the editor or in the Structure
window and select Select Text Resource for > Text from the context menu.)
e) In the Select Text Resource dialog box:
i) Ensure that StorefrontUIBundle is the selected resource bundle.
ii) Enter a Display Value of Cancel, which populates the Key value with
CANCEL.
iii) Enter a Description of Label for the Cancel button.
iv) Click Save and Select.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 175

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

Oracle University and Egabi Solutions use only

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.

Practice 14-1: Creating Buttons for Navigation (continued)

g) Select the button and in the Property Inspector click the drop-down arrow at the
end of the Action property and select cancel from the drop-down list.

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 Fusion Middleware 11g: Build Applications with ADF I C - 176

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

Oracle University and Egabi Solutions 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}.

Practice 14-1: Creating Buttons for Navigation (continued)

3) In a similar fashion, add a button labeled Search to the ProductCatalog page in the
ShoppingFlow task flow. Set the Action to search.
4) Optional step (if you choose not to create these buttons, you can 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 existing
text resource)

search

ShoppingFlow

ProductDetails

Shop

shop

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 177

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

Oracle University and Egabi Solutions 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.

Practice 14-1: Creating Buttons for Navigation (continued)


ShoppingCartFlow

ShoppingCart

Shop (use the


existing text
resource)

shop

ShoppingCartFlow

ShoppingCart

Checkout

checkout

Save your work.


a) In the Application Navigator, expand StorefrontUI > Application Sources >
oracle.storefront.ui.
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):

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 type
in the strings as hard-coded text.
d) Close all editor windows.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 178

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

Oracle University and Egabi Solutions use only

5) Examine the resource bundle.

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.
b) Turn off automatic row selection on the table:
i) Select af:table in the Structure window or in the breadcrumbs at the bottom of
the editor.
ii) Click Edit on the Property Inspector.
iii) 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:
i) In the Structure window, expand the first af:column under af:table.
ii) Right-click af:outputText for ProductName in the Structure window
and select Surround With.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 179

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

Oracle University and Egabi Solutions use only

a) Open the ProductSearch page.

Practice 14-2: Creating Links for Navigation (continued)

iv) In the Property Inspector, remove the value in the Text property of the
af:commandLink and set the 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 in the page.
i) In the Data Controls panel, expand FODProductAMDataControl >
BrowseProduct > Operations.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 180

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

Oracle University and Egabi Solutions use only

iii) In the Surround With dialog box, select ADF Faces > Link and click OK.

Practice 14-2: Creating Links for Navigation (continued)

iii) 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:
i) Right-click anywhere in the ProductSearch page and select Go To Page
Definition, or click the Bindings tab of the page.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 181

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

Oracle University and Egabi Solutions use only

ii) Drag the setCurrentRowWithKey operation to the af:commandLink in


either the Structure window or the editor, and select Bind Existing Link.

Practice 14-2: Creating Links for Navigation (continued)

iii) In the Property Inspector, set the NDValue property to #{row.rowKeyStr},


and 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.


i) In the ShoppingFlow task flow, right-click the ProductCatalog view activity
and select Run.
ii) Click Search.
iii) On the search page, enter % in the ProductName field and click Search.
Experiment with using the link.
iv) If you completed the optional steps of defining additional buttons:
(1) On the detail page, click Search to return to the search page to try
another link, or if you did not complete the optional step of
definingSear.
(2) On the ProductDetails page, click Shop to return to the
ProductCatalog page.
v) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.
2) In the ShoppingFlow task flow, add a drill-down link from the ProductCatalog page
to the ProductDetails page.
a) Open the ProductCatalog page.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 182

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

Oracle University and Egabi Solutions use only

ii) In the Structure window, select bindings > setCurrentRowWithKey >


rowKey.

Practice 14-2: Creating Links for Navigation (continued)


b) Select the af:outputText of ProductName in the bottom table.
c) Use [Ctrl] + [C] to copy the Value property #{row.ProductName}.
d) Right-click the af:outputText and select Convert.

f) Accept the convert confirmation.


g) 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.
So you need to use the setCurrentRowWithKeyValue() method from the
BrowseProduct data control to coordinate the pages.
a) In the Data Controls panel, expand
FODProductAMDataControlBrowseProductOperations.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 183

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

Oracle University and Egabi Solutions use only

e) In the Convert Output Text dialog box, select ADF Faces > Link and click OK.

Practice 14-2: Creating Links for Navigation (continued)

c) In the Confirm Component Rebinding dialog box, select the text check box to
retain its value and click OK.
d) 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 184

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

Oracle University and Egabi Solutions use only

b) Drag setCurrentRowWithKeyValue to the af:commandLink you just


converted and select Bind Existing Link.
Note: Be sure to select setCurrentRowWithKeyValue, and not just
setCurrentRowWithKey.

Practice 14-2: Creating Links for Navigation (continued)


b) In the Bindings section, select the BrowseProduct1 binding and click Edit.

Note: This adds the attribute to the bindings, but it does not add it to the table in
the page. It simply makes the attribute available to the page.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 185

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

Oracle University and Egabi Solutions use only

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.

Practice 14-2: Creating Links for Navigation (continued)

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. Click Shop to return to the
ProductCatalog page to try different links (if you did not define the Shop button in
the optional steps, then use the browsers Back button to return to the
ProductCatalog page.)
Note: If the bottom Products table shows no data, you can test the links after
you coordinate the Products table with the Subcategories table in a later
practice.
f) 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 186

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

Oracle University and Egabi Solutions use only

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.

Practice 14-2: Creating Links for Navigation (continued)


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.)
e) Open the BrowseSuppliers page.
f) Change the SupplierId to be a link that navigates to the SupplierUpdate page:
i) In the Structure window, expand the first af:column under af:table.
ii) Right-click af:outputText for SupplierId in the Structure window and
select Surround With.
iv) In the Property Inspector, remove the value in the Text property of the
af:commandLink and set the Action to update.
v) 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 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 187

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

Oracle University and Egabi Solutions use only

iii) In the Surround With dialog box, select ADF Faces > Link and click OK.

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.
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.
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 type in 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 188

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

Oracle University and Egabi Solutions use only

1) Open the ProductCatalog page.

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.
2) Select Web Tier > JSF > ADF Task Flow and click OK.
3) In the Create Task Flow dialog box:
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.

4) Create the following three View Activities on the CheckoutFlow, and notice that
JDeveloper creates a navigation path as you create the activities:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 189

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

Oracle University and Egabi Solutions use only

1) Invoke the New Gallery.

Practice 14-4: Defining a Sequence of Steps (continued)


CheckoutShipping
CheckoutPayment
CheckoutConfirm

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:
i) One named submit from CheckoutConfirm to SubmitOrder
ii) One named cancel from the wildcard to CancelOrder

6) Create the CheckoutShipping page:


a) Double-click the CheckoutShipping view activity to create the page. Be sure to
create in the \oracle\storefront\ui\pages directory.
b) Add a form that displays the ShippingAddress information:
i) Drag FODCheckoutAMDataControl > ShoppingCart1 >
ShippingAddress to the page (or onto to af:form in the Structure window)
as an ADF Form and include the following attributes in order, deleting all
other attributes:
Address1

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 190

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

Oracle University and Egabi Solutions use only

5) Add two task flow returns:

Practice 14-4: Defining a Sequence of Steps (continued)


Address2
City
StateProvince
PostalCode
CountryId

ii) Dont include Navigation Controls or a Submit Button.

7) Run the page from the task flow. It has no data on it because the shopping cart
context has not been established. Also notice that there is currently no means of
navigation. You fix these problems in the next steps.

Close the browser and undeploy the application as described in step 6(i) of Practice 24.
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 programatically), 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. The
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:
i) Select Generic Bindings from the drop-down list.
ii) Select methodAction.
iii) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 191

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

Oracle University and Egabi Solutions use only

iii) Click OK to create the form.

Practice 14-4: Defining a Sequence of Steps (continued)


d) In the Create Action Binding dialog box:
i) Select FODCheckoutAMDataControl. Notice that the Operation defaults to
init(). This is because the init() method is the only method in the
application module.
ii) Click OK.
e) Now that you have a reference to the init() method, you can add it to the
Executables list:
i) Click Add in the Executables section.
iii) Set the Binds to init.
iv) Set the id to invokeInit and click OK.
v) 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.
vi) 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 192

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

Oracle University and Egabi Solutions use only

ii) Select Generic Bindings > invokeAction and click OK.

Practice 14-4: Defining a Sequence of Steps (continued)

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.
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: Be sure 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) Select the CheckoutShipping activity.
c) In the Property Inspector, select the Train Stop panel and set the display-name
to Shipping.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 193

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

Oracle University and Egabi Solutions use only

a) In the page editor for the CheckoutShipping page, drag a Train component from
the Component Palette just inside the top of the form, and select Create Train.

Practice 14-4: Defining a Sequence of Steps (continued)

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 of 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.
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) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.
f) Delete the two temporary pages:
i) In the CheckoutFlow task flow, select the CheckoutPayment and
CheckoutConfirm view activities and delete the value in their page property.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 194

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

Oracle University and Egabi Solutions use only

d) In a similar fashion, set the display-name for CheckoutPayment to Billing


and for CheckoutConfirm to Confirmation.

Practice 14-4: Defining a Sequence of Steps (continued)

Oracle University and Egabi Solutions use only

ii) In the Application Navigator, multiselect the CheckoutConfirm and


CheckoutPayment pages. Right-click and select Erase from Disk.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 195

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.

c) Select one of the search control flow cases and in the Property Palette change its
from-activity-id to the wildcard rule, selecting it from the drop-down list.

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, selecting it from the drop-down list.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 196

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

Oracle University and Egabi Solutions use only

b) Drag a Wildcard Control Flow Rule from the Component Palette to the task
flow.

Practice 14-5: Simplifying and Enhancing a Task Flow


(continued)

g) Select the shop control flow rule and in the Property Palette change its fromactivity-id to the wildcard rule, 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:


a) To call the checkout flow
b) To display the shopping cart
c) To add an item to the cart

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 197

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

Oracle University and Egabi Solutions use only

f) Delete the other detail control flow rule. The diagram should now look similar
to the following screenshot:

Practice 14-5: Simplifying and Enhancing a Task Flow


(continued)

e) Drag a Control Flow Case from the wildcard to CheckoutFlow and name the
outcome checkout.
f) From the Application Navigator, drag the ShoppingCartFlow to the
ShoppingFlow task flow diagram in the editor to create a task flow call activity.
g) In the Property Inspector, change the id of the task flow call activity to
AddShoppingCart. Do not change the id in the Task Flow Reference section.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 198

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

Oracle University and Egabi Solutions use only

d) From the Application Navigator, drag the CheckoutFlow to the ShoppingFlow


task flow diagram in the editor to create a task flow call activity.

Practice 14-5: Simplifying and Enhancing a Task Flow


(continued)

i) From the Application Navigator, again drag the ShoppingCartFlow to the


ShoppingFlow task flow diagram in the editor to create a task flow call activity.
j) In the Property Inspector, change the id of the task flow call activity to
DisplayShoppingCart. Do not change the id in the Task Flow Reference section.
k) 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.
l) Open ProductCatalog and to the right of the Search button, add a button
named Show Cart that navigates to the DisplayShoppingCart activity.
i) Using the resource bundle, set the text property to Show Cart.
ii) Set the action to cart.
iii) Test the navigation by running the ProductCatalog page from the
ShoppingFlow task flow.
iv) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 199

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

Oracle University and Egabi Solutions use only

h) Drag a Control Flow Case from the wildcard to AddShoppingCart and name
the outcome add.

Practices for Lesson 15

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, then
you need to 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
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 200

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

Oracle University and Egabi Solutions use only

In the practices so far, you have chosen the default layout for all the components you
have used. Thats a quick way to check that 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.

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.
Page

Table

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, stretch the
middle column, because it is the one that contains a large amount of text. To do
so, follow these steps:
i) Select the middle column and give it the Id of Description.
ii) You may get errors when non-default values of Id and TestId are not identical.
To avoid this possibility, reset the TestId to its default value.
iii) Select the table and set Column Stretching to column:Description (just
type this value in.)
f) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 201

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

Oracle University and Egabi Solutions use only

1) Stretch the last columns of the following tables, and stretch the tables themselves:

Practice 15-1: Stretching Tables and Columns (continued)

Oracle University and Egabi Solutions use only

g) Optional step (if you choose not to complete this step, you can begin the
practices for the next lesson by opening the starter application):
In a similar fashion, stretch the table and the last column for all tables in the
following pages:
ProductSearch (Search results table)
ShoppingCart (Items table)
BrowseSuppliers (Suppliers table)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 202

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.
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 default headings. Change these headings to Categories and Subcategories.
i) In the Structure window, select af:panelHeader BrowseCategory1.

ii) In the Property Inspector, change the Text property to Categories, being
sure to use a resource bundle.
iii) In a similar fashion, set the Text property for the af:panelHeader
BrowseSubCategory to Subcategories.
2) In 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.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 203

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

Oracle University and Egabi Solutions use only

a) Open the ProductCatalog page.

Practice 15-2: Adjusting JDevelopers Default Layout


Components (continued)

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):
In a similar fashion, set the default Panel Group Layout component to scroll in the
ProductSearch page.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 204

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

Oracle University and Egabi Solutions use only

b) In the Property Inspector, select scroll from the Layout drop-down list.

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 in 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.

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:
i) Set the Text property to Product Detail, optionally using the resource
bundle.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 205

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

Oracle University and Egabi Solutions use only

c) In the Structure window, right-click af:table and select Surround With.

Practice 15-3: Adding Layout Components to Existing Pages


(continued)
f) In the Structure window, expand af:panelHeader > Panel Header facets.

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

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 206

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

Oracle University and Egabi Solutions use only

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.

Practice 15-3: Adding Layout Components to Existing Pages


(continued)

3) Optional step (if you choose not to complete this step, you can begin the practices
for the next lesson by opening the starter application):
In a similar fashion 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 the existing buttons to a toolbar in 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.
d) Set the Width of the panel header to 500 pixels.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 207

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

Oracle University and Egabi Solutions use only

and the Structure window should look similar to this:

Practice 15-3: Adding Layout Components to Existing Pages


(continued)

and the Structure window should look like this:

4) Optional step (if you choose not to complete this step, you can begin the practices
for the next lesson by opening the starter application):
In a similar fashion on the BrowseSuppliers page, put the Supplier table into a panel
header with the heading Select a Supplier for Update.
a) Surround the Supplier table with a Panel Header.
b) Using the resource bundle, change the Text to Select a Supplier for
Update.
c) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 208

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

Oracle University and Egabi Solutions use only

e) Save your work. When you have finished, the page should look like this

Practice 15-3: Adding Layout Components to Existing Pages


(continued)
5) Optional step (if you choose not to complete this step, you can begin the practices
for the next lesson by opening the starter application):
In a similar fashion on the ShoppingCart page, put the table into a panel header
labeled Shopping Cart.
a) Surround the table with a Panel Header.
b) Add the existing buttons to a toolbar in the toolbar facet of the panel header.
c) Use the resource bundle to change the Text to Shopping Cart.
6) Optional step (if you choose not to complete this step, you can begin the practices
for the next lesson by opening the starter application):
In a similar fashion on the CheckoutShipping page, put the panelFormLayout
containing the Shipping form into a panel header titled Shipping Address.
a) Surround the Panel Form Layout with a Panel Header.
b) Use the resource bundle to change the Text to Shipping Address.
c) Do not move the train or the train button bar into the panel form layout.
d) Save your work. When you have finished, the Structure window should look like
this:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 209

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

Oracle University and Egabi Solutions use only

d) Save your work.

Practice 15-4: Creating New Pages with Required Layout


You have not yet created the last two pages in the CheckoutFlow train. In this practice
you create those pages, starting with the layout components and then adding databound
components.

a) Open the CheckoutFlow task flow.


b) Double-click the CheckoutPayment view activity to create the page. Be sure to
create it in the \oracle\storefront\ui\pages directory.

c) Drag a Panel Group Layout from the Component Palette to the page and set its
Layout property to scroll.
d) Drag two Panel Headers to the page, one below the other and both within the
panel group layout. You may find it easier to drag the panel headers to the
af:panelGroupLayout in the Structure window.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 210

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

Oracle University and Egabi Solutions use only

1) Create the CheckoutPayment page. The page should contain a panel group layout
with two panel headers, one that displays the billing address and the other displaying
payment options. The layout should be like this:

Practice 15-4: Creating New Pages with Required Layout


(continued)
e) Set the Text of the top panel header to Billing Address and of the other to
Payment Options, optionally using a resource bundle.
2) Now that you have the layout defined, you can add databound components. First you
add the billing address.

b) Create it as an ADF Form.


c) Include the following attributes in order:
Address1
Address2
City
StateProvince
PostalCode
CountryId

d) Dont include Navigation Controls or a Submit Button.


e) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 211

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

Oracle University and Egabi Solutions use only

a) Drag the FODCheckoutAMDataControl > ShoppingCart1 > PaymentOption1


> BillingAddress to the first panel header.

Practice 15-4: Creating New Pages with Required Layout


(continued)

3) In a similar manner, add the payment options.


a) Drag the FODCheckoutAMDataControl > ShoppingCart1 > PaymentOption1
data control to the second panel header on the page and add it as an ADF Form.
b) Include the following attributes in order:
PaymentTypeCode
CardTypeCode
AccountNumber
ExpireDate
CheckDigits
RoutingIdentifier
InstitutionName
c) Do not include Navigation Controls or a Submit Button.
d) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 212

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

Oracle University and Egabi Solutions use only

f) Save your work. The page should now look like this:

Practice 15-4: Creating New Pages with Required Layout


(continued)

4) Add some white space between the panels.


a) Drag a Spacer from the Component Palette to the Panel Group Layout facets >
separatorthis provides a little white space between panels.
b) Save your work.
5) Create the CheckoutConfirm page, which has a more complicated layout than the
other pages because it is an overview of all of the order information. The layout
should be like this:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 213

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

Oracle University and Egabi Solutions use only

e) Save your work. Now the page should look like this:

a) In the CheckoutFlow task flow diagram, double-click the CheckoutConfirm


view activity to create the CheckoutConfirm page in the
\oracle\storefront\ui\pages directory.
b) From the Component Palette, drag a Panel Group Layout to the page and set its
Layout property to scroll.
c) Drag a Panel Header to the Panel Group Layout and set its Text property to
Payment Options, optionally using an existing text resource.
d) Drag a second Panel Group Layout to the first one, and set its Layout property
to horizontal and its Width to 100%.
e) Drag two Panel Headers to the horizontal Panel Group Layout. Set the Text of
the first to Shipping Address, and of the second to Billing Address,
optionally using existing text resources in the resource bundle.
f) Drag a spacer to the separator facets of each of the two Panel Group Layouts.
g) Drag another Panel Header to the outermost Panel Group Layout (the one with
the scroll layout) and set its Text to Order Items.
6) Now that you have defined the layout, you can create databound components on the
page. Create a read-only table of shopping cart items on the Order Items panel header,
and read-only forms for shipping address, billing address, and payment options on
their respective panel headers.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 214

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

Oracle University and Egabi Solutions use only

Practice 15-4: Creating New Pages with Required Layout


(continued)

Practice 15-4: Creating New Pages with Required Layout


(continued)
a) Drag the FODCheckoutAMDataControl > ShoppingCart1 > PaymentOption1
to the Payment Options panel header as an ADF Read-only Form.
ii) Include the following attributes in order:
Meaning
Meaning1
AccountNumber
ExpireDate
CheckDigits
RoutingIdentifier
InstitutionName
Note: Meaning and Meaning1 are the displayable values for
PaymentTypeCode and CardTypeCode, respectively. These attribute names
are the default attribute names for the view object. This is why it is important
to take the time to relabel them to something meaningful, as has been done in
the LookupCodeEO entity object control hints. You see the new labels at run
time.
b) Drag the FODCheckoutAMDataControl > ShoppingCart1 >
ShippingAddress to the Shipping Address panel header as an ADF Read-only
Form.
i) Do not include Navigation Controls or a Submit Button.
ii) Include the following attributes in order:
Address1
Address2
City
StateProvince
PostalCode
CountryId

c) Drag the FODCheckoutAMDataControl > ShoppingCart1 > PaymentOption1


> BillingAddress to the Billing Address panel header as an ADF Read-only
Form.
i) Do not include Navigation Controls or a Submit Button.
d) Include the following attributes in the same order:
Address1
Address2
City
StateProvince
PostalCode
CountryId

e) Drag FODCheckoutAMDataControl > ShoppingCart1 > ShoppingCartItem1


to the Order Items panel header on the page as an ADF Read-only Table.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 215

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

Oracle University and Egabi Solutions use only

i) Do not include Navigation Controls or a Submit Button.

Practice 15-4: Creating New Pages with Required Layout


(continued)
i) Enable Sorting.
ii) Include the following attributes in order:
ProductName
Quantity
UnitPrice
LineTotal
iii) Set the Width of the table to 100% and enable last column stretching.

Oracle University and Egabi Solutions use only

f) Save your work. The page should look like this

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 216

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


(continued)

g) Optional Step: To test your checkout pages, you need to add the same train
components to the second and third train stops. In the lesson titled Ensuring
Reusability, you define a page template to use for all of these pages, and the train
components are on it rather than on the individual pages. However, for now you
temporarily add them to each page for testing. Copy the train and train button bar
from the CheckoutShipping page to each of the other two pages in the
CheckoutFlow.
i) Open the CheckoutShipping page.
ii) In the Structure window, expand jsp:root > f:view > af:document > af:form.
iii) Multiselect af:train and af:trainButtonBar.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 217

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

Oracle University and Egabi Solutions use only

and the Structure window should look like this:

Practice 15-4: Creating New Pages with Required Layout


(continued)

v) Open the CheckoutPayment page.


vi) In the Structure window, expand jsp:root > f:view > af:document > af:form.
vii) Right-click af:form and select Paste.
viii) Drag af:train and af:trainButtonBar above the af:panelGroupLayout.

ix) Perform steps v) through vii) on the CheckoutConfirm page.


x) Run the CheckoutFlow to test the pages.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 218

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

Oracle University and Egabi Solutions use only

iv) Right-click and select Copy.

Practice 15-5: Setting Conditional Display


Sometimes there is a need to display or not display attributes depending on specific
conditions. In our example, if the user selects a Credit Card payment type, you dont want
to display the RoutingIdentifier or the InstitutionName because those are used only for
checks. If the user selects a Direct Debit payment type, you dont want to display
CardTypeCode or ExpirationDate, because those are used only for credit cards.

The Payment Type codes are listed below.


CC Credit Card
DD Direct Debit
IN Invoice
PP PayPal
1) The PaymentTypeCode is a choice list and its default binding gives you the
position of the selected value in the list, not the value. On the CheckoutPayment page,
create an attribute value named PaymentTypeCodeValue for the value of the
payment type code.
a) Click the Bindings tab on the CheckoutPayment.jspx page.
b) In the Bindings section, click Add

c) Select Generic Bindings > attributeValues.


d) Click OK.
e) In the Create Attribute Binding dialog box:
i) Select FODCheckoutAMDataControl.PaymentOption1 as the Data Source
and PaymentTypeCode as the Attribute.
ii) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 219

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

Oracle University and Egabi Solutions use only

In this practice, you work on the CheckoutPayment page to set the attributes to be visible
only when they are needed, based on the Payment Type. You add Expression Language
to the components that you want to conditionally display, and you use partial page
rendering to refresh only those components, rather than the entire page.

Practice 15-5: Setting Conditional Display (continued)


f) In the Property Inspector, change the id of the binding to
PaymentTypeCodeValue. (Click PaymentTypeCode1 in the Structure window
if you dont see the id in the Property Inspector.)
Now you have a reference to the actual value of the PaymentTypeCode so that
you can use a condition based on its value. Save your work.

a) Click the Design tab on the CheckoutPayment.jspx page to go back to the


design view of the page.
b) Select the af:selectOneChoice for PaymentTypeCode in either the visual
editor or the Structure window.
c) Set the Id property to PaymentType.
d) Set the Behavior > AutoSubmit property to true.
3) The first attribute to set a condition on is CardTypeCode. If the payment type code
is not CC (for Credit Card), then dont display this field.
a) Select af:selectOneChoice for CardTypeCode attribute in either the visual
editor or the Structure window.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 220

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

Oracle University and Egabi Solutions use only

2) Because you are going to use partial page rendering for this action, you need to
reference the component that triggers the partial page rendering. Set an Id and
implement PPR on the triggering component.

Practice 15-5: Setting Conditional Display (continued)


b) Set the Visible attribute (in the Advanced panel) to:
#{bindings.PaymentTypeCodeValue.inputValue == 'CC'}
If this expression evaluates to true, then the attribute is visible in the UI.

In the list at the left of the Expression Builder, select ADF Bindings > bindings >
PaymentTypeCodeValue > inputValue, which inserts
#{bindings.PaymentTypeCodeValue.inputValue} into the expression.
You then can add the condition to the end of the expression and click OK.
Note: Be sure to select the PaymentTypeCodeValue attribute binding and not
the PaymentTypeCode binding.

c) Now set the PartialTriggers property to PaymentType, which is the Id of the


triggering component.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 221

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

Oracle University and Egabi Solutions use only

Note: You can use the Expression Builder to help build the expression. To get to
Expression Builder, click the arrow icon to the right of the Visible property in the
Property Inspector and select Expression Builder.

Practice 15-5: Setting Conditional Display (continued)


i) On the Behavior panel, click the small down arrow next to the
PartialTriggers text box and select Edit.
ii) In the Edit Property dialog box, choose selectOneChoice PaymentType
and shuttle it to the Selected list.
(This means that when the PaymentType component forces an autosubmit, it
refreshes this data control. When it does, the code in the Visible property
executes. If the code evaluates to true, the data control appears.)
iii) Click OK.

5) Set CheckDigits to be visible only if the value is CC.


6) Set RoutingIdentifier and InstitutionName to be visible only if the
value is DD.
Hint: Remember to set the expression for the Visible property and select
PaymentType for the PartialTriggers property for these attributes.
7) Run CheckoutShipping from the CheckoutFlow task flow and navigate to the
CheckoutPayment page to test your work.
a) Test changing the Payment Type value to see the results. You should see that
different attributes appear depending on the value that you set.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 222

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

Oracle University and Egabi Solutions use only

4) Now set ExpireDate to be visible only if the Payment Type Code Value is CC.
(The steps and code are similar.)

Practice 15-5: Setting Conditional Display (continued)

Oracle University and Egabi Solutions use only

b) When you are finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 223

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

Practice 15-6: Implement PPR to Coordinate Products Display


with Selected Subcategory
When you added the Products table to the ProductCatalog page, you added it as an
independent table, not as a masterdetail. It is not set to be refreshed when the selection
in the SubCategory table changes. In this practice, you use PPR to refresh the
Products table (this PPR is defined automatically when you add components as
masterdetail).
1) Set the SubCategory table to be the triggering component for PPR.
b) Set the Id to SubCategory.
c) You may get errors when non-default values of Id and TestId are not identical. To
avoid this possibility, reset the TestId to its default value by invoking the menu to
the right of the field. (TestId is on the Advanced panel of the Property Inspector.)
d) Verify that Row Selection is selected for this table. Use the table Edit icon in the
Property Inspector (dont just change the Row Selection property).

2) Set the Products table to be the PPR target that is refreshed when the selected
subcategory changes.
a) Select the Products table.
b) In the Property Inspector, set the Partial Triggers property to SubCategory
(use the editor, available from the drop-down menu, to add appropriate colons in
front to reference the correct naming container.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 224

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

Oracle University and Egabi Solutions use only

a) Open the ProductCatalog page and select the SubCategories table.

3) Test the page.


a) Run the page, either directly or from the task flow.
b) Select Category, then SubCategory and check that the correct products appear.
c) When you have finished, close your browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 225

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

Oracle University and Egabi Solutions use only

Practice 15-6: Implement PPR to Coordinate Products Display


with Selected Subcategory (continued)

Practices for Lesson 16


In this set of practices, you begin to implement reusability in the application.

The FODShoppingDashboard page is meant to be the main page of the application. Other
applications that will be developed for this company should use a similar look, so you
create a page template that imposes a certain layout. You then create the
FODShoppingDashboard page, using this page template.
The bounded task flows that you have created so far have used pages, not page
fragments. This enabled you to test them independently. However, now you incorporate
these task flows as regions on the main FODShoppingDashboard page. To do so, you
first must convert the bounded task flows to use page fragments.
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, then
you need to open Storefront-16.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
wish to build the entire application yourself, you can complete the optional steps.
However, in the interest of time, you may wish to skip them. If you do so, you will need
to start the practices for the next lesson by opening the starter application for that lesson.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 226

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

Oracle University and Egabi Solutions use only

When there are several pages that are used in succession, it is a good practice to make
sure the layout of each page is exactly the same. For example, you want navigation
buttons to appear in exactly the same location on pages that are used in series, like the
CheckoutFlow. To make the layout cleaner and reusable, you create and apply a template
to the pages.

Practice 16-1: Converting Bounded Task Flows to Use Page


Fragments
In this practice, you convert all of your bounded task flows to use page fragments rather
than pages. After you have done this, you no longer can run the task flows independently.
You would need to either call them from an unbounded task flow or use them as regions
on a page.
1) Convert CheckoutFlow to use page fragments.
b) Right-click the diagram and select Convert To Task Flow With Page
Fragments.
c) In the Convert To Task Flow With Page Fragments dialog box, just click OK.
You do not need to keep a copy of any of the pages.
d) In the warning dialog box, click Yes to continue. You should see that the usepage-fragments property of the task flow is now set to true.

You should also see that the .jspx files for the checkout pages have been
converted to .jsff files.

e) Select one of the .jsff files in the Application Navigator.


f) Observe in the Structure window that the files no longer contain the f:view,
af:document, and af:messages tags.
2) So that you can use all unbounded task flows as regions on a main page, repeat the
above steps to convert all of the unbounded task flows to use page fragments. Notice
that all of the .jspx files (except for ProductCategory.jspx) are now converted
to .jsff (page fragment) files.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 227

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

Oracle University and Egabi Solutions use only

a) Open the CheckoutFlow task flow in the editor.

Practice 16-1: Converting Bounded Task Flows to Use Page


Fragments (continued)
3) There is only one full page left, which is ProductCategory.jspx. This is a page
on the unbounded task flow. Extract this page into its own bounded task flow named
ProductCategoryFlow, and then convert it to use page fragments as well.
a) Open adfc-config.xml.
b) Right-click the ProductCategory view activity and select Extract Task Flow.
c) In the Extract Bounded Task Flow dialog box:
i) Enter ProductCategoryFlow as the File Name.
iii) Click OK.
d) The task flow opens in the editor. Mark the ProductCategory view activity as the
default activity.
e) Convert ProductCategoryFlow to use page fragments as you did the other task
flows.
f) When you extract a task flow, JDeveloper creates a task flow call on the original
task flow. Delete the task flow call activity from adfc-config.xml.
g) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 228

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

Oracle University and Egabi Solutions use only

ii) Append \oracle\storefront\ui\flow to the Directory path.

Practice 16-2: Creating a Page Template and Applying It to


Existing Pages
In this practice, you create a page template and apply it to the pages in the CheckoutFlow.
You previously added the train components and arranged them on each of the checkout
pages. This duplication of effort isnt that bad if there are only a few pages. However, if
there are many pages, this duplication becomes a little tedious and possibly error-prone.

1) Create a new page template named CheckoutPageTemplate, with a content


facet and a required title attribute.
a) In the Application Navigator, right-click the directory where you have been filing
pages and select New.
b) In the New Gallery, select Web Tier > JSF > JSF Page Template.
c) Set the following properties for the new page template, and then click OK:
File Name

CheckoutPageTemplate.jspx

Directory

<ProjHome>\public_html\oracle\storefront\ui\pages\templates

Page
Template
Name

CheckoutPageTemplate

content
Facet
Definitions (select Facet Definitions tab and click Add to add the facet)

Attributes

title

java.lang.String

required

(select Attributes tab and click Add to add the attribute)

2) To the page template, add the layout and train components that you want to use in all
the checkout pages.
a) Add a Panel Group Layout on the af:pageTemplateDef.
i) Set its Layout property to scroll)
ii) Drag the panel group layout above the af:xmlContent in the Structure
window.
b) Drag a Train to the af:panelGroupLayout.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 229

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

Oracle University and Egabi Solutions use only

To avoid this unnecessary duplication, you now create a template that manages the train
components for each of the pages. The template also contains a Panel Group Layout and
a Panel Header to provide additional layout structure for the checkout pages.

Practice 16-2: Creating a Page Template and Applying It to


Existing Pages (continued)
c) Set the Value property of af:train to
#{controllerContext.currentViewPort.taskFlowContext.trainMo
del}

(You can use Expression Builder and select ADF Controller Objects >
controllerContext > currentViewPort > taskFlowContext > trainModel to
insert into the expression.)

e) Add a Toolbar to the af:panelHeader toolbar facet.


f) Add a Button to the af:toolbar inside the af:panelHeader toolbar facet.
i) Set the Text to Cancel, optionally using the resource bundle.
ii) Set the Action to cancel.
iii) Set the Immediate property to true.
g) Add a Train Button Bar to the af:toolbar inside the af:panelHeader
toolbar facet and set the Value property to
#{controllerContext.currentViewPort.taskFlowContext.trainModel}

h) Add another Button to the af:toolbar inside the af:panelHeader toolbar


facet.
i) Set Text to Submit.
ii) Set Action to submit.
iii) Set the disabled property to
#{controllerContext.currentViewPort.taskFlowContext.
trainModel.next != null}

Note: If you use the Expression Builder, it displays the code as if it were an error.
It has context for the trainModel but doesnt understand .next in the expression.
You can ignore the error.
3) Add a Facet Reference named content to the template.
a) Drag the Facet Ref to the af:panelHeader.
b) Set the FacetName to content.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 230

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

Oracle University and Egabi Solutions use only

d) Drop a Panel Header on the af:panelGroupLayout and set its Text to


#{attrs.title}. (You can use Expression Builder and select JSP Objects >
attrs > title to insert into the expression, then delete the original value.)

Practice 16-2: Creating a Page Template and Applying It to


Existing Pages (continued)

and the Structure window should look similar to the following:

5) Apply the template to the checkout pages. (You cant use the IDE to apply a template
to an existing page. However, you can add the template-related code to an existing
page.)
a) Open CheckoutShipping.jsff.
b) Click the Source tab.
c) In the Structure window, select af:train and af:trainButtonBar. These
components are no longer needed in the page fragment because they are contained
in the page template.
d) Back in the Source editor, replace the highlighted code with the following (you
can copy the code from PageTemplate.txt in your files directory):

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 231

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

Oracle University and Egabi Solutions use only

4) Save your work. The page template should look similar to the following

Practice 16-2: Creating a Page Template and Applying It to


Existing Pages (continued)
<af:pageTemplate
viewId="/oracle/storefront/ui/pages/templates/CheckoutPag
eTemplate.jspx">
<f:facet name="content"/>
<f:attribute name="title"/>
</af:pageTemplate>

f) Notice that in the Structure window there is now an af:pageTemplate, an


f:attribute and a content facet. Set the Value property of the
f:attribute to Shipping, optionally using the resource bundle.

6) The template contains the outermost Panel Group Layout (which holds the train,
buttons and the Panel Header). Therefore, when you apply the template to your page,
you need to move the content to the template content facet.
a) Using the Structure window, drag the af:panelHeader Shipping
Address to the content facet.

7) Apply the template to the other pages in the checkout flow, using Billing as the title
for the CheckoutPayment page and Confirmation as the title for the CheckoutConfirm
page.
a) Open CheckoutPayment.jsff.
b) Repeat the steps above, changing the value of the title attribute to Billing. (The
content area of this page is in the panelGroupLayout.)
c) Open CheckoutConfirm.jsff.
d) Repeat the steps above, changing the value of the title attribute to
Confirmation. (The content area of this page is in the outermost
panelGroupLayout.)
8) Save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 232

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

Oracle University and Egabi Solutions use only

e) Click the Design tab.

Practice 16-3: Creating a Page Template and Applying It to a


New Page
Your company is planning several applications that should have a similar look. The main
page should have an image at the top left, with the company name next to it. The lower
part of the page should be divided into two panels. The main flow of the application is to
appear in the right panel, whereas the left panel should have tabs for accessing other
functionality that may be available.

1) In the templates subdirectory of your directory for pages, create a new page template
named MainPageTemplate. Define content areas named companyLogo,
tab1Content, tab2Content, and mainContent. Define required attributes
called companyName, tab1Title, and tab2Title.
a) In the Application Navigator, right-click the directory where you already created a
page template and select New.
b) In the New Gallery, select Web Tier > JSF > JSF Page Template.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 233

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

Oracle University and Egabi Solutions use only

In this practice, you create a page template to be used in the main page of any of the
companys applications. You then create the FODShoppingDashboard page and base it
on this template. The layout of the template should be as follows:

Practice 16-3: Creating a Page Template and Applying It to a


New Page (continued)
File Name

MainPageTemplate.jspx

Directory

<ProjHome>\public_html\oracle\storefront\ui\pages\templates

Page
Template
Name

MainPageTemplate

Facet
Definitions
(click Add
to add
each facet)

companyLogo

Attributes
(click Add
to add
each
attribute)

companyName

java.lang.String

required

tab1Title

java.lang.String

required

tab2Title

java.lang.String

required

tab1Content
tab2Content
mainContent

2) The new template opens in the editor. Add a component with resizable vertical panes,
so that page developers can resize it to fit the size of the image they add to the top
pane. The component should be one that automatically stretches its children. Stretch it
to fit the browser vertically and horizontally.
a) Drag a Panel Splitter to the page, being sure that it appears above
af:xmlContent in the Structure window.
i) Set its Orientation to vertical.
ii) Set its SplitterPosition to 125.
3) You want the company logo image and the company name to be arranged
horizontally in the top portion of the page. Add a layout component to accomplish
that, and add the company logo and name.
a) In the Structure window, expand af:panelSSplitter and Panel Splitter facets.
b) Drag a Panel Form Layout to the first facet and set the following properties:
i) Set Rows to 1 (so that the components you add are in one horizontal row).
ii) Set Width to 500 pixels (so that the components you add are next to one
another, instead of spreading out to fit the browser width).
c) Drag a Facet Ref to the af:panelFormLayout and select companyLogo as the
facet name. This provides a spot for users of the page template to place an image.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 234

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

Oracle University and Egabi Solutions use only

c) Set the following properties for the new page template, and then click OK:

Practice 16-3: Creating a Page Template and Applying It to a


New Page (continued)
d) Drag a spacer to the af:panelFormLayout, so that the company name that you
add in the next step is not right up against the logo.
e) Drag an Output Text component to the af:panelFormLayout.
i) Set its Value to #{attrs.companyName} (you can use Expression Builder and
select JSP Objects > attrs > companyName.) Designers of pages that use
this template can supply a value for the companyName attribute.

4) Below the header section that has the company logo and name, you want two
resizable panels that consume the remainder of the browser area. The left panel
should contain two tabs where page designers can place content, and the right panel
should contain the main content area. Add the layout and components for this area.
a) Drag a Panel Splitter to the second facet of the root af:panelSplitter and set its
Orientation property to horizontal.
b) Expand af:panelSplitter >Panel Splitter facets for the panel splitter that you just
added.
c) Drag a Panel Tabbed component to the first panel splitter facet.
d) One detail item (corresponding to a tab) is created by default for the
af:panelTabbed component. Drag a second Show Detail Item to the
af:panelTabbed component.
i) Set the Text of the first af:showDetailItem to #{attrs.tab1Title}
(you can use Expression Builder.) This enables page designers to supply a
label for the tab.
ii) Set the Text of the second af:showDetailItem to #{attrs.tab2Title}.
e) Drag a Facet Ref to the first af:showDetailItem and select tab1Content as the
facet name.
f) Drag a Facet Ref to the second af:showDetailItem and select tab2Content as
the facet name.
g) Drag a Facet Ref to the second facet of the af:panelSplitter and select
mainContent as the facet name. This provides a spot for page designers to place
the main content of the application.
h) Save your work. You must save a page template before you can use it.
5) On the main unbounded task flow for the application, create the
FODShoppingDashboard page, applying the template that you just created.
a) Open adfc-config.xml.
b) Double-click the FODShoppingDashboard view activity to create the page,
setting the following properties:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 235

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

Oracle University and Egabi Solutions use only

ii) On the Style > Text section of the Property Inspector, set Color to Blue, Size
to xx-large, Bold to bold, and Italic to italic.

File Name

FODShoppingDashboard.jspx

Directory

<ProjHome>\public_html\oracle\storefront\ui\pages

Use Page
Template

MainPageTemplate

6) Use the attributes of the page template to customize the page for the Storefront
application. Supply values for the attributes of the template. The company name
should be Storefront Demo and the tabs should be labeled Categories and Suppliers.
The IDE does not provide a way to use a resource bundle, so you can enter hardcoded strings in this case.
a) Set the attribute values in FODShoppingDashboard. In the editor, click the
FODShoppingDashboard tab, or reopen that file if you have closed it.
b) In the Structure window, select af:pageTemplate.
c) In the Property Inspector, set the following values:
companyName: Storefront Demo
tab1Title: Categories
tab2Title: Suppliers

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 236

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

Oracle University and Egabi Solutions use only

Practice 16-3: Creating a Page Template and Applying It to a


New Page (continued)

Practice 16-3: Creating a Page Template and Applying It to a


New Page (continued)

d) Add the company logo to the page.


i) In the Structure window, expand af:pageTemplate >
/oracle/storefront/ui/pages/templates/MainPageTemplate.jspx facets.
ii) Drag an Image component from the Component Palette to the companyLogo
facet.
(1) In the Insert Image dialog box, click the arrow next to Source, click
Edit, and navigate to the \images subdirectory of your courseware
directory.
(2) Select store.gif and click OK.
(3) In the Image Location Problem warning box, click Yes to copy the
image into the document root of your project.

(4) In the Save Image dialog box, click Save.


(5) Back in the Insert Image dialog box, provide a ShortDesc if desired,
and then click OK. You should now see the image on the page.
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 237

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

Oracle University and Egabi Solutions use only

The page should now look similar to the following:

Practice 16-3: Creating a Page Template and Applying It to a


New Page (continued)
e) Save your work.
7) Change the company name to display in red rather than in blue.
a) Open MainPageTemplate.
b) Expand af:pageTemplateDef > af:panelSplitter - vertical > Panel Splitter
facets > first > af:panelFormLayout - 1.
c) Select af:outputText - #{attrs.companyName}.
e) Save your work. You must save changes to a page template in order for them to
be picked up by pages that use the template.
f) Open FODShoppingDashboard. If it is already open, click its tab and select View
> Refresh. You should see that the Storefront Demo text is now red.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 238

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

Oracle University and Egabi Solutions use only

d) On the Style > Text section of the Property Inspector, set Color to Red.

Practice 16-4: Using Bounded Task Flows as a Region on a Page


In this practice, you create regions on the FODShoppingDashboard page by dragging
bounded task flows to the page as regions.
1) Add content to the Categories tab of the FODShoppingDashboard page. You should
display the ProductCategoryFlow in this area.

b) From the Application Navigator, drag ProductCategoryFlow to the tab1Content


facet in the Structure window.
c) Create the flow as a Region.
2) Add the tab2 content. You should display the ShowSuppliersFlow in this area.
a) From the Application Navigator, drag ShowSuppliersFlow to the tab2Content
facet in the editor.
3) Create the flow as a Region.
4) Add the main content. You should display the ShoppingFlow in this area.
a) From the Application Navigator, drag ShoppingFlow to the mainContent facet.
b) Create the flow as a Region.
c) Now unpin the Structure window by clicking Freeze View again.
5) Test the page by running it from the task flow. Make note of any errors and problems
that you encounter.
a) Right-click the FODShoppingDashboard view activity in the adfc-config.xml
task flow and select Run. The page in the browser should look similar to the
following:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 239

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

Oracle University and Egabi Solutions use only

a) Select the FODShoppingDashboard page in the editor, and then in the Structure
window click Freeze View , or select View > Options > Freeze View from
the menu.

Practice 16-4: Using Bounded Task Flows as a Region on a Page


(continued)
b) Click the Suppliers tab. Click one of the links. You can see that the update
supplier page appears and displays the selected record, but with no way to
navigate back to the browse page (you fix this later).
c) In the main shopping region, notice that you must scroll down to see the other
tables on the page (you fix this shortly.) Select a new subcategory and verify that
the correct products appear in the Products table.
d) Click Show Cart to verify that the cart is displayed correctly.
f) Click Search. Verify that the search functionality works. Notice that there is no
way to return to the main shopping page from this page. You soon fix this
problem.
g) Click the link on one of the products. The page should now show the product
detail.
h) Click Shop to return to the main shopping page.
i) Click Show Cart again, and then click Checkout.
j) Verify that you can navigate through the checkout train, both by using the train
and by using the train buttons.
k) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.
6) Optional step (if you choose not to complete this step, you must begin the
practices for the next lesson by opening the starter application):
There is no way to return to the main shopping page from the ProductSearch page.
Implement navigation on that page to return to the main shopping task flow. Also add
some layout to the page to improve its appearance: Change the heading of the table to
Search Products and place all components under a root panel header with scrollbars.
a) Open the ProductSearch page fragment.
b) In the existing af:panelHeader use the resource bundle to change the text from
ProductEO to Search Products.
c) Move af:table to the af:panelHeader.
d) Drag a toolbar to the toolbar facet of the panel header.
e) Drag a toolbar button to the toolbar facet and set the following properties on the
button:
Text (use the resource bundle)

Shop

Action

shop

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 240

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

Oracle University and Egabi Solutions use only

e) Click Shop to return to the main shopping region.

Practice 16-4: Using Bounded Task Flows as a Region on a Page


(continued)

f) Run FODShoppingDashboard again from the unbounded task flow to ensure


that the Shop button on the Product Search page navigates back to the shopping
flow (Product Catalog page.)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 241

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

Oracle University and Egabi Solutions use only

The Structure window should look like this:

Practices for Lesson 17


When you built the ProductCatalog page, you created three separate areas on the page to
display Categories, SubCategories, and Products. Now you modify the page
to display only one table at a time.

You accomplish this by using parameters. In the practices for this lesson, you modify the
ProductCatalog page to display specific tables and data based on those parameters.
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, then
you need to open Storefront-17.jws, and edit the database information as
described in step 4 of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 242

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

Oracle University and Egabi Solutions use only

Initially the Categories table should appear. When the user clicks the name of a
category, the Subcategories table should display the subcategories for the category
that the user clicked. Then if the user clicks a subcategory, the Products table should
display the products for that subcategory.

Practice 17-1: Conditional Rendering Based on Parameters


In this practice, you define parameters and set up the tables on the ProductCatalog page
to conditionally appear based on the parameter values.
1) You need to change the tables on the ProductCatalog page to accept a parameter to
set the row, rather than relying on row concurrency as it does now. First, disable row
selection for the tables.
a) Open the ProductCatalog page.

c) In the Property Inspector, click Edit.


d) Deselect Row Selection and click OK.
Note: By using the editor, JDeveloper removes the row selection and whatever
listeners were required. If you just remove the row selection manually in the
Property Inspector, the listeners still remain.
e) Select the SubCategory table and remove the Row Selection in the same way.
2) Now you add page parameters.
Set page parameters on the ProductCatalog page to accept parameters named
param_CategoryId, param_SubCategoryId, param_CategoryName, and
param_SubCategoryName.
The page parameters should get their values from pageFlowScope variables named
CategoryId, SubCategoryId, CategoryName, and SubCategoryName.
a) Open the Page Definition for the ProductCatalog page (right-click the page and
select Go to Page Definition.)
b) Add the following parameters to the page definition:
id

Value

param_CategoryId

#{pageFlowScope.CategoryId}

param_SubCategoryId

#{pageFlowScope.SubCategoryId}

param_CategoryName

#{pageFlowScope.CategoryName}

param_SubCategoryName

#{pageFlowScope.SubCategoryName}

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 243

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

Oracle University and Egabi Solutions use only

b) Select the Categories table either in the Structure window or the visual editor
(the default id of the table was masterDetail1)

Practice 17-1: Conditional Rendering Based on Parameters


(continued)
The Page Definitions Parameters section should look like:

3) There is a method named setCurrentCategory() in the FODProductAM


application module. This method takes two arguments: a category ID and a
subcategory ID. It reexecutes the BrowseCategory, BrowseSubcategory, and
BrowseProduct view object queries based on the values that are passed to it.
Edit the bindings for the ProductCatalog page so that this method is executed upon
loading the page. Pass to the method two of the parameters that you defined above.
a) Still in the page definition of the ProductCatalog page, add a methodAction
binding to FODProductAMDataControl > setCurrentCategory.
b) In the Create Action Binding Editor, set the value of the categoryId parameter
to #{bindings.param_CategoryId} and the value of subCategoryId to
#{bindings.param_SubCategoryId} (you can use Expression Builder; the
parameters are shown under ADF Bindings > bindings).

The Parameters section of the Create Action Binding Editor should look like:

c) Add an InvokeAction to the Executables. Set the id to


invokeSetCurrentCategory and bind it to setCurrentCategory. Set the
Refresh property to ifNeeded.
d) Make sure that invokeAction is the first executable in the list. This insures that
the method is executed first when the page is loaded. (If you need to move it, you
drag it to the top of the list.)
e) Save your work, and leave the page definition file open for the next step.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 244

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

Oracle University and Egabi Solutions use only

Leave the page definition file open for the next step.

Practice 17-1: Conditional Rendering Based on Parameters


(continued)
4) You have defined parameters that take their values from pageFlowScope variables.
But how do those values get stored in the pageFlowScope variables? In this step,
you store these values.

a) Add CategoryId to the page bindings for both BrowseCategory1 and


BrowseSubCategory1.
i) Still in the page definition file for ProductCatalog, edit the BrowseCategory1
binding and add CategoryId as a display attribute. Hint: Click the
BrowseCategory binding; click Edit; select the rule in the Tree Binding editor;
shuttle the CategoryId from Available to Display Attributes.
Here is what the Tree Binding editor should look like:

ii) Repeat this step for BrowseSubCategory1, because you are going to use the
CategoryId that is selected in the SubCategories table to set the
subcategory-related parameters.
b) In the ProductCatalog page, convert the CategoryName field in the
Categories table to be a link. When a user clicks the link, the page should use
setActionListeners to set the pageFlowScope parameters.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 245

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

Oracle University and Egabi Solutions use only

In the Category and Subcategory tables, convert the category name to a link
that stores the name and ID in pageFlowScope variables. Use a Set Action Listener
operation to store each variable value.
Hint: You first must add the category ID to the page bindings.

Practice 17-1: Conditional Rendering Based on Parameters


(continued)
i) In the Structure window for the ProductCatalog page, expand the af:table
- masterDetail1.
ii) Click af:outputText for CategoryName and copy [Ctrl + c] the Value
property (when you convert the outputText to a Link, you lose the Value
property).
iii) Right-click the af:outputText for CategoryName and select Convert.
v) Paste into the Text property the value you copied a moment ago. The value
should be #{row.bindings.CategoryName.inputValue}.
vi) Insert two setActionListeners inside the Link with the following properties.
From

To

#{row.CategoryId}
#{row.CategoryName}

#{pageFlowScope.CategoryId}
#{pageFlowScope.CategoryName}

Note: You use the CategoryName and SubCategoryName parameters when


you set breadcrumbs in the next section.
c) Repeat the steps for the SubCategory table. (Make sure to pay close attention
to the pageFlowScope variable names in each setActionListener.)
i) Expand the af:table - SubCategory in the second panel header.
ii) Click af:outputText for CategoryName and copy [Ctrl + c] the Value
property.
iii) Right-click the af:outputText for CategoryName and select Convert.
iv) Select Link, and then click OK in the Confirm Convert dialog box.
v) Paste into the Text property the value you copied a moment ago. The value
should be #{row.bindings.CategoryName.inputValue}.
vi) Insert two setActionListeners inside the Link with the following properties.
From

To

#{row.CategoryId}
#{row.CategoryName}

#{pageFlowScope.SubCategoryId}
#{pageFlowScope.SubCategoryName}

5) Modify the rendering of the tables so that only a single table appears at a time.
Hint: If both category and subcategory parameters are null, the Categories table
should appear (no links have been clicked to set the parameters). If only the
categoryId parameter is set, the Subcategories table should appear, because
the user clicked a link on the Categories table to set the category ID. If both
parameters are set, the Products table should be displayed (both Category and
Subcategory links have been clicked, so both parameters have been set).
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 246

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

Oracle University and Egabi Solutions use only

iv) Select Link, and then click OK in the Confirm Convert dialog box.

Practice 17-1: Conditional Rendering Based on Parameters


(continued)
a) Select the first af:table (masterDetail1) and set the Rendered property so that
the table appears if the param_CategoryId and the param_SubCategoryId
are both null. (This means that there were no parameters set). The EL code is:
#{bindings.param_CategoryId == null &&
bindings.param_SubCategoryId == null}

#{bindings.param_CategoryId != null &&


bindings.param_SubCategoryId == null}

c) Select the third af:table (Products) and set the Rendered property so that the
table appears if there is a categoryId and a subCategoryId. (This means that
the page has set a Category and subCategory) The EL code is:
#{bindings.param_CategoryId != null &&
bindings.param_SubCategoryId != null}

6) Modify the layout of the ProductCatalog page so that all tables are under a single
panel header whose title changes depending on the table that appears.
a) In the Structure window for the ProductCatalog page, select af:table
SubCategory in the second af:panelHeader and drag it to the first
af:panelHeader (the one currently labeled Categories.)
b) Drag the af:table from the third af:panelHeader to the first af:panelHeader.
c) Delete the second and third panel headers.
d) Select af:panelHeader and set the Text property to
#{bindings.param_CategoryId == null ||
bindings.param_SubCategoryId == null ?
storefrontuiBundle.CATEGORIES :
storefrontuiBundle.PRODUCTS}

e) Move the command buttons on the page to a toolbar in the toolbar facet of the panel
header.

i) Expand Panel Header facets.


ii) Drag a toolbar to the toolbar facet.
iii) Drag the Search and Show Cart buttons to the toolbar.
f) The Structure should now look something like:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 247

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

Oracle University and Egabi Solutions use only

b) Select the second af:table (SubCategory) and set the Rendered property so
that the table appears if the CategoryId parameter is set but the
SubCategoryId parameter is null. (This means that the page set a Category
but not a subCategory) The EL code is:

7) Test the page.


a) Run FODShoppingDashboard from the adfc-config task flow.
b) The page should initially display categories. Click one of the category names.
c) The page should now display subcategories (the title of the panel header still says
Categories.) Click one of the subcategory names.
d) The page should now display products, and the title of the panel header changes
to Products. Notice that there is no way to navigate back to the Categories
table. You fix this in the next practice.
e) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 248

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

Oracle University and Egabi Solutions use only

Practice 17-1: Conditional Rendering Based on Parameters


(continued)

Practice 17-2: Using Parameters for Dynamic Breadcrumbs


When users click through links in the tables to display either the Subcategories or the
Products table, they need a way to navigate back through the chain of tables. This is
what the breadcrumbs on the page should enable them to do.

1) For the first breadcrumb, you want the Categories table to appear, so reset all the
parameters to null.
Hint: Remember that the parameters get their values from the pageFlowScope
variables.
a) In the ProductCatalog page, select the first af:commandNavigationItemthe
one labeled Store.
b) Add four setActionListeners with the following properties:
From

To

#{null}
#{null}
#{null}
#{null}

#{pageFlowScope.CategoryId}
#{pageFlowScope.CategoryName}
#{pageFlowScope.SubCategoryId}
#{pageFlowScope.SubCategoryName}

Hint: After you add the first setActionListener, you could use the Source tab to copy,
paste, and then modify the code.
2) Set the second breadcrumb to appear only if the user has clicked a category name in
the Categories table. Label the breadcrumb with the Category name that the user
clicked in the Categories table. Set the second breadcrumb to display the
Subcategory table when a user clicks it.
a) Select the second of the three navigation items in the Structure window.
b) Set the Text property to #{bindings.param_CategoryName}. You can use
Expression Builder to set this (ADF Bindings > bindings > param_CategoryName).

c) Set the Rendered property to


#{bindings.param_CategoryId != null}.

d) If a user clicks the second breadcrumb, he or she wants to see the SubCategories.
You use the setActionListeners to reset just the SubCategory parameters.
Add 2 setActionListeners with the following properties:
From

To

#{null}
#{null}

#{pageFlowScope.SubCategoryId}
#{pageFlowScope.SubCategoryName}

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 249

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

Oracle University and Egabi Solutions use only

When users click the first breadcrumb, they should return to the top level of the
breadcrumb list to display the Categories table. You have already set the page to use
the pageFlowScope parameters to display the correct section of the page, so in this
practice, you just set those parameters based on which breadcrumb is clicked.

Practice 17-2: Using Parameters for Dynamic Breadcrumbs


(continued)
3) Set the third breadcrumb to appear only if the user has clicked a category name in the
SubCategories table. Label the breadcrumb with the Category name that the user
clicked in the SubCategories table. Set the third breadcrumb to display the
Products table when a user clicks it.
a) Select the last of the three navigation items in the Structure window.
b) Set the Text property to #{bindings.param_SubCategoryName}.
c) Set the Rendered property to

d) The Structure should look like:

4) Test the page.


a) Run FODShoppingDashboard from the adfc-config task flow and use the table
links and the breadcrumbs to navigate around the shopping region.
b) Close the browser when you are finished and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 250

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

Oracle University and Egabi Solutions use only

#{bindings.param_CategoryId != null &&


bindings.param_SubCategoryId != null}

Practice 17-3: Implementing the Add to Cart Functionality


In this practice, you add a router and a method call to the shopping cart flow so that it can
be used either to display the cart or to add items to it. The calling page, ProductDetails, in
the shopping flow sets some parameter values that it passes to the shopping cart flow.
1) Modify the shopping cart flow to accept the following two input parameters:
Name

Value

Required

Action
ProductId

#{pageFlowScope.Action}
True
#{pageFlowScope.ProductId} False

b) Click the task-flow-definition in the Structure window.


c) Select Parameters in the Property Inspector.
d) Click Add to add the two parameters shown above.

2) Add a method call to the shopping cart flow that calls the addItemToCart()
method of FODShoppingCartAM. Set the value of its productId argument to
#{pageFlowScope.ProductId}. Navigate to the ShoppingCart view when
finished.
a) In the Data Controls panel, expand FODShoppingCartAMDataControl.
b) Drag addItemToCart(Number) to the shopping cart flow diagram.
c) In the Edit Action Binding dialog box, set the Value of the productId parameter
to #{pageFlowScope.ProductId}, and then click OK.

d) Add a Control Flow Case from addItemToCart to ShoppingCart and label it


done (you later change this to include a commit function, but for now you simply
want to go to the cart after the method call.)
e) In the addItemToCart method call, change the fixed-outcome property to
done.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 251

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

Oracle University and Egabi Solutions use only

a) Open ShoppingCartFlow.

Practice 17-3: Implementing the Add to Cart Functionality


(continued)
3) Add a router named ChooseAction as the default activity for the shopping cart
flow. The router should either display the shopping cart (display control flow case)
or add an item to it (add control flow case), depending on whether
pageFlowScope.Action has a value of Display or Add. The default action
should be to display the cart.
a) Add a Router to the flow and name it ChooseAction.
c) Create two Control Flow Cases from ChooseAction: One to addItemToCart
named add, and the other to ShoppingCart named display.
d) Add two expressions to the ChooseAction router that evaluate
pageFlowScope.Action. If the value is Add, use the add outcome. If it is
Display, use the display outcome. Hint: The add expression is:
#{pageFlowScope.Action == 'Add'}

Note: The ChooseAction property is in the Cases section under the Common tab
of the Property Inspector.
e) Set the display outcome to be the default outcome of the router.

4) The shopping cart flow is expecting parameters named Action and optionally,
ProductId. Modify the shopping flow to send the correct parameters.
a) Open the ShoppingFlow diagram.
b) Two parameters have been added to the DisplayShoppingCart task flow call in
the Parameters section of the Property Inspector. Set a value for the Action
parameter as follows:
Name

Value

Action

Display

ProductId

Leave blank (or empty)

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 252

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

Oracle University and Egabi Solutions use only

b) Mark the ChooseAction router as the default activity for the page flow.

Practice 17-3: Implementing the Add to Cart Functionality


(continued)
c) The same two parameters have been added to the AddShoppingCart task flow
call; set the values as follows:
Name

Value

Action

Add

ProductId

#{requestScope.ProductId}

5) Finally you need to get the productId from the calling page and put it into the
requestScope variable ProductId. The call to add the item to the cart should be
placed on the ProductDetails page. Hint: There is currently no binding for ProductId.
a) Open the ProductDetails page.
b) Add a button to the toolbar of the panel headers toolbar facet and label it Add
Item to Cart. Set its Action to add.
c) Add a binding for ProductId.
i) Click the Bindings tab.
ii) In the Bindings section, click Add (plus icon.)
iii) Add an attributeValues binding whose Data Source is
FODProductAMDataControl.BrowseProduct and whose Attribute is
ProductId.
d) Add a setActionListener to the Add Item to Cart button that sets the value of
#{requestScope.ProductId} to the value of
#{bindings.ProductId.inputValue} when the button is clicked.
Hint: Right-click af:commandButton, select Insert inside > ADF Faces > Set
Action Listener and set the From and To values. Make sure to put the correct
value in the To and the From properties.

6) Test by running FODShoppingDashboard from the adfc-config unbounded task


flow. Remember that the Add to Cart functionality is available from the Product
Details page. When you have finished, close the browser and undeploy the
application as described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 253

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

Oracle University and Egabi Solutions use only

The ShoppingFlow is now set up to send the Action parameter and, if needed, to
send the ProductId as well.

Practice 17-4: Implementing Create Supplier Functionality


(OPTIONAL)
This practice is very similar to 17-3, and is therefore optional. If you choose not to
complete this practice, you must begin the practices for the next lesson by opening
the starter application.
In this practice, you add a router to the ManageSupplierFlow task flow that decides
whether the UpdateSupplier page should display a supplier for update or should display a
new record where users can create a new supplier. You also add a method call to create a
new record.
Name

Value

Required

SupplierAction #{pageFlowScope.SupplierAction} True

a) Open ManageSupplierFlow.
b) Click the task-flow-definition in the Structure window.
c) Select Parameters in the Property Inspector.
d) Click Add to add the parameter shown above.

2) Add a method call to the ManageSupplierFlow task flow to call the CreateInsert
operation for a new supplier and connect it to the SupplierUpdate activity when
finished.
a) Open the ManageSupplierFlow task flow.
b) In the Data Controls panel, expand FODSupplierAMDataControl > Supplier1
> Operations and drag the CreateInsert operation to the task flow diagram to
create a method call activity.
c) Change the fixed-outcome of the CreateInsert method call activity to done.
d) Drag a Control Flow Case from CreateInsert to SupplierUpdate; its fromoutcome should default to done.
3) Set up the task flow so that a new supplier is created when a parameter passed to it
has a value of New, or that an existing supplier is updated when the parameter value is
Update.
a) Add a Router to the flow and name it ChooseAction.
b) Mark the ChooseAction router as the default activity for the page flow.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 254

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

Oracle University and Egabi Solutions use only

1) Modify the manage supplier flow to accept the following input parameter:

Practice 17-4: Implementing Create Supplier Functionality


(OPTIONAL) (continued)
c) Create two Control Flow Cases from ChooseAction: One to SupplierUpdate
named update, and the other to CreateInsert named new.
d) Add two expressions to the ChooseAction router that evaluate
pageFlowScope.SupplierAction. If the value is New, use the new outcome.
If it is Update, use the update outcome. Hint: The new expression is:
#{pageFlowScope.SupplierAction == 'New'}

Note: You define these expressions in the Cases section under the Common tab
of the Property Inspector.

4) The manage suppliers flow is expecting a parameter named SupplierAction.


Modify the show suppliers flow to send the correct parameter.
a) Open the ShowSuppliersFlow diagram.
b) Add a parameter to the ManageSupplierFlow task flow call activity using the
Parameters section of the Property Inspector (the parameter should be there by
default because you have set it on the ManageSupplierFlow task flow, so just set
its value in the task flow call activity):
Name

Value

SupplierAction #{requestScope.SupplierAction}

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 255

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

Oracle University and Egabi Solutions use only

e) Set the update outcome to be the default outcome of the router.

5) Set the requestScope variable SupplierAction. The calls to create a new


supplier or update an existing one should be placed on the BrowseSuppliers page.
a) Open the BrowseSuppliers page.
b) Add a toolbar to the panel headers toolbar facet.
c) Add a toolbar button to the toolbar and label it New Supplier. Set its Action to
update.
d) Add a setActionListener to the New Supplier button that sets the value of
#{requestScope.SupplierAction} to New when the button is clicked.
Hint: Right-click af:commandToolbarButton, select Insert inside > ADF
Faces > Set Action Listener and set the From and To values. Set the From
property to #{'New'}.

e) Add a setActionListener to the SupplierId link that sets the value of


#{requestScope.SupplierAction} to Update when the link is clicked. Set
the From property to #{'Update'}.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 256

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

Oracle University and Egabi Solutions use only

Practice 17-4: Implementing Create Supplier Functionality


(OPTIONAL) (continued)

Practice 17-4: Implementing Create Supplier Functionality


(OPTIONAL) (continued)
6) Finally, change the panel header text of the SupplierUpdate page to conditionally
display either Update Supplier or New Supplier, depending on the value of the
parameter that is passed.
a) On the SupplierUpdate page, select the panel header.
b) If you are not using resource bundle for text, change the Text to the expression
#{pageFlowScope.SupplierAction == 'New' ? 'New Supplier' :
'Update Supplier'} (all on one line.)

i) You need to make some entries to the resource bundle: Although you could
edit it directly, it may be easier to change the Text to Update Supplier, using
the resource bundle (use UPDATE_SUPPLIER_TITLE as the key), and then
change it again to New Supplier, using the resource bundle (use
NEW_SUPPLIER_TITLE as the key).
ii) Now that you have the text resources entered in the resource bundle, you can
use them in a conditional expression to define the title based on the parameter.
Enter the following in the Text property (all on one line):
#{pageFlowScope.SupplierAction == 'New' ?
storefrontuiBundle.NEW_SUPPLIER_TITLE :
storefrontuiBundle.UPDATE_SUPPLIER_TITLE}

7) Test by running FODShoppingDashboard from the adfc-config unbounded task


flow. Remember that the New Supplier functionality is available from the
BrowseSuppliers page. There is not yet a way to commit updates or inserts; you add
this in a later practice. When you are finished, close the browser and undeploy the
application as described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 257

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

Oracle University and Egabi Solutions use only

c) If you are using a resource bundle for text:

Practices for Lesson 18

In addition to changing the display based on what the user clicks on the page, you also
want to change the display depending on what the user clicks in the category tree in the
left region of the containing page. When a user clicks a category in the tree, its
subcategories should appear in the shopping region. If the user clicks a subcategory in the
tree, then the shopping region should display its products.
You accomplish this by defining a contextual event that passes parameters from the
ProductCategory (tree) region to the ShoppingFlow region. First you define task flow
parameters on the ShoppingFlow, and then you enable the category tree to pass
parameters (through the use of a bean) to the Shopping flow. You use a contextual event
to coordinate this interaction between the regions on the main page.
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, then you need to open
Storefront-18.jws, and edit the database information as described in step 4 of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 258

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

Oracle University and Egabi Solutions use only

In the previous set of practices, you enabled a different table to appear based on
parameters that were set in the ProductCatalog page. You may wonder why you used
page parameters instead of using the pageFlowScope variables directly. This is because
using parameters enables your page to accept values from outside the task flow as well.

Practice 18-1: Defining Task Flow Parameters


The contextual event that you define in the practices for this lesson makes it possible for
the user to click a category in the ProductCategory region at the left of the page and then
display the appropriate table in the ShoppingFlow region on the right of the page.
The ShoppingFlow region (ProductCatalog page) displays the appropriate table based on
pageFlowScope variables that you defined in the previous set of practices. To be able to
set the pageFlowScope variables from outside the task flow, the task flow must be able

1) Define four parameters on the ShoppingFlow task flow: CategoryId,


CategoryName, SubCategoryId, and SubCategoryName. Store them in
pageFlowScope variables of the same name.
a) Select the ShoppingFlow in the Application Navigator.
b) Select the task-flow-definition ShoppingFlow node in the Structure window.
c) Use the Parameters section of the Property Inspector to create the following input
parameters:
Name

Value

CategoryId

#{pageFlowScope.CategoryId}

CategoryName

#{pageFlowScope.CategoryName}

SubCategoryId

#{pageFlowScope.SubCategoryId}

SubCategoryName

#{pageFlowScope.SubCategoryName}

The Property Inspector should look like:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 259

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

Oracle University and Egabi Solutions use only

to receive values that are set in another region. In this practice, you define input
parameters on the ShoppingFlow task flow as the first step in setting up a contextual
event.

Practice 18-1: Defining Task Flow Parameters (continued)


Notice that this is just another way to set the pageFlowScope variables in the
ShoppingFlow task flow. The values are set either by clicking links on the
ProductCatalog page, as you defined in the previous set of practices, or they can
be set by receiving values via these input parameters on the task flow. After the
values are received, they have the same effect of setting the correct table to appear
and setting the breadcrumbs.

Oracle University and Egabi Solutions use only

In the remaining practices in this lesson, you use a contextual event to pass values
to these parameters when a node in the category tree is clicked.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 260

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

Practice 18-2: Creating a Helper Method to Evaluate EL


Several methods that you use in this section must evaluate EL expressions. To avoid
repeating blocks of code, in this practice you create a helper class with methods to
evaluate EL expressions. This class is the ADFUtil class. You can then call that helper
class whenever you need to evaluate EL.
1) In the Application Navigator, expand Application Sources, right-click the
oracle.storefront.ui package, and select New.
2) In the New Gallery select General > Java Class and click OK.
4) Select the Public and Generate a Default Constructor check boxes.
5) Replace all of the code in the class with the following code (you can copy it from
ADFUtil.txt in the \files subdirectory of your course directory):
package oracle.storefront.ui.common;
import java.util.Map;
import
import
import
import
import

javax.el.ELContext;
javax.el.Expression;
javax.el.ExpressionFactory;
javax.el.MethodExpression;
javax.el.ValueExpression;

import javax.faces.context.FacesContext;
import oracle.adf.model.BindingContext;
import oracle.adf.model.DataControlFrame;

/**
* Provides various utility methods that are handy to
* have around when working with ADF.
*/
public class ADFUtil {
/**
* When a bounded task flow manages a transaction (marked as
* requires-transaction, requires-new-transaction, or
* requires- existing-transaction), then the task flow must
* issue any commits or rollbacks that are needed.
* This is essentially to keep the state of the transaction
* that the task flow understands in synch with the state
* of the transaction in the ADFbc layer.
* Use this method to issue a commit in the middle of a task
* flow while staying in the task flow.
*/
public static void saveAndContinue() {
Map sessionMap =

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 261

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

Oracle University and Egabi Solutions use only

3) Name the class ADFUtil and put it in oracle.storefront.ui.common.

Practice 18-2: Creating a Helper Method to Evaluate EL


(continued)
FacesContext.getCurrentInstance().getExternalContext().getSess
ionMap();
BindingContext context =

dcFrame.commit();
dcFrame.beginTransaction(null);
}
/**
* Programmatic evaluation of EL.
*
* @param el EL to evaluate
* @return Result of the evaluation
*/
public static Object evaluateEL(String el) {
FacesContext facesContext =
FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression exp =
expressionFactory.createValueExpression(elContext,
el, Object.class);
return exp.getValue(elContext);
}
/**
* Programmatic invocation of a method that an EL evaluates
* to. The method must not take any parameters.
*
* @param el EL of the method to invoke
* @return Object that the method returns
*/
public static Object invokeEL(String el) {
return invokeEL(el, new Class[0], new Object[0]);
}
/**
* Programmatic invocation of a method that an EL evaluates
to.
*
* @param el EL of the method to invoke
* @param paramTypes Array of Class defining the types of the
* parameters
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 262

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

Oracle University and Egabi Solutions use only

(BindingContext)sessionMap.get(BindingContext.CONTEXT_ID);
String currentFrameName =
context.getCurrentDataControlFrame();
DataControlFrame dcFrame =
context.findDataControlFrame(currentFrameName);

Practice 18-2: Creating a Helper Method to Evaluate EL


(continued)

facesContext.getApplication().getExpressionFactory();
MethodExpression exp =
expressionFactory.createMethodExpression(elContext,
el, Object.class, paramTypes);
return exp.invoke(elContext, params);
}
/**
* Sets a value into an EL object. Provides similar
* functionality to
* the &lt;af:setActionListener&gt; tag, except the
* <code>from</code> is
* not an EL. You can get similar behavior by using the
* following...<br>
* <code>setEL(<b>to</b>, evaluateEL(<b>from</b>))</code>
*
* @param el EL object to assign a value
* @param val Value to assign
*/
public static void setEL(String el, Object val) {
FacesContext facesContext =
FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression exp =
expressionFactory.createValueExpression(elContext,
el, Object.class);
exp.setValue(elContext, val);
}
}

6) Right-click anywhere in the code editor and select Make to compile the class.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 263

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

Oracle University and Egabi Solutions use only

* @param params Array of Object defining the values of the


* parametrs
* @return Object that the method returns
*/
public static Object invokeEL(String el,
Class[] paramTypes, Object[] params) {
FacesContext facesContext =
FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =

Practice 18-3: Creating the Producer (Payload) Method


When the user clicks a category or subcategory in the tree, you need to capture the
current values and store them. These are the values (payload) that you pass to the
ShoppingFlow and use in the ProductCatalog page. In this practice, you create a
JavaBean to encapsulate the current row values. A method in this JavaBean becomes the
payload method of the contextual event.
1) Create the new Java class.
a) In the Application Navigator, expand Application Sources, right-click the
oracle.storefront.ui package and select New.
c) Name the class FODCategoryBean and put it in oracle.storefront.ui.bean.
d) Make it public and generate a default constructor.
e) Add private variable definitions for the following:
categoryId, subCategoryId (Number)
categoryName, subCategoryName (String)
At this point, the code should be:
public class FODCategoryBean {
private Number categoryId, subCategoryId;
private String categoryName, subCategoryName;
public FODCategoryBean() {
}

f) Generate accessors for these variables using either the toolbar button
(on the
visual editor pane) or use the menu SourceGenerate Accessors. Select the toplevel check box to select all accessors. Click OK to generate the accessors.
2) Add a method named onNodeClicked() that returns a bean with values set based
on the values of the node that the user clicked (you can copy it from
onNodeClicked.txt in the \files subdirectory of your course directory):
/**
* Evaluates the currently selected node in the tree returns a
* bean representing that node.
*
* @return FODCategoryBean with all properties set
*/
public FODCategoryBean onNodeClicked() {
JUCtrlHierNodeBinding node =
(JUCtrlHierNodeBinding)ADFUtil.evaluateEL("#{node}");
Row nodeRow = node.getRow();
JUCtrlHierNodeBinding parentNode = node.getParent();
Row parentRow = parentNode.getRow();

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 264

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

Oracle University and Egabi Solutions use only

b) In the New Gallery select Java Class.

Number categoryId, subCategoryId;


String categoryName, subCategoryName;
if (parentRow == null) {
// Root category selected
categoryId =
(Number)nodeRow.getAttribute("CategoryId");
categoryName =
(String)nodeRow.getAttribute("CategoryName");
subCategoryId = null;
subCategoryName = null;
} else {
// Sub-category selected
categoryId =
(Number)parentRow.getAttribute("CategoryId");
categoryName =
(String)parentRow.getAttribute("CategoryName");
subCategoryId =
(Number)nodeRow.getAttribute("CategoryId");
subCategoryName =
(String)nodeRow.getAttribute("CategoryName");
}
setCategoryId(categoryId);
setSubCategoryId(subCategoryId);
setCategoryName(categoryName);
setSubCategoryName(subCategoryName);
return this;
}

3) JDeveloper prompts you to import the supporting packages. Import the following:
oracle.jbo.Row;
oracle.jbo.domain.Number;
oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;
oracle.storefront.ui.common.ADFUtil

Note: If you are not prompted for the oracle.jbo.domain.Number package, add
it to the imports manually. Otherwise, the code will use the wrong Number class
and you will get errors when you call it.
4) Compile the class and create a data control from it.
a) Right-click anywhere in the code editor and select Make. This compiles the class.
b) Right-click the bean (FODCategoryBean.java) in the Application Navigator and
select Create Data Control, or alternatively just drag the bean from the
Application Navigator to the Data Control panel.
c) Check the Data Controls panel to ensure that the bean was added. If it is not there,
click the refresh icon
on the Application Navigator.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 265

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

Oracle University and Egabi Solutions use only

Practice 18-3: Creating the Producer (Payload) Method


(continued)

Practice 18-3: Creating the Producer (Payload) Method


(continued)

Oracle University and Egabi Solutions use only

The Data Control panel should look something like:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 266

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

Practice 18-4: Initiating the Contextual Event


The ProductCategory page starts the event sequence. When a user clicks a node in the
Category tree, an event is raised which is managed by the FODShoppingDashboard page.
In this practice, you set up the ProductCategory page to initiate the event.
1) Call the onNodeClicked() method when the user clicks a node in the tree.
a) Open the ProductCategory page.

c) Click OK to accept the default values on the Confirm Component Rebinding


page.
2) Add an event to the page named FODSelectCategory that will be registered when the
user clicks the node.
a) While still on the ProductCategory page, click the Bindings tab.
b) Expand Bindings in the Structure window.
c) Insert events (an event list) inside onNodeClicked (use the context menu).

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 267

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

Oracle University and Egabi Solutions use only

b) Drag the FODCategoryBean > onNodeClicked() method from the Data Controls
panel to the af:commandLink and select Bind Existing Link.

d) Insert an event inside the event list and set the name property to
FODSelectCategory.
The Binding Structure should look like:

You now have specified that at run time clicking a node in the Category Tree calls the
onNodeClicked() method and raises the FODSelectCategory event.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 268

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

Oracle University and Egabi Solutions use only

Practice 18-4: Initiating the Contextual Event (continued)

Practice 18-5: Creating the Consumer (Handler) Method


In this application, the producer of the event is the ProductCategory page (the category
tree). The consumer of the event is the ProductCatalog page.

To create this handler method, perform the following steps:


1) Create a new Java class for the bean as you did for the producer bean. Name the class
FODShoppingDashboardBean and put it in oracle.storefront.ui.bean. Make it
public and generate a default constructor.
2) Add the refreshCategory() method. This method uses an ADFUtil method to set
the requestScope variables to hold the category and subcategory ID and name (you
can copy it from refreshCategory.txt in the \files subdirectory of your
course directory):
/**
* Used as a consumer to a contextual event, changes the
* parameter values passed to the local area region and forces
* a refresh in that area.
*
* @param category Selected category
*/
public void refreshCategory(FODCategoryBean category) {
/*
* For the selected category, set requestScope
* variables.
* These variables are used as parameters to the local
* area region.
*/
ADFUtil.setEL("#{requestScope.CategoryId}",
category.getCategoryId());
ADFUtil.setEL("#{requestScope.SubCategoryId}",
category.getSubCategoryId());
ADFUtil.setEL("#{requestScope.CategoryName}",
category.getCategoryName());
ADFUtil.setEL("#{requestScope.SubCategoryName}",
category.getSubCategoryName());
/**
*
*
*
*/

#{requestScope.refreshLocalArea} is used as the EL to


control whether the local area region is refreshed. By
setting this to true, the region will be forced to refresh
with the new category.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 269

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

Oracle University and Egabi Solutions use only

In this practice, you create the method that is used by the consumer of the event. It
handles the information that is passed to the consumer region (the payload) as follows:
Sets the requestScope variables to reflect which Category was selected in the
tree
Encapsulates the requestScope variables in a bean that is used by the
consumer of the event (the ProductCatalog page)

Practice 18-5: Creating the Consumer (Handler) Method


(continued)
ADFUtil.setEL("#{requestScope.refreshLocalArea}",
Boolean.TRUE);
}

3) JDeveloper prompts you to import the supporting package. Import the following:
oracle.storefront.ui.common.ADFUtil;

Oracle University and Egabi Solutions use only

4) As you did with the other bean, compile the class and create a data control from it.
The Data Control panel should now look like this:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 270

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

Practice 18-6: Mapping the Contextual Event


Now that you have created the bean and added it to the Data Control panel, in this
practice you add a method action binding so that you can use it in the
FODShoppingDashboard page. The FODShoppingDashboard page is the page that
contains both the Category region and the Shopping region, so it is responsible for
coordinating the event. To accomplish this, you also add an event map to the page.
1) Add a method action binding to the refreshCategory() method.
a) Open the FODShoppingDashboard page.
c) Add a Generic Bindings > methodAction binding. Select
FODShoppingDashboardBean.refreshCategory() as the operation. Leave
the category parameters value blank.

d) Click OK to create the binding.


2) Create an event map to orchestrate the contextual event.
a) On the Bindings tab for FODShoppingDashboard, right-click the top-level node
in the Structure window and select Edit Event Map.

b) In the Event Map Editor, click Add a New Event Entry

c) In the Add New EventMap Entry dialog box:

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 271

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

Oracle University and Egabi Solutions use only

b) Click the Bindings tab.

Practice 18-6: Mapping the Contextual Event (continued)

ii) Select FODSelectCategory as the Event Name (this should be selected by


default, because it is the only event that you have defined).
iii) Select FODShoppingDashboardPageDef > refreshCategory from the
Consumer drop-down list.

iv) In the ConsumerParams section, click Add Consumer Parameter to define a


parameter named category with a value of ${payLoad} (you can use
Expression Builder to select Payload Data > payLoad.) Click OK.

d) Click OK to create the event mapping in the containing FODShoppingDashboard


page.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 272

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

Oracle University and Egabi Solutions use only

i) From the Producer drop-down list select FODShoppingDashboardPageDef


> ProductCategoryFlow1 > ProductCategoryPageDef.onNodeClicked.

Practice 18-7: Passing Values Through Region Parameters

The handler method that you defined for the event sets several requestScope variables.
In this practice, you define region parameters to pass these variables into the Shopping
region. The region parameters have the same name as the task flow parameters that you
defined in the first practice for this lesson. So the values come through the event to
requestScope variables and are passed to region parameters. The region parameter
values are passed to the task flow parameters, which in turn set the pageFlowScope
variables that the ProductCatalog page uses to conditionally render tables and
breadcrumbs, as you defined in an earlier practice.
1) One of the tasks accomplished by the refreshCategory() method in the
FODShoppingDashboard bean is to set a Boolean requestScope variable named
refreshLocalArea to true. Set a refresh condition on the ShoppingFlow region to
make use of the value of this variable, so that the region is refreshed only if
refreshLocalArea is set to true.
a) Still in the FODShoppingDashboard page definition (binding tab of the page),
select Executables > ShoppingFlow1 in the Structure window.
b) Set the RefreshCondition to #{requestScope.refreshLocalArea}.

2) Set region parameter values to the requestScope values that are set by the
refreshCategory() method in the FODShoppingDashboard bean.
a) Click the Parameters tab in the Property Inspector. Notice that the task flow
binding parameters are listed.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 273

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

Oracle University and Egabi Solutions use only

That completes building the event map and defining the producer and consumer methods.
Now you need to set the ShoppingFlow to be refreshed based on a requestScope
parameter and to accept the other parameters needed by the ProductCatalog page.

Practice 18-7: Passing Values Through Region Parameters


(continued)
Name

Value

CategoryId

#{requestScope.CategoryId}

CategoryName

#{requestScope.CategoryName}

SubCategoryId

#{requestScope.SubCategoryId}

SubCategoryName

#{requestScope.SubCategoryName}

3) Run the page and test the functionality.


a) You should see that when you click a Category in the tree, the ProductCatalog
displays the related SubCategories.
b) When you click a SubCategory, the page should display the related Products.
c) When you are finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.
4) Extra credit (if you have time): When you click a Category in the tree, you should
notice that the tree seems to be refreshed as well. Prevent that from happening so that
only the ProductCatalog region is refreshed.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 274

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

Oracle University and Egabi Solutions use only

b) Set the value property of the parameters to the following values.

Practice 18-8: Modifying the JSF Life Cycle (Optional Exercise)


If you have time: In this practice you modify the JSF life cycle to print out a message
whenever the user navigates to a new page. In a real application, you could use a
similar modification to call a routine to, for example, perform some cleanup activities.
1) In the oracle.storefront.ui.common package, create a new Java class named
StorefrontPhaseListener.java that implements the PhaseListener interface
and displays a message when the view ID of a page changes.

b) In the Create Java Class dialog box, enter a name of


StorefrontPhaseListener, and then click OK.
c) Right-click the editor and select Source > Implement Interface.
d) On the Hierarchy tab of the Implement Interface dialog box, select javax > faces
> event > PhaseListener and click OK.
e) Add a private String attribute named storedViewId to store the view ID by
adding the following on the line just after the first left brace:
private String storedViewId = null;

f) Modify the getPhaseId() method to return the PhaseId of whatever life cycle
phase being executed with the following code:
public PhaseId getPhaseId() {
return PhaseId.ANY_PHASE;
}

g) Modify the afterPhase() method to store the view ID when the view is first
restored:
public void afterPhase(PhaseEvent phaseEvent) {
if (phaseEvent.getPhaseId() == PhaseId.RESTORE_VIEW) {
storedViewId =
phaseEvent.getFacesContext().getViewRoot().getViewId();
}
}

h) Modify the beforePhase() method so that just before the page is rendered a
message appears if the current view ID is not the same as the stored view ID:
public void beforePhase(PhaseEvent phaseEvent) {
if (phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE)
{
String viewId =
phaseEvent.getFacesContext().getViewRoot().getViewId();
if (storedViewId != null &&
!viewId.equalsIgnoreCase(storedViewId)) {
System.out.println("Changing pages");
}
storedViewId = null;
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 275

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

Oracle University and Egabi Solutions use only

a) Right-click oracle.storefront.ui.common to invoke the New Gallery, select Java


Class in the General category, and then click OK.

Practice 18-8: Modifying the JSF Life Cycle (Optional Exercise)


(continued)
}
}

2) Register the new phase listener with JavaServer Faces.


a) Open faces-config.xml in the editor by double-clicking it in the Application
Navigator (under WebContent > WEB-INF).
b) Select the Overview tab.
c) On the Life Cycle panel, click Add to add a Phase Listener.
oracle.storefront.ui.common.StorefrontPhaseListener.

3) Test the functionality by invoking the application and changing views. Because you
have only one view activity in the application, with all others being part of a region
on the same page, you need to add another page to the application to test it.
a) Open adfc-config and add a view activity called Start.
b) Add a control flow case from Start to FODShoppingDashboard whose fromoutcome is start.
c) Create the Start.jspx page by double-clicking the Start view activity in the
editor.
d) Add a button to the page labeled Start Shopping! and set its Action to start.
e) Run the Start page from the adfc-config diagram.
f) When the page comes up, right-click the JDeveloper log and select Clear.
g) Click Start Shopping!. You should see the message in the log, Changing
pages.
h) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 276

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

Oracle University and Egabi Solutions use only

d) Enter the complete path to the phase listener and the class name:

Practices for Lesson 19

There are three places in the application where a commit is needed:


The first is the Add to Cart, where the user adds items to the cart. So far, the user
can add items but they are not persisted.
The second area is the Checkout.
The third area is being able to update, delete, and add Suppliers.
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, then you need to open
Storefront-19.jws, and edit the database information as described in step 4 of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 277

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

Oracle University and Egabi Solutions use only

In this practice, you complete the application by adding transaction management. So far,
the application navigates to all the pages and displays data, but the commit functions are
missing.

Practice 19-1: Saving the Shopping Cart


In this practice, you add a commit to the shopping cart functionality to persist items that
are added to the cart.
1) Use the Commit operation of FODShoppingCartAMDataControl to commit items
after adding them to the cart.
a) Open the ShoppingCartFlow.

c) Set the fixed-outcome property to done.


d) Select the done control flow case and change its to-activity-id to Commit.
e) Add a Control Flow Case labeled done from Commit to ShoppingCart. Set the
from-outcome property to done.
2) Test the functionality:
a) Run FODShoppingDashboard from the adfc-config task flow.
b) Add an item to the cart; it should remain in the cart when you redisplay it and
when you rerun the application.
c) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 278

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

Oracle University and Egabi Solutions use only

b) From the Data Controls panel, drag the Commit operation from
FODShoppingCartAMDataControl > Operations to the ShoppingCartFlow
page flow.

Practice 19-2: Updating, Deleting, and Displaying Details of


Shopping Cart Items
In this practice, you add data management to the shopping cart. You add the ability for
users to update or delete a line item or to display details about it. You use a bean that
contains a single method to perform a delete followed by a commit. By using this
method, a single button click executes both parts of the transaction. Without it, you
would have to either click two buttons or wire the two functions together.

a) In the Applications Navigator, right-click the oracle\storefront\ui\bean


directory and select New > JavaClass.
b) Name the class FODCommitDeleteBean and set the package to
oracle.storefront.ui.bean.
c) Make it Public and include a Constructor.
2) Add a method named onDeleteItem that calls the ADFUtil.invokeEL() helper
method to execute the EL expression that you pass in as a parameter. In this case, it
will execute a Delete and a Commit. Note the Delete and Commit methods must be in
the Page Definition Bindings for any page that uses them.
a) Add the following code (you may copy the code from onDeleteItem.txt in
the \files subdirectory of your courseware directory):
/**
* Deletes the current selected row in the Shopping Cart.
*
* @param actionEvent
*/
public void onDeleteItem(ActionEvent actionEvent) {
ADFUtil.invokeEL("#{bindings.Delete.execute}");
ADFUtil.invokeEL("#{bindings.Commit.execute}");
}

b) Include the following imports as JDeveloper prompts you:


javax.faces.event.ActionEvent
oracle.storefront.ui.common.ADFUtil

c) Right-click anywhere in the code and select Make.


3) Register the bean as a managed bean.
a) Open the adfc-config.xml pageflow.
b) Click the Overview tab.
c) Select the Managed Beans navigation tab.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 279

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

Oracle University and Egabi Solutions use only

1) Add a bean to the oracle.storefront.ui.bean package named


FODCommitDeleteBean.

Practice 19-2: Updating, Deleting, and Displaying Details of


Shopping Cart Items (continued)

Name

FODCommitDeleteBean

Class

oracle.storefront.ui.bean.
FODCommitDeleteBean

Scope

request

4) Complete the ShoppingCart page by adding buttons for Update, Delete, and Details;
these buttons should relate to the rows of the table. Add a panel collection around the
table to contain the buttons.
a) Open the ShoppingCart page fragment.
b) Surround the af:table with a Panel Collection.
c) Insert a Toolbar inside the Panel Collection's toolbar facet.
d) Drag the FODShoppingCartAMDataControl > Commit operation to the
toolbar as an ADF Toolbar Button. This adds the button and also adds the
Commit operation to the page definition.
e) Set the following properties on the toolbar button:
Id

updateMenu

Text (optionally use


the resource bundle)

Update

Action

<default>

Disabled

Reset to default value

f) Add a second Toolbar Button to the toolbar. This time add it from the
Component Palette, or right-click and select insert inside.
g) Set the following properties on the second toolbar button:
Id

deleteMenu

Text (use the resource


bundle)

Delete

Action

<default>

ActionListener

#{FODCommitDeleteBean.onDeleteItem}

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 280

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

Oracle University and Egabi Solutions use only

d) Add a managed bean by clicking the Add (green plus sign) with the following
attributes:

Practice 19-2: Updating, Deleting, and Displaying Details of


Shopping Cart Items (continued)
Id

Leave blank

Text (optionally use


the resource bundle)

Details

Action

<default>

5) The method you added in the managed bean uses a commit binding and a delete
binding. When you added the commit button from the Data Control panel, JDeveloper
added the commit binding for you. Now manually add the delete binding to the page.
a) Select the Bindings tab in the editor of the ShoppingCart page fragment.
b) In the Bindings section, click Add.
c) In the Insert Item dialog box, select Generic Bindings > action and click OK.
d) In the Create Action Binding dialog box:
i) Expand FODShoppingCartAMDataControl and select ShoppingCart1.
ii) From the Select an Iterator drop-down list, select
ShoppingCartItem1Iterator.
iii) From the Operation drop-down list, select Delete and click OK.

e) In the Property Inspector, change the InstanceName to


FODShoppingCartAMDataControl.ShoppingCart.ShoppingCartItem1.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 281

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

Oracle University and Egabi Solutions use only

h) Add a third toolbar button and set the properties as follows:

Practice 19-2: Updating, Deleting, and Displaying Details of


Shopping Cart Items (continued)
6) Use partial page rendering to refresh the table to show the changes when the user
clicks either Update or Delete.
a) Click the Design tab in the editor.

7) Enable the quantity to be updated.


a) With the af:table still selected, click the Edit icon on the Property Inspector
and ensure that the Row Selection check box is selected, and click OK.
b) Select the af:outputText - #{rowQuantity} and convert it to an Input
Text.

c) Remove the value from the Label attribute on the Input Text.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 282

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

Oracle University and Egabi Solutions use only

b) Select af:table in ShoppingCart.jsff and set PartialTriggers on the table to


include updateMenu and deleteMenu.

Practice 19-2: Updating, Deleting, and Displaying Details of


Shopping Cart Items (continued)
8) Test the functionality.
a) Run FODShoppingDashboard, add an item to the cart, update a quantity or two,
delete an item (be sure to leave at least one item in the cart), and so on. (The only
button you havent yet connected is the details buttonyou do this next.)
When you update a quantity and click Update, you should notice that the line item
total also changes.

9) Use a pop-up window to display details of the item when a user clicks the Details
button.
a) In ShoppingCart.jsff, drag a Popup from the Component Palette to the
af:panelCollection in the Structure window.
b) Set the following properties on the pop-up:
Id

ProductDetails

ContentDelivery

LazyUncached

c) Insert a Dialog inside the pop-up.


d) Drag the FODShoppingCartAMDataControl > ShoppingCart1 >
ShoppingCartItem1 to the af:dialog as an ADF Read-only Form.
i) Do not include Navigation Controls or a Submit button.
ii) Include the following columns, in the same order:
ProductName
Description
AdditionalInfo
ListPrice

e) Set the following properties on the af:dialog:


Type

ok

Title

#{bindings.ProductName.inputValue}

(use Expression Builder)

f) Add a call to the pop-up from the Details button: Click back on the ShoppingCart
page, insert a Show Popup Behavior in the Details button, and set the PopupId
to ProductDetails.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 283

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

Oracle University and Egabi Solutions use only

b) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

10) Test the functionality.


a) When you click Details on the ShoppingCart page, the productDetails pop-up
should display the dialog.

b) When you have finished, close the browser and undeploy the application as
described in step 6(i) of Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 284

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

Oracle University and Egabi Solutions use only

Practice 19-2: Updating, Deleting, and Displaying Details of


Shopping Cart Items (continued)

Practice 19-3: ControllingTransactions in the Checkout Flow


In this practice, you add transactional capability to the Checkout flow.
1) Implement transaction control in the CheckoutFlow task flow, starting a new
transaction when entering the flow and terminating with either a commit or a
rollback.
a) Open the CheckoutFlow.

c) Select the SubmitOrder task flow return and set the End Transaction property
to commit.
d) Select CancelOrder task flow return and set the End Transaction property to
rollback.
2) Test. When you click Commit, any changes you have made to the shipping and
billing information is committed. In a real SOA-integrated application, this could, for
example, commit an order and start some back-end processing.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 285

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

Oracle University and Egabi Solutions use only

b) On the Behavior panel of the Property Inspector, set the transaction property to
new-transaction. This means that when this flow is called, it starts a new
transaction.

Practice 19-4: Adding CRUD Functionality for Suppliers


(Optional Exercise)
On the ManageSuppliers flow, you have already added the functionality to create a new
supplier and to update supplier information, but you have not added the ability to commit
the updates and deletes. In this practice, you implement the ability to add, update, and
delete suppliers.

1) Add transaction control to the ManageSupplierFlow task flow as you did with the
ShoppingCartFlow, with commit and rollback functionality.
a) Open ManageSupplierFlow in the editor.
b) In the Structure window, select task-flow-definition ManageSupplierFlow.
c) In the Property Inspector, click the Behavior navigation tab and set transaction
to new-transaction.
d) In the editor, select the Save task flow return and set its End Transaction
property to commit.
e) In the editor, select the Cancel task flow return and set its End Transaction
property to rollback.
f) Save your work.
2) Add the ability to delete a supplier to the BrowseSuppliers page.
a) Open the BrowseSuppliers page in the editor.
b) Check that the table has row selection enabled by selecting af:table in the
Structure window and then clicking Edit
in the Property Inspector. Ensure
that the Row Selection check box is selected.
c) In the Data Control panel, expand FODSupplierAMDataControl > Supplier1 >
Operations and drag the Delete operation to the toolbar in the toolbar facet of
the Panel Header on the page, creating an ADF Toolbar Button and set the
following properties on the button:
Id
ActionListener

deleteSupplier

Set to the onDeleteItem method of the managed


bean (use the edit down-arrow button to select
it)

d) The onDeleteItem() method calls bindings.Delete.execute and


bindings.Commit.execute. When you added the delete operation as a button,
the Delete binding was added, but there is no Commit binding. Add a Commit
binding to the page definition.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 286

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

Oracle University and Egabi Solutions use only

This practice is optional because the steps are similar to what you have done
previously. If you choose not to add CRUD functionality for Suppliers, you must
begin the practices for the next lesson by opening the starter application.

Practice 19-4: Adding CRUD Functionality for Suppliers


(Optional Exercise) (continued)
i) Click the Bindings tab.
ii) In the Bindings section, click Add.
iii) In the Insert Item dialog box, select action and click OK.
iv) In the Create Action Binding dialog box:
(1) Select the FODSupplierAMDataControl.
(2) Select the Commit operation from the drop-down list.
e) To improve the appearance of the buttons, change the Width of the Panel
Header to 500 Pixels.
f) To ensure that the table is refreshed after the record is removed, use the Edit
function to set the Partial Triggers property on the table to the ID of the Delete
button.

g) Save your work.


3) Test the functionality.
a) Run FODShoppingDashboard from the adfc-config task flow.
b) Click the Suppliers tab and resize the left panel of the panel splitter until you can
see the New Supplier and Delete buttons.
c) Select the supplier that you previously added and click Delete. You should see
that the supplier is removed from the row.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 287

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

Oracle University and Egabi Solutions use only

(3) Click OK.

Practice 19-4: Adding CRUD Functionality for Suppliers


(Optional Exercise) (continued)
d) Close the browser. In the JDeveloper log, click the Target URL link to rerun the
page.
e) Select the Suppliers tab. You should see that the supplier you deleted is no longer
in the table even when the data is requeried.

Oracle University and Egabi Solutions use only

f) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 288

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

Practices for Lesson 20

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, then you need to open
Storefront-20.jws, and edit the database information as described in step 4 of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 289

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

Oracle University and Egabi Solutions use only

In the practices for this lesson, you set up the application to use security. You create users
and roles in an identity store, and you assign permissions to roles. You also create login
and error pages. You then use ADF security to manage access to pages, task flows, and
entity objects, and you programmatically access the security context by using global
security expressions and a security proxy bean.

Practice 20-1: Configuring the Application to Use ADF Security


In this practice, you set up the application to use ADF security for both authentication
and authorization.

2) Invoke the Configure ADF Security Wizard and configure the application to use ADF
security for both authentication and authorization.
a) With the StorefrontUI project selected in the Application Navigator, select Tools
> Configure ADF Security.
b) On the ADF Security page of the wizard, select the ADF Authentication and
Authorization option, and then click Next.
c) On the Authentication Type page of the wizard, select the Form-Based
Authentication option and the Generate Default Pages check box. Click Next.
d) On the Identity Store page of the wizard, select the Application XML option and
then click Next.
e) On the Automatic Policy Grants page of the wizard, select the Grant to All
Objects option and then click Next.
f) Click Next to skip the Authenticated Welcome page of the wizard without
redirecting to another page (you can change this later, if needed).
g) The Summary page of the wizard displays a list of files that will be changed or
created. Click Finish to create the security configuration.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 290

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

Oracle University and Egabi Solutions use only

1) Examine the existing files in the Descriptors node of the Application Resources
panel.

h) Click OK to acknowledge the Security Infrastructure Created dialog box.


i) Save your work.
3) Reexamine the files in the Application Resources panel. You can see that the
Configure ADF Security Wizard created a new file, jazn-data.xml.

4) If you look in the file system, you can compare the modified dates to see which files
have been changed.
a) First, look in the .adf > META-INF subdirectory of your application. You can
see that the adf-config.xml file has just been changed.
b) Next, look in the src > META-INF subdirectory of your application. You can
see that all files except for weblogic-application.xml have been changed.
c) Finally, look in the StorefrontUI > public-html > WEB-INF subdirectory
of your application. You can see that web.xml and weblogic.xml have been
changed (actually, weblogic.xml is a new file).
d) Notice that the changed files are the ones that the Summary page of the Configure
ADF Security Wizard reported to be created or changed.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 291

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

Oracle University and Egabi Solutions use only

Practice 20-1: Configuring the Application to Use ADF Security


(continued)

Practice 20-1: Configuring the Application to Use ADF Security


(continued)

The default realm name for the optional XML identity store.

The policy store for the Storefront-12 application, consisting of application


roles and a policy. The policy grants permissions on resources (task flows and
pages) to the application roles. Note that anonymous-role is a member of
the test-all role, which is granted access to all of the task flows, and that
anonymous-role also has access to the login and error pages.

6) In a similar fashion, examine:


a) jps-config.xml: Definitions have been added for service providers, service
instances, and the context for Java Platform Security.
b) adf-config.xml: The JaasSecurityContext entry has been added,
specifying that both authentication and authorization are enforced.
7) In a similar fashion, from the Application Navigator open web.xml and
weblogic.xml (StorefrontUI > Web Content > WEB-INF):
a) web.xml has added initialization parameters for the JpsFilter, along with a
definition for the adfAuthetication servlet, a security constraint, the login
configuration (form-based with the login and error pages), and a security role,
valid-users.
b) weblogic.xml is a newly created file that assigns the principal name users to
the security role valid-users.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 292

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

Oracle University and Egabi Solutions use only

5) In the JDeveloper Application Resources panel, double-click jazn-data.xml to


open it, and then select the Source tab to examine the entries. It is a newly created
file that contains:

Practice 20-2: Defining Users in the Identity Store


In this practice, you define some users to test security.
1) Create the following users in the default security realm, using welcome1 as the
password for each: drapheal, sking, bernst, and pgamer.
a) With the jazn-data.xml file open in the editor, click Manage Users and Roles.

c) In the Add User dialog box, enter the name (such as DRAPHEAL) and the
crendentials (welcome1), and then click OK.

d) Repeat steps b) and c) for each user; the users appear in the Users list. Instead of
pgamer, you can add your own name if you would prefer to.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 293

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

Oracle University and Egabi Solutions use only

b) In the Edit JPS Identity & Policy Store dialog box, select Identity Store >
jazn.com > Users in the tree at the left, and then click Add in the Users panel.

Practice 20-3: Defining Roles


In this practice, you define the roles that you want to be able to access the application. To
do so, you think about the functions and groups of functions that users need to perform,
which fall into four categories:
Managers in the company need to view and update information about suppliers,
but they do not need to delete suppliers and they do not need to access the
shopping portal.
Clerks in the company need to be able to read, update, and delete supplier
information, but they do not need to access the shopping portal.
Customers need to be able to shop and to view the list of suppliers, but do not
need to update or enter new suppliers.
In addition, application developers need to temporarily be able to access everything for
testing purposes. There is currently one developer working on the application.
1) Create the identity store roles manager, clerk, customer, and developer.
a) Still in the Edit JPS Identity & Policy Store dialog box, select Identity Store >
jazn.com > Roles in the tree at the left, and then click Add in the Roles panel.
b) In the Add Role dialog box, enter the Name manager and click OK.
c) Repeat steps b) and c) to add the other three roles; the roles appear in the Roles
list along with the test-user role that the security configuration created.

2) Add the following users to the roles:


manager

SKING

clerk

BERNST

customer

DRAPHEAL (use this exact name)

developer

PGAMER (or your own name if you created it as a user)

a) With Roles selected in the tree on the left, select the Member Users tab.
b) In the Roles list, select manager.
c) On the Member Users tab, select SKING in the Available list and shuttle to the
Selected list.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 294

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

Oracle University and Egabi Solutions use only

d) Repeat steps b) and c) for each role.


3) Create application roles that correspond to the identity store roles, prefixed by fod_,
such as fod_customer. Also create a fifth application role called fod_user.
a) Still in the Edit JPS Identity & Policy Store dialog box, select Application Policy
Store > Storefront-xx > Application Roles in the tree at the left, and then click
Add in the Application Roles panel (where xx is the number of the application
you are using.)
b) Add roles as you did in the identity store, prefacing the role name with fod_.
c) Add another application role named fod_user.
4) To each application role, add its corresponding identity store role (for example, add
customer to fod_customer.) Then add clerk, customer, manager, and
developer to fod_user.

5) Click OK, and then save your work.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 295

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

Oracle University and Egabi Solutions use only

Practice 20-3: Defining Roles (continued)

Practice 20-4: Implementing Security on Task Flows and Pages


In this practice, you grant to the roles the appropriate access to task flows and pages.
1) Grant managers, clerks, and developers access to the function of updating suppliers.
a) In the editor for the jazn-data.xml file, select the Overview tab.

c) In the Select Roles dialog box, select the check boxes for fod_manager,
fod_clerk, and fod_developer, and then click OK.
Note: If all of the roles do not appear in the Select Roles dialog box, then close
jazn-data.xml and reopen it. The roles should then appear.

d) With the fod_clerk role selected in the Granted to Roles column, select the
View check box in the Actions column.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 296

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

Oracle University and Egabi Solutions use only

b) Select the ManageSupplierFlow task flow, and in the Granted to Roles column,
click Add Application Role
.

Practice 20-4: Implementing Security on Task Flows and Pages


(continued)

e) Repeat step d) for the fod_developer and the fod_manager roles.


a) In the editor, select ShoppingFlow.
b) Add the fod_customer and fod_developer application roles.
c) Select each role in turn and add the View action.
d) Perform steps a), b), and c) for ShoppingCartFlow, ProductCategoryFlow, and
CheckoutFlow.
3) Grant all roles access to displaying the suppliers.
a) Select ShowSuppliersFlow.
b) Add the fod_user application role.
c) Add the View action.
4) Ensure that all users can access the FODShoppingDashboard page.
a) Click the Web Pages tab.
b) Select the FODShoppingDashboard page.
c) Click Add, and then add the fod_user application role.
d) Add the View action.
5) Ensure that a login screen appears when you invoke the application.
a) Click the Web Pages tab.
b) Select the FODShoppingDashboard page.
c) Select the test-all role and deselect the View check box.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 297

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

Oracle University and Egabi Solutions use only

2) Grant customers and developers access to the shopping application.

Practice 20-5: Testing Application Authentication and


Authorization
In this practice, you test the authentication and authorization that you have set up.
1) Test authentication by entering incorrect credentials.
a) Open adfc-config in the editor.

c) In the login page, enter a fake username and password, and then click Submit.

The error page should display the message:

Note: When using Internet Explorer, you may receive an HTTP error instead
of seeing the error page.
2) Test authorization.
a) Click the browsers Back button.
b) In the login page, enter the username SKING, a valid user who is not authorized to
use the shopping application. Enter the password welcome1, and then click
Submit. The FODShoppingDashboard page appears, but the shopping application
is not visible. You see data only when you select the Suppliers tab.
Note: If you encounter an error when entering login information after using the
Browsers Back button, then rerun the application.
c) Click the Suppliers tab, and then click the SupplierId in one of the rows. The
supplier detail is shown.
d) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.
e) Run the application again and enter credentials for DRAPHEAL, who does have
access to the shopping application. The FODShoppingDashboard page should
then appear with the shopping application visible.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 298

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

Oracle University and Egabi Solutions use only

b) Right-click the FODShoppingDashboard page and select Run.


Note: If you encounter an error when running the application, then undeploy the
application and then terminate the default server. You do this the same way you
undeploy an application, except that you select DefaultServer instead of an
application. Then rerun the application.

Practice 20-5: Testing Application Authentication and


Authorization (continued)
f) Click the Suppliers tab, and then click the SupplierId in one of the rows. You
should receive an error indicating that the authorization check failed, because
DRAPHEAL does not have access to the ManageSupplierFlow task flow.

Oracle University and Egabi Solutions use only

g) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 299

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

Practice 20-6: Implementing Entity Object Security


1) Because suppliers, clerks, and managers (also the application developer) all have
access to the Suppliers data, secure the entity object and grant the appropriate
permissions. Managers should not be able to delete supplier records.
a) Select SupplierEO in the Application Navigator.

c) In the Edit Security dialog box, enable security on all operations, and then click
OK.

d) In the Structure window, right-click SupplierEO and select Edit


Authorization.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 300

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

Oracle University and Egabi Solutions use only

b) In the Structure window, right-click SupplierEO and select Edit Security.

e) In the Edit Authorization dialog box, grant the following privileges:


Privileges

Roles

Read

fod_user

Update

fod_clerk, fod_developer, fod_manager

Delete

fod_clerk, fod_developer

f) Click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 301

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

Oracle University and Egabi Solutions use only

Practice 20-6: Implementing Entity Object Security (continued)

Practice 20-7: Testing Entity Object Security


In this practice, you test entity object security in the Business Component Browser.
1) Test the implementation of read-only access to the SupplierEO entity object.
a) In the adfc-config task flow diagram, right-click FODShoppingDashboard and
select Run.
b) In the login dialog box, enter the user name DRAPHEAL, whose customer role
has read-only access to the SupplierEO. Enter the password welcome1 and click
Submit.
d) Click New Supplier. You should receive an authorization error.

e) Close the browser and run the application again, this time logging in as SKING,
who has the manager role. Click the Suppliers tab. You should see that the
Delete button is disabled. However, when you click New Supplier, or when you
click a supplier ID link, you should be able to navigate to the New Supplier or the
Update Supplier window.
f) Close the browser and undeploy the application as described in step 6(i) of
Practice 2-4.
g) Run the application again, this time logging in as BERNST, who has the clerk
role, or as PGAMER, who has the developer role. Click the Suppliers tab. You
should see that the Delete button is now enabled. Also, when you click New
Supplier, or when you click a supplier ID link, you should be able to navigate to
the New Supplier or the Update Supplier window.
h) Close the browser and undeploy the application.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 302

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

Oracle University and Egabi Solutions use only

c) Click the Suppliers tab. You should notice that the Delete button is disabled.

Practice 20-8: Accessing Security Context Programmatically


In this practice, you use the SecurityContext API to retrieve security information
programmatically.
1) In the Application Navigator, double-click BaseApplicationModuleImpl.java to
open it in the editor.
2) Add a method to retrieve the username from the security context.

public String getUserName() {


return
ADFContext.getCurrent().getSecurityContext().getUserName().toUpperCa
se;
}

b) Press [Alt] + [Enter] if prompted to import oracle.adf.share.ADFContext.


3) Add a method to determine whether the user is in a certain role.
a) Add the following code just above the closing right brace:
public boolean isUserInRole(String role) {
return
ADFContext.getCurrent().getSecurityContext().isUserInRole(role);
}

4) Expose the added methods to the client interface of FODShoppingCartAM


application module.
a) In the Application Navigator, double-click FODShoppingCartAM to open it in
the editor.
b) Click the Java navigation tab.
c) In the Client Interface section, click Edit

d) In the Edit Client Enterface dialog box, shuttle getUserName():String and


isUserInRole(String):boolean from the Available list to the Selected list and
then click OK.
e) Save your work.
5) Test the functionality.
a) In the Application Navigator, right-click FODShoppingCartAM and select Run
from the context menu.
b) In the JAAS Security login dialog box, enter the Principal of DRAPHEAL and the
Credentials of welcome1, and then click OK.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 303

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

Oracle University and Egabi Solutions use only

a) Add the following code just above the closing right brace:

Practice 20-8: Accessing Security Context Programmatically


(continued)

c) In the Business Components Brower, double-click FODShoppingCartAM.

e) Select isUserInRole from the Method drop-down list and enter customer as the
Value. Click Execute. You should see the Return value of true.
f) Change the Value to manager and click Execute. The Return value should be
false.
g) Close the Business Component Browser.
h) If you would like to do so, you can run the Application Module again and test
users that are in different roles. Close the Business Component Browser after each
test.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 304

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

Oracle University and Egabi Solutions use only

d) Select getUserName from the Method drop-down list and click Execute. You
should see the Return value of DRAPHEAL.

Practice 20-9: Conditionally Displaying a Component Based on


User Role
When you tested the Web application and logged in as a customer, clicking the New
Supplier button produced an authorization error, which is not a good situation for a user
who may have no idea what this means. It would be better to prevent the customer from
clicking this button. In this practice, you use expression language so that the button does
not appear when the logged-in user does not have permission to run the task flow.

a) Open BrowseSuppliers.jsff in the editor.


b) Select the New Supplier button and set the Rendered property to
#{!securityContext.userInRole['fod_customer']}.
2) Test the new functionality:
a) Run the application and log in as a customer (DRAPHEAL)the button should not
appear.
b) Run the application again and log in as a user in one of the other roles, such as
SKING. The button should now appear.
3) Although this works when you know the role that has access to the task flow, you do
not want to have to change the code if other roles are created or if grants for
customers should change. Set the button property so that the button does not appear
for any user who does not have permission to view the task flow.
a) Obtain the complete name of the task flow.
i) Open jazn-data.xml and click the Task Flows tab.
ii) Click the Source tab at the bottom of the editor.
iii) In the search field, enter ManageSupplier.
iv) Copy [Ctrl+c] the entire task flow name (everything between the <name> and
</name> tags.)

b) Open or switch to BrowseSuppliers.jsff in the editor.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 305

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

Oracle University and Egabi Solutions use only

1) You know that customers do not have the view permission for the
ManageSupplierFlow task flow. Set a property on the button that invokes that task
flow so that it does not appear for customers.

Practice 20-9: Conditionally Displaying a Component Based on


User Role (continued)

4) Ensure that the button appears if authentication security is not enabled. Instead of
using a global security expression, write a security proxy bean to check the security.
Name the bean FODSecurityBean.
a) Create a new Java class in your oracle.storefront.ui.bean package with the
following code (you can copy the code from SecurityBean.txt in the \files
subdirectory):
package oracle.storefront.ui.bean;
import oracle.adf.share.ADFContext;
public class FODSecurityBean {
public FODSecurityBean() {
}
public boolean isAuthorizationEnabled() {
return
(ADFContext.getCurrent().getSecurityContext().isAuthorizati
onEnabled());
}
}

b) Register FODSecurityBean as a managed bean:


i) Open adfc-config.xml and click the Overview tab.
ii) Click the Managed Beans navigation tab.
iii) In the Managed Beans section of the page, click Add

iv) Set the following properties:


Property

Value

Name

FODSecurityBean

Class

oracle.storefront.ui.bean.FODSecurityBean

Scope

request

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 306

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

Oracle University and Egabi Solutions use only

c) Click the New Supplier button and set the Rendered property to
#{securityContext.taskflowViewable['']}, and then paste the
complete task flow name between the single quotation marks.

Practice 20-9: Conditionally Displaying a Component Based on


User Role (continued)
v) On the BrowseSuppliers page fragment, change the Rendered property of
the New Supplier button to the following expression:
#{FODSecurityBean.authorizationEnabled ?
securityContext.taskflowViewable['/WEBINF/oracle/storefront/ui/flow/ManageSupplierFlow.xml#Mana
geSupplierFlow'] : true}

Oracle University and Egabi Solutions use only

c) Test the functionality as before, making sure that the button appears for clerks,
managers, or developers, and that it does not appear for customers.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 307

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

Practice 20-10: Modifying the Hard-Coded User Name to Use the


API
Previously you hard coded the user name that is used to initialize the shopping cart. In
this practice, you replace the hard-coded name with a call to the method you just added.
1) Modify the TODO item in the base application module code to use the security API.
a) In the editor, open or switch to BaseApplicationModuleImpl.java.
b) Click the pink box in the right margin of the code to go to the TODO item.

d) Delete the commented TODO lines.


e) Add a clause that sets the userPrincipal variable to the hard-coded string if
security is not implemented. Change the line:
String userPrincipal = getUserName();

to
String userPrincipal;
if
(ADFContext.getCurrent().getSecurityContext().isAuthorizati
onEnabled())
userPrincipal = getUserName();
else
userPrincipal = "DRAPHEAL";

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 308

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

Oracle University and Egabi Solutions use only

c) Replace the hard-coded user name with a call to getUserName().

Practice 20-10: Modifying the Hard-Coded User Name to Use the


API (continued)
2) Test the functionality.
a) Run the FODShoppingCartAM and log in as DRAPHEAL.
b) In the Business Component Browser, double-click FODShoppingCartAM.
c) Select init from the Method drop-down list and click Execute.
d) Double-click ShoppingCart1 and click Cancel in the Bind Variables dialog box
to accept the values that were set in the init() method.

3) Close the Business Component Browser when you have finished.


4) Disable security by running the Configure ADF Security Wizard (Tools > Configure
ADF Security) and selecting the option to Remove ADF Security Configuration.
Then run the application again to ensure that the button appears and that the shopping
cart has items.
You can probably see that security should be considered from the beginning, rather than
adding it at the end, so that the UI could be better designed to consider roles and their
access to task flows.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 309

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

Oracle University and Egabi Solutions use only

e) The shopping cart for DRAPHEAL should be shown.

Practices for Appendix A


In this practice, you use the database diagrammer to create a visual representation of the
database schema. You also create a new database component (a table) and create the
DDL to add it to the schema.

If you choose to work on this practice, start with a clean application by opening
Storefront-A.jws and editing the database information as described in step 4 of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 310

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

Oracle University and Egabi Solutions use only

This practice is optional and does not affect any of the other practices. You should
work on it only if you have extra time.

Practice A-1: Creating a Database Diagram with Existing Schema


Objects
In this practice, you examine existing schema objects and use some of them in a new
database diagram.
1) In the Storefront application (the one that you created) in JDeveloper, examine the
objects in the FOD schema.
b) In the Application Resources section, expand the Connections and Database
nodes, and you should see the FOD connection that you created in an earlier
practice.

c) Expand the FOD node to view the types of database objects that the schema
contains.
2) Create a new database diagram named FODSchema and put it in the
oracle.fod.storefront.design package.
a) In the Application Navigator, right-click the StorefrontModel project and select
New from the context menu.
b) In the New Gallery:
i) Expand the General node if it is not already expanded.
ii) Select Diagrams.
iii) In the Items panel, select Database Diagram.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 311

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

Oracle University and Egabi Solutions use only

a) In the Application Navigator, expand the Application Resources section.

iv) Click OK.


c) In the Create Database Diagram dialog box:
i) Change the name for your diagram to FODSchema.
ii) Change the package to oracle.fod.storefront.design.

iii) Click OK. The blank diagram opens in the editor.


3) Depict the Orders and OrderItems table on the schema diagram.
a) In the Application Resources window, expand the Connections > Database >
FOD schema node, and then expand Tables.
b) Use Ctrl-click to multiselect the Orders and Order_Items tables and drag them
onto the diagram surface.
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 312

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

Oracle University and Egabi Solutions use only

Practice A-1: Creating a Database Diagram with Existing Schema


Objects (continued)

c) In the Specify Location dialog box, change the offline database name to FodDB
and then click OK to copy the database objects to the new offline database in
your project and to place them on your diagram.

d) The two tables are depicted on your diagram. Notice that the table icon has two
compartments. The top compartment displays the column names and their data
types, and the bottom compartment displays information about primary and
foreign keys. Your diagram should look something like the screenshot below.
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 313

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

Oracle University and Egabi Solutions use only

Practice A-1: Creating a Database Diagram with Existing Schema


Objects (continued)

e) You can modify column information in the diagram, although you shouldnt
modify any of the table information at this time. To modify column information,
you can click a column in the Orders table to select it, and then click again. You
can modify the name, data type, and size of the column on the diagram.
Alternatively you can double-click the table itself to invoke the Edit Table dialog
box, where you can make more detailed modifications to columns and other table
information. Again, dont modify any columns for this practice.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 314

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

Oracle University and Egabi Solutions use only

Practice A-1: Creating a Database Diagram with Existing Schema


Objects (continued)

Practice A-2: Adding New Schema Objects


In this practice, you add a new table to the diagram. After adding new objects to the
diagram, you can synchronize the diagram with the database by generating directly to the
database, or you can first create a SQL script and then run that against the database. In
this practice, you create a SQL script.
1) Add a new table to the diagram named Shippers, with a primary key named
Shipper_Id and a varchar2 column named Shipper_Name.

b) In the Component Palette, ensure that Database is selected from the drop-down
list at the top. The list below it now displays components suitable for adding to a
schema diagram.

c) In the Component Palette, select Table and drag it onto the schema diagram.
d) In the Specify Location dialog box, accept the default location of the FodDB
offline database and click OK.
e) In the name area at the top of the table icon, type Shippers.

f) Select the table and resize it to make it easier to add columns.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 315

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

Oracle University and Egabi Solutions use only

a) Ensure that the Component Palette is visible to the right of the diagram. If it is
not, select View > Component Palette.

Practice A-2: Adding New Schema Objects (continued)


g) Double-click the white space of the table diagram to invoke the Edit Table dialog
box.
h) With the Columns node selected in the tree at the left of the Edit Table dialog
box:
i) Click Add (plus icon) to add a new column, Shipper_Id:
(1) Set the data type to Number.
(2) Set the Precision to 10.

ii) In a similar fashion, add a Shipper_Name column, with the default values
for data type and size. This is not a mandatory column.
iii) In the list at the left of the Edit Table dialog box, select Primary Key and set
the primary key as follows:
(1) Select SHIPPER_ID in the Available Columns list.
(2) Click Add

to shuttle SHIPPER_ID to the Selected Columns list.

iv) Click OK. The diagram should look similar to this:

2) Generate the DDL for adding the new table to the database, but do not actually add
the table.
a) Right-click the SHIPPERS table in the diagram, and from the context menu
select Synchronize with Database > Generate To > SQL Script (you can also
choose to generate to FOD, which brings up the same dialog box with different
default options that you can change.)
Oracle Fusion Middleware 11g: Build Applications with ADF I C - 316

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

Oracle University and Egabi Solutions use only

(3) Make sure that Shipper_Id is a mandatory column by selecting the


Cannot be NULL check box.

Practice A-2: Adding New Schema Objects (continued)


b) In the Generate SQL from Database Objects Wizard:
i) Click Back until you are on the Specify Source page.

iii) Choose the SQLScript option in the Specify Target page, and click Next.
iv) The Object Picker page should show SHIPPERS in the Selected list. Click
Next.
v) In the Choose Operation page, select the Create option and click Next.
vi) In the SQL Script Options page, change the name of the SQL file to
CreateShippersTable.sql and click Next.
vii) Click Finish to generate the script.
c) When the wizard is complete, the script file opens in a SQL worksheet. Examine
the file contents.
d) Do not run the script, but note that to run the script you can right-click the script
and choose Run Script from the context menu, or click Run Script .
e) Save your work.
f) When you have finished, close the script file and the database diagram. To close
all the open windows at once, right-click one of the tabs and select Close All.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 317

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

Oracle University and Egabi Solutions use only

ii) On Specify Source page, check the location of the objects to be generated in
the Specify Source page, and then click Next.

Practices for Appendix B


In this practice, you create a deployment profile and configure deployment options for the
Storefront application that you have developed. You then configure a data source in the
stand-alone Oracle WebLogic Server, and you configure the application to use a data
source. Finally, you deploy the application to the stand-alone Oracle WebLogic Server,
and you test the deployment.

If you choose to work on this practice, start with the completed application by opening
Storefront-B.jws and editing the database information as described in step 4 of
Practice 2-4.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 318

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

Oracle University and Egabi Solutions use only

This practice is optional and does not affect any of the other practices. You should
work on it only if you have extra time.

Practice B-1: Creating Deployment Profiles


In this practice, you create a new deployment profile for the application. It should specify
a Java EE Web Context Root of Storefront, and should specify the myWLS connection.
1) The default context root for the application is Storefront2-StorefrontUIcontext-root; because this context root becomes part of the URL to access the
application, it is better to use a shorter one. To set a new context root, you must create
or edit a deployment profile for the StorefrontUI project. Create a new deployment
profile called myStorefrontUI that specifies a context root of Storefront.

b) In the New Gallery, select General > Deployment Profiles > WAR File.
c) In the Create Deployment Profile dialog box, enter a Deployment Profile Name of
myStorefrontUI and click OK.
d) In the Edit WAR Deployment Profile Properties dialog box, select the Specify
Java EE Web Context Root option and enter a context root of Storefront.

e) Click OK twice.
2) Create a deployment profile named myStorefront for the application, specifying
that it should contain the myStorefrontUI WAR file and the JAR file for the
StorefrontModel project.
a) Invoke the Application menu and select Application Properties.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 319

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

Oracle University and Egabi Solutions use only

a) In the Application Navigator, select the StorefrontUI project, and then select File
> New.

b) In the Application Properties dialog box:


i) Select Deployment in the tree at the left.
ii) In the Deployment panel, click New.
c) In the Create Deployment Profile dialog box, set the Archive Type to EAR File
and the name to myStorefront, and then click OK.
d) In the Edit EAR Deployment Profile Properties dialog box:
i) Select Application Assembly in the tree at the left.
ii) In the Application Assembly panel, select the myStorefrontUI and
StorefrontModelArchive check boxes, and then click OK twice

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 320

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

Oracle University and Egabi Solutions use only

Practice B-1: Creating Deployment Profiles (continued)

Practice B-2: Using a WebLogic Server Data Source


A stand-alone Oracle WebLogic Server has already been created for you and configured
to run ADF applications. In this practice, you use the Oracle WebLogic Server
Administration Console to create a data source that the deployed application can use. You
then configure the application to use a JDBC DataSource connection type rather than the
JDBC URL connection type that it has been using by default.

a) From the Windows Start menu, select Programs > Oracle Fusion Middleware >
User Projects > MyWLS_domain > Admin Server Console. The console
application deploys and then runs.
Note: If the Administration Server Console does not run, then make sure that the
WebLogic Server is running. If it is not running, invoke the same menu except
select as the final item Start Admin Server for WebLogic Server Domain.
After the server has started, you can minimize the startWebLogic command
window.
b) Log in to the Administration Server Console with the user name of weblogic
and the password of weblogic.
c) In the Domain Structure menu at the left of the window, expand the Services and
JDBC nodes, and then select the Data Sources node.

d) On the Summary of JDBC Data Sources page, click New.


e) In the Create a New JDBC Data Source Wizard, set the following properties:
Property

Value

Name

FODLocal

JNDI Name

jdbc/FODDS

Database Type

Oracle

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 321

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

Oracle University and Egabi Solutions use only

1) Set up a data source named FODLocal in the basic_domain domain of the standalone Oracle WebLogic Server, setting the JNDI name to jdbc/FODDS. Set other
properties so that it connects to the same schema that you have been using.

Database Driver

Oracle's Driver (Thin)


Versions:9.0.1,9.2.0,10,11

Database Name

XE

Host Name

localhost

Port

1521

Database User Name

<your schema>, such as fod01

Password

fusion

f) On the next page of the wizard, click Test Configuration. If the test is successful,
click Next (do not click Finish).
g) On the next page of the wizard, select the AdminServer check box as a target to
deploy the data source, and then click Finish. You should receive a message that
the changes are activated, and your new data source should be listed.
2) Configure the application modules to use the data source, rather than the JDBC URL
connection that you have been using.
a) In the JDeveloper Application Navigator, right-click the FODCategoryAM
application module and select Configurations.

b) In the Manage Configurations dialog box:


i) Select FODCategoryAMLocal and click Copy.
ii) Select the new FODCategoryAMLocal1 configuration and click Edit.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 322

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

Oracle University and Egabi Solutions use only

Practice B-2: Using a WebLogic Server Data Source (continued)

Practice B-2: Using a WebLogic Server Data Source (continued)


c) In the Edit Business Components Configuration dialog box, set the following
properties:
Property

Value

Configuration Name

FODCategoryAMWeb (change Local1 in the name to


Web)

Connection Type

JDBC DataSource

Datasource Name

Java:comp/env/jdbc/FODDS

e) Perform steps a) through d) for all of the application modules.


3) Configure the data bindings to use the data source.
a) In the Application Navigator, select DataBindings.cpx in the StorefrontUI
project.

b) In the Structure window:


i) Expand DataBindings > dataControlUsages.
ii) Select each application module data control usage, and in the Property
Inspector set its Configuration to be the Web configuration that you just
defined, such as FODProductAMWeb.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 323

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

Oracle University and Egabi Solutions use only

d) Click OK twice.

iii) Repeat steps i) and ii) for all five application server data control usages.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 324

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

Oracle University and Egabi Solutions use only

Practice B-2: Using a WebLogic Server Data Source (continued)

Practice B-3: Creating an Application Server Connection


To deploy to an application server from within JDeveloper, you must first create a
connection to it.
1) Create an application server connection to the stand-alone WebLogic Server. Name
the connection myWLS, with a user name of weblogic and a password of weblogic.
Use a Port of 7001 and a WLS Domain named base_domain.
a) From the JDeveloper menu, select View > Application Server Navigator.
c) In the Create Application Server Connection Wizard, enter the following settings,
leaving others at their default values:
Property

Value

Connection Name

myWLS

Password

weblogic

Deploy Password

Checkbox selected

Port

7001

WLS Domain

myWLS_domain

d) On the last page of the wizard, click Test, and then click Finish if the connection
is successful.

e) The connection appears in the Application Server Navigator. Expand the myWLS
and deployments nodes so that you can see what is already deployed.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 325

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

Oracle University and Egabi Solutions use only

b) Right-click the Application Servers node and select New Application Server.

Practice B-4: Deploying the Application from JDeveloper


You have prepared the application and the OracleWebLogic Server for deployment. In
this practice, you use JDeveloper to deploy the application to the application sever.
1) Using the deployment profile that you defined in this set of practices, deploy the
Storefront application to the stand-alone WebLogic Server.

The log window displays deployment messages. It may take a few minutes to
finish the deployment; wait until the window displays the message that the
deployment is finished.

b) In the Application Server Navigator, click Refresh to see the myStorefront


deployment.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 326

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

Oracle University and Egabi Solutions use only

a) Invoke the Application menu and select Deploy > myStorefront > to > myWLS.

Practice B-4: Deploying the Application from JDeveloper


(continued)
2) Test the deployment.
a) In a browser, enter the URL
http://127.0.0.1:7001/Storefront/faces/FODShoppingDashboard.
b) Ensure that data appears properly, that the New Supplier button is shown on the
BrowseSuppliers page, and that there are items in the shopping cart.
c) When you have finished, close the browser and undeploy the application as
follows:
.

ii) Right-click the myStorefront deployment and select Undeploy.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 327

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

Oracle University and Egabi Solutions use only

i) On the Application Server Navigator, click Refresh

Practice B-5: Deploying the Application from the WebLogic


Server Administration Console
In this practice, you use the WebLogic Server Administration Console to deploy the
application.
1) Use JDeveloper to create a deployable EAR file, making note of the directory where
the EAR file is created.
a) From the Application Navigator, invoke the Application menu.
b) Select Deploy > myStorefront > to EAR file.
2) Use the Oracle WebLogic Server Administration Console to deploy the application.
a) Invoke the Administration Console, or switch to it if it is already open.
b) From the Domain Structure menu at the left, select Deployments.
c) In the Deployments panel, click Install.
d) By clicking through the displayed directories, locate the myStorefront.ear file in
the directory where it was created and select it, and then click Next.

e) Select the Install this deployment as an application option and click Next.
f) Select the Copy this application onto every target for me option and click
Next.
g) Select the option Yes, take me to the deployment's configuration screen and
click Finish.
h) Review the configuration options, but do not change them. Click Save.
i) Click back to Deployments on the menu. You should see that the application is
deployed.
3) Test the deployment as you did above.

Oracle Fusion Middleware 11g: Build Applications with ADF I C - 328

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

Oracle University and Egabi Solutions use only

c) In the log file, make note of the location of the EAR file.

Вам также может понравиться