Oracle Fusion Middleware 11g: Build Applications With ADF I
Oracle Fusion Middleware 11g: Build Applications With ADF I
Oracle Fusion Middleware 11g: Build Applications With ADF I
D53979GC10
Edition 1.0
December 2008
Authors
Disclaimer
Pam Gamer
Gary Williams
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.
Technical Contributors
and Reviewers
Glenn Maslen
Ken Cooper
Joe Huang
Taj-ul Islam
Duncan Mills
Kenichi Mizuta
Frank Nimphius
Dan Pillay
Blaise Ribet
Oliver Steinmeier
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
Editors
Steve Elwood
Raj Kumar
Aju Kumar
Publishers
Veena Narasimhan
Jothi Lakshmi
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be
trademarks of their respective owners.
Course Introduction:
Oracle Fusion Middleware 11g:
Build Applications with ADF I
Course Objectives
I-2
I-3
I-4
Basic UI Concepts:
Lesson 11: Understanding UI Technologies
Lesson 12: Binding UI Components to Data
Lesson 13: Planning the User Interface
Lesson 14: Adding Functionality to Pages
Lesson 15: Implementing Navigation on Pages
I-5
I-6
I-7
Introduction
to
Oracle Fusion and Oracle ADF
Objectives
1-2
1-3
1-4
Rich Clients
Controller
1-5
View
Controller
Model
Model
(JSR-227)
Business Services
Business
Services
Rich Clients
View
Controller
Controller
Model
(JSR-227)
Model
Java
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
BI
Essbase
Portlets
Business
Services
Data
Services
Relational Data
1-6
XML Data
Legacy Data
Packaged Apps
Rich Clients
View
Controller
Controller
Model
(JSR-227)
Java
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
BI
Essbase
Portlets
Business
Services
Data
Services
Relational Data
1-7
XML Data
Legacy Data
Packaged Apps
Rich Clients
View
Controller
Struts
Java
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
BI
Essbase
Portlets
Business
Services
Data
Services
Relational Data
1-8
XML Data
Legacy Data
Packaged Apps
Browser-based
JSP
Office
JSF
Struts
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
BI
Controller
Model
Java
View
Essbase
Portlets
Business
Services
Data
Services
Relational Data
1-9
XML Data
Legacy Data
Packaged Apps
Browser-based
JSP
Office
JSF
Struts
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
BI
Controller
Model
Java
View
Essbase
Portlets
Business
Services
Data
Services
Relational Data
1 - 10
XML Data
Legacy Data
Packaged Apps
1 - 11
1 - 12
Summary
1 - 13
Objectives
2-2
2-3
Technology stacks
Development approaches
Development platform
Data sources
Application servers
Copyright 2008, Oracle. All rights reserved.
Launching JDeveloper
2-5
2-6
A developer role
Expandable Panels
Minimizing a Panel
Restoring a Panel
2-8
2 - 10
Apply
filter
Edit
properties:
2 - 11
2 - 13
2 - 14
2 - 15
with
Editor
3
6
2 - 16
2 - 17
2 - 18
2 - 19
2 - 20
2 - 21
2 - 23
Cue cards
Tutorials
Samples
Guided steps
Detailed help
2 - 24
Two types:
IDE:
Available to be added to any application
Create in Database Navigator or Resource Palette
To add to an application, drag to Application Resources or to
an application in Database Navigator
Application:
Owned by a specific application
Create in Database Navigator or Application Resources
2 - 26
2 - 27
2 - 29
2 - 30
Summary
2 - 31
Practice 2 Overview:
Using JDeveloper
This practice covers the following topics:
Setting preferences for the IDE
Creating a JDeveloper application, project, and database
connection
Viewing the course application in a browser and identifying
functionality
2 - 32
Objectives
3-2
3-3
3-4
3-5
Diagrammer:
Create and modify objects by dragging from Component
Palette and Database Navigator.
Import objects from offline database model.
Generate changes to online schemas.
3-6
3-7
3-8
3 - 10
3 - 11
3 - 12
Invoke wizard.
In the wizard:
3 - 13
Select objects.
Specify operation.
Set database options.
Set SQL script options.
3 - 14
3 - 15
3 - 16
3 - 17
Summary
3 - 18
Practice 3 Overview:
Modeling the Schema for the Course Application
(optional)
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
3 - 19
Objectives
4-2
4-3
4-4
StorefrontAM
Customer
CustVO
CustomerOrder
4-5
CustomerEO
OrderEO
AllOrders
OrdVO
Application Module
with View
Object Instances
View
Objects
and
View
Link
LineItemEO
Entity Objects
and
Associations
4-6
Specify
Package.
Restrict
query.
Rename
entity.
4-7
Specify
Package.
Rename
view object.
4-8
Specify
Package.
Rename
view object.
4-9
Create an
application
module?
Name
application
module.
4 - 10
Create?
Name
diagram
Choose
objects
4 - 11
4 - 12
4 - 13
4 - 14
Summary
4 - 15
Practice 4 Overview:
Building a Business Model
This practice covers the following topics:
Using the Business Components from Tables Wizard to
quickly build part of the data model
Testing the model with the Business Components Browser
4 - 16
Objectives
After completing this lesson, you should be able to do the
following:
Describe the characteristics of an ADF BC view object
Create ADF BC view objects that can be used for data
queries in a Web application
Modify SQL statements in view objects
Explain how entity objects relate to database tables
Describe the persistence mechanism of entity objects
Create entity objects from database tables
Create associations between entity objects
Create updatable view objects based on entity objects
Link view objects to one another
Refactor business components
5-2
CustomerStatusRO
5-3
Reusable
Query Components
PriorityOrderVO
5-4
ItemListVO
5-5
5-7
5-8
5-9
5 - 10
Provide
connection
details.
Double-click the
view object
instance.
Entity objects:
Represent a row in a database table or other data source
Handle database caching
Contain attributes representing the database columns
Encapsulate attribute-level and entity-level validation logic
Can contain custom business methods
CustomerEO
5 - 11
OrderEO
CustomerEO
Id
Name
Status
Email
Attributes
Status List
(Gold Silver Platinum)
Validation
rule
CUSTOMERS
Database
table
5 - 12
ID
NAME
STATUS
201
202
Steve
Mike
Gold
Silver
Email
msmith@company.com
dgonzales@company.com
5 - 13
5 - 15
ALTER
ALTER TABLE
TABLE USERS
USERS
ADD
(security_question
ADD (security_question VARCHAR2(60));
VARCHAR2(60));
5 - 16
5 - 17
Characteristics of Associations
5 - 18
OrdersPersonsFkAS
OrderEO
Source
Association
Destination
Creating Associations
Use the Create Association Wizard:
Name page
5 - 19
Association Types
Association
Entities are related but not
completely dependent.
Either end of the association can
exist without the other.
Customer
Either can be deleted without
deleting the other.
Composition
Destination entity is completely
dependent on source entity.
Source entity owns destination
entity.
No destination entity can be
created without the owning entity
existing first.
Source entity cannot be deleted
without deleting all its associated
destination entities.
5 - 20
Order
Order
Order Item
Characteristics of
Updatable View Objects
Entity Object
View Object
CustomerEO
CustomerStatusVO
select name, status
from customers
order by name
Name
ID
Name
Status
Email
5 - 21
Mike
Steve
ID
NAME
STATUS
201
202
Steve
Mike
Gold
Silver
Steve@abc.com
Mike@abc.com
Status
Silver
Gold
Database
Table
Name page
Entity Objects page
5 - 22
Attributes page
5 - 23
5 - 25
5 - 27
Select
5 - 28
Commit
5 - 29
EO
Update
VO
Join is based on
association
between
entities.
5 - 30
5 - 31
Master to Single
Detail
5 - 32
Master to Multiple
Details
Cascading Master
Detail to Any Depth
5 - 33
5 - 34
Refactoring Objects
5 - 35
Summary
In this lesson, you should have learned how to:
Describe the characteristics of an ADF BC view object
Create ADF BC view objects that can be used for data
queries in a Web application
Modify SQL statements in view objects
Explain how entity objects relate to database tables
Describe the persistence mechanism of entity objects
Create entity objects from database tables
Create associations between entity objects
Create updatable view objects based on entity objects
Link view objects to one another
Refactor to move and rename associations and links
5 - 36
Practice 5 Overview:
Creating Entity Objects and View Objects
This practice covers the following topics:
Creating read-only view objects to support LOVs
Creating entity objects for tables that need to be updated
in the application
Creating associations
Creating updatable view objects
Creating view links
Refactoring associations and links
5 - 37
Exposing Data
Objectives
6-2
6-3
6-4
Represents the data model that the client uses and has
one connection to the database
Provides transactional context for the application
Enables you to gather data customized to a client interface
so that data can be retrieved in one network round-trip
Can contain other application modules, called nested
application modules
Keeps track of all changes that affect data in the database
Provides remotely accessible methods to implement
application module behavior
Is deployable in multiple configurations
Can be easily reused in business logic tiers of other
applications
Copyright 2008, Oracle. All rights reserved.
6-5
6-6
6-7
6-8
Application modules:
Handle transaction and concurrency support
Use a single database connection
Provide transaction context for updates, deletes, and inserts
for all view objects in the application module, so all are
committed or rolled back at once
6-9
6 - 12
Available
M
rA
e
d
r
Referenced: Id like to be
used by User2
M
rA
e
d
r
Unavailable: Im busy
right now!
Saved
state
10
51
Passivation
6 - 13
Activation
10
51
Browser-based
JSP
Office
JSF
Struts
ADF Bindings
Java
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
View
Controller
Model
BI
Essbase
Portlets
Business
Services
Data
Services
Relational Data
6 - 14
XML Data
Legacy Data
Packaged Apps
6 - 15
6 - 16
4
2
6
6 - 18
Summary
6 - 19
Practice 6 Overview:
Defining Application Modules
This practice covers the following topics:
Packaging view objects in application modules to provide
the data needs of the application
Testing the business components
6 - 20
Objectives
7-2
Using Groovy
Groovy
Is a Java-like scripting language that is dynamically
compiled and evaluated at run time
Enables you to use declarative expressions, instead of
writing Java code, for the following types of values in the
ADF BC data model:
7-3
Bind variables
Calculated attributes
Attribute default values
View criteria
View accessor bind variables
Validation
Validation message token binding
Copyright 2008, Oracle. All rights reserved.
Java Code
Equivalent
Groovy script
((Number)getAttribute("Sal").multiply(new
Number(0.10))
Sal * 0.10
((Date)getAttribute("PromotionDate")).compareTo PromotionDate
((Date)getAttribute("HireDate")) > 0
> HireDate
7-6
Property Inspector
Entity Object Editor
7-7
7-8
7-9
7 - 10
7 - 12
7 - 13
7 - 15
7 - 16
7 - 17
7 - 18
7 - 19
7 - 20
7 - 21
7 - 22
7 - 24
Performing Calculations
Setting recalculation
dependencies
7 - 25
7 - 26
Original query
Deleting attributes
Modified
query
Reordering attributes
7 - 27
7 - 28
7 - 29
7 - 30
Add a WHERE
clause:
7 - 31
7 - 32
Edit the
view object.
7 - 34
Add a
parameterized
WHERE clause.
7 - 35
7 - 36
7 - 37
7 - 38
7 - 39
LOVs:
Are defined on view object attributes
Use view accessors as a data source:
For attributes mapped to an entity object attribute:
7 - 40
7 - 41
7 - 42
7 - 43
7 - 44
Summary
7 - 45
Practice 7 Overview:
Declaratively Modifying Business Components
This practice covers the following topics:
Changing data labels and formats
Specifying that an entity object should use a database
sequence to generate the primary key
Designating history columns
Creating bind variables and view criteria
Creating join view objects
Defining an LOV
7 - 46
Objectives
8-2
8-3
8-4
EntityImpl
The entity class
Represents a row
Provides getter and
setter methods
EntityDefImpl
The entity definition class
Represents the whole entity
Can be used to modify the entity definition
EntityCollImpl
Represents the cached set of rows from the entity
Not usually necessary to modify or override methods in this
class
8-5
Traversing Associations
OrderEO
PersonEOToOrderEO
PersonEO
getPersonEO()
setPersonEO()
getPersonEmail()
getOrderEO()
getEmail()
Accessor in source
to get destination
Accessors in destination
to get and set source
8-7
8-9
1
2
3
4
5
// In ProductEOImpl.java
import oracle.jbo.server.SequenceImpl;
// Default ProdId value from PRODUCTS_SEQ sequence at
protected void initDefaults() {
super.initDefaults();
SequenceImpl sequence = new
SequenceImpl("PRODUCTS_SEQ",getDBTransaction());
DBSequence dbseq = new
DBSequence(seq.getSequenceNumber());
populateAttributeAsChanged(ProdId, dbseq);
}
8 - 10
8 - 11
ViewObjectImpl
The view class
Provides methods
to manage the row
set
ViewDefImpl
The view definition class
Represents the whole view
Can be used to modify the view definition
ViewRowImpl
The view object row class
Instantiated for each record returned by the query
Provides attribute accessors
8 - 12
8 - 13
NAME
STATUS
201
202
201
Susan
Mike
Steve
Platinum
Silver
Gold
select name,
status
from customers
order by name
ViewObject vo = am.findViewObject
("CustomerStatusRO");
String whereClause = "NAME < 'Su'";
String orderByClause = "STATUS";
vo.setWhereClause(whereClause);
vo.setOrderBy(orderByClause);
8 - 16
Name
Status
Mike
Steve
Susan
Silver
Gold
Platinum
Name
Status
Steve
Mike
Gold
Silver
8 - 18
Programmatically Retaining
and Reusing a View Link Accessor Row Set
To retain and reuse a view link accessor row set
programmatically:
1. Generate a Java class for the source view object.
2. Override the create() method.
3. Add setViewLinkAccessorRetained(true).
public
public class
class OrderVOImpl
OrderVOImpl extends
extends ViewObjectImpl
ViewObjectImpl {{
public
public OrdersViewImpl()
OrdersViewImpl() {{
}}
@Override
@Override
protected
protected void
void create()
create() {{
super.create();
super.create();
setViewLinkAccessorRetained(true);
setViewLinkAccessorRetained(true);
}}
}}
Traversing Links
8 - 20
Created by default:
8 - 22
Code to
manipulate
view objects
Client
8 - 23
Application Module
Copyright 2008, Oracle. All rights reserved.
8 - 25
8 - 27
8 - 28
Click Execute.
Observe results.
8 - 30
Accessing a Transaction
8 - 31
Committing Transactions
Post phase
1. Validate pending changes.
2. Post updates to the database.
Commit phase
Commit the transaction.
8 - 33
8 - 34
Implement a TransactionListener.
Implement beforeCommit() and afterCommit().
8 - 36
public
public String
String findOrderID(long
findOrderID(long orderId)
orderId) {{
String
String entityName
entityName == "oracle.fod.storefront.model.entity.OrderEO";
"oracle.fod.storefront.model.entity.OrderEO";
EntityDefImpl
1
EntityDefImpl orderDef
orderDef == EntityDefImpl.findDefObject(entityName);
EntityDefImpl.findDefObject(entityName);
Key
Key orderKey
orderKey == new
new Key(new
Key(new Object[]{orderId});
Object[]{orderId});
EntityImpl
EntityImpl order
order == orderDef.findByPrimaryKey(getDBTransaction(),
orderDef.findByPrimaryKey(getDBTransaction(),
orderKey);
orderKey);
if
if (order
(order !=
!= null)
null) {{
return
}}
return (String)order.getAttribute(ShipToName");
(String)order.getAttribute(ShipToName");
else
return
}} }}
else {{
return null;
null;
8 - 37
Updating or Removing
an Existing Entity Row
public
public void
void updateEmpEmail(long
updateEmpEmail(long empId,
empId, String
String newEmail)
newEmail) {{
EntityImpl
1
EntityImpl emp
emp == retrieveEmployeeById(empId);
retrieveEmployeeById(empId);
if
if (emp
(emp !=
!= null)
null) {{
emp.setAttribute(Email",newEmail);
2
emp.setAttribute(Email",newEmail);
try
try {{
3
getDBTransaction().commit();
}}
getDBTransaction().commit();
catch
catch (JboException
(JboException ex)
ex) {{
getDBTransaction().rollback();
getDBTransaction().rollback();
throw
}}
}} }}
throw ex;
ex;
8 - 38
public
public long
long createProduct(String
createProduct(String name,
name, String
String description)
description) {{
String
String entityName
entityName == oracle.
oracle. fod.storefront.
fod.storefront. model.entity.ProductEO";
model.entity.ProductEO";
1 EntityDefImpl
EntityDefImpl productDef
productDef == EntityDefImpl.findDefObject(entityName);
EntityDefImpl.findDefObject(entityName);
2 EntityImpl
EntityImpl newProduct
newProduct ==
productDef.createInstance2(getDBTransaction(),null);
productDef.createInstance2(getDBTransaction(),null);
newProduct.setAttribute("Name",name);
newProduct.setAttribute("Name",name);
3 newProduct.setAttribute("Description",description);
newProduct.setAttribute("Description",description);
try
try {{
getDBTransaction().commit();
}}
4
getDBTransaction().commit();
catch
catch (JboException
(JboException ex)
ex) {{
throw
}}
throw ex;
ex;
5 DBSequence
DBSequence newIdAssigned
newIdAssigned ==
(DBSequence)newProduct.getAttribute("ProdId");
(DBSequence)newProduct.getAttribute("ProdId");
return
return newIdAssigned.getSequenceNumber().longValue();
newIdAssigned.getSequenceNumber().longValue();
8 - 39
8 - 41
[Ctrl]+[Enter]
8 - 42
8 - 43
ViewObject
Row
Row
Row
RowSetIterator
8 - 44
RowSet
hasNext
next
setNamedWhereClauseParam
executeQuery
setWhereClause
setNamedWhereClauseParam
executeQuery
hasNext
next
hasNext
next
ViewCriteria
ViewCriteria vc
vc == custOrdVO.createViewCriteria();
custOrdVO.createViewCriteria();
ViewCriteriaRow
ViewCriteriaRow promotionRow
promotionRow == vc.createViewCriteriaRow();
vc.createViewCriteriaRow(); 2
ViewCriteriaRow
ViewCriteriaRow noPromRow
noPromRow == vc.createViewCriteriaRow();
vc.createViewCriteriaRow();
promotionRow.setAttribute("OrderTotal",
promotionRow.setAttribute("OrderTotal", ">
"> 500");
500");
promotionRow.setAttribute("CreditLimit",
">
promotionRow.setAttribute("CreditLimit", "> 2500");
2500");
3
promotionRow.setAttribute(DiscountId",
<>
NULL");
promotionRow.setAttribute(DiscountId", <> NULL");
noPromRow.setAttribute("OrderTotal",
noPromRow.setAttribute("OrderTotal", ">
"> 1000");
1000");
noPromRow.setAttribute(CreditLimit",
noPromRow.setAttribute(CreditLimit", ">
"> 5000");
5000");
vc.addElement(promotionRow);
vc.addElement(promotionRow);
vc.addElement(noPromRow);
vc.addElement(noPromRow);
custOrdVO.applyViewCriteria(vc);
custOrdVO.applyViewCriteria(vc);
custOrdVO.executeQuery();
custOrdVO.executeQuery();
8 - 45
4
5
6
1
3
4
5
6
7
8
8 - 48
public
public class
class TestClient
TestClient {{
public
public static
static void
void main(String[]
main(String[] args)
args) {{
TestClient
TestClient testClient
testClient == new
new TestClient();
TestClient();
String
amDef
String
amDef == "oracle.hr.test.TestAM";
"oracle.hr.test.TestAM";
String
config
=
String
config = "TestAMLocal";
"TestAMLocal";
ApplicationModule
am
=
ApplicationModule am =
Configuration.createRootApplicationModule(amDef,config);
Configuration.createRootApplicationModule(amDef,config);
ViewObject
ViewObject vo
vo == am.findViewObject("EmployeesView1");
am.findViewObject("EmployeesView1");
Key
empKey
=
new
2 Key empKey = new Key(new
Key(new Object[]{101});
Object[]{101});
Row[]
Row[] empsFound
empsFound == vo.findByKey(empKey,1);
vo.findByKey(empKey,1);
if
(empsFound
!=
null
if (empsFound != null &&
&& empsFound.length
empsFound.length >> 0)
0) {{
Row
Row emp
emp == empsFound[0];
empsFound[0];
System.out.println("Employee
System.out.println("Employee Name:
Name: "" ++ emp.getAttribute("LastName"));
emp.getAttribute("LastName"));
System.out.println("Employee
System.out.println("Employee is
is in
in department
department ++
emp.getAttribute("DepartmentId"));
emp.getAttribute("DepartmentId"));
emp.setAttribute("DepartmentId",60);
emp.setAttribute("DepartmentId",60);
System.out.println("Employee
System.out.println("Employee reassigned
reassigned to
to department
department "" ++
emp.getAttribute("DepartmentId"));
emp.getAttribute("DepartmentId"));
am.getTransaction().rollback();
am.getTransaction().rollback();
System.out.println("Transaction
System.out.println("Transaction cancelled");}
cancelled");}
Configuration.releaseRootApplicationModule(am,true);
Configuration.releaseRootApplicationModule(am,true); }}
}}
1
2
3
4
5
public
public class
class TestClient
TestClient {{
public
static
public static void
void main(String[]
main(String[] args)
args) {{
TestClient
TestClient testClient
testClient == new
new TestClient();
TestClient();
String
amDef
=
"oracle.hr.test.TestAM";
String
amDef = "oracle.hr.test.TestAM";
String
config
String
config == "TestAMLocal";
"TestAMLocal";
ApplicationModule
am
=
ApplicationModule am =
Configuration.createRootApplicationModule(amDef,config);
Configuration.createRootApplicationModule(amDef,config);
ViewObject
ViewObject vo
vo == am.findViewObject("EmployeesView1");
am.findViewObject("EmployeesView1");
Row
newEmp
=
Row newEmp = vo.createRow();
vo.createRow();
vo.insertRow(newEmp);
vo.insertRow(newEmp);
newEmp.setAttribute("EmployeeId",999);
newEmp.setAttribute("EmployeeId",999);
newEmp.setAttribute("FirstName","Pam");
newEmp.setAttribute("FirstName","Pam");
newEmp.setAttribute("LastName","Gamer");
newEmp.setAttribute("LastName","Gamer");
Date
Date now
now == new
new Date();
Date();
newEmp.setAttribute("HireDate",now);
newEmp.setAttribute("HireDate",now);
newEmp.setAttribute("JobId","IT_PROG");
newEmp.setAttribute("JobId","IT_PROG");
newEmp.setAttribute("Email","pgamer@mymail.com");
newEmp.setAttribute("Email","pgamer@mymail.com");
newEmp.setAttribute("DepartmentId",60);
newEmp.setAttribute("DepartmentId",60);
newEmp.setAttribute("ManagerId",103);
newEmp.setAttribute("ManagerId",103);
am.getTransaction().commit();
am.getTransaction().commit();
System.out.println("Added
System.out.println("Added employee
employee "" ++
newEmp.getAttribute("EmployeeId")
newEmp.getAttribute("EmployeeId") ++ "" to
to Department
Department "" ++
newEmp.getAttribute("DepartmentId"));
newEmp.getAttribute("DepartmentId"));
Configuration.releaseRootApplicationModule(am,true);
Configuration.releaseRootApplicationModule(am,true); }}
}}
8 - 49
Summary
8 - 50
Practice 8 Overview:
Programmatically Modifying
Business Components
This practice covers the following topics:
Generating Java classes
Overriding base class methods
Using a test client to enable testing code that uses some of
the view object APIs
Extending the application module base class
Adding service methods to an application module
8 - 51
Objectives
9-2
Validation options:
Business services:
ADF BC
Database (PL/SQL)
9-3
User interface
9-4
Entity
validation rule
9-5
9-6
In error messages:
You indicate a variable
by surrounding a name
with braces {}
9-7
9-8
9-9
Collection validator
Unique key validator
Compare validator
Key exists validator
Length validator
List validator
Range validator
Regular expression validator
9 - 10
Method validator
Script Expression validator
Copyright 2008, Oracle. All rights reserved.
9 - 11
Collection validator
Unique key validator
Compare validator
Key exists validator
Length validator
List validator
Range validator
Regular expression validator
9 - 12
Method validator
Script Expression validator
Copyright 2008, Oracle. All rights reserved.
9 - 13
Operation
Accessor
Attribute
Operator
Compare with
Compare with value
9 - 14
Collection validator
Unique key validator
Compare validator
Key exists validator
Length validator
List validator
Range validator
Regular expression validator
9 - 15
Method validator
Script Expression validator
Copyright 2008, Oracle. All rights reserved.
Attribute-level
Compare validator
1. Attribute (if
entity level)
2. Operator
Entity-level
Compare validator
3. Value to
compare
with
9 - 16
Operator:
9 - 18
Comparison Type:
Value(s):
9 - 19
9 - 20
9 - 21
Operator:
Regular Expression:
Qualifier(s):
Predefined Expressions:
Collection validator
Unique key validator
Compare validator
Key exists validator
Length validator
List validator
Range validator
Regular expression validator
9 - 22
9 - 23
9 - 26
9 - 28
4
2
9 - 29
Select the
global rule
from
the Rule
Type list.
Create a new validator for an
attribute or for the entity.
Provide
values for
any
properties.
9 - 31
9 - 33
9 - 34
JDeveloper Debugger is
useful for pinpointing
problems in your custom
validation code.
Set source breakpoints to
pinpoint problems.
Set exception breakpoints
to stop when a particular exception
is thrown.
At breakpoints you can execute code one line at a time
and view variable values.
To run a file in debug mode, right-click and select Debug.
Copyright 2008, Oracle. All rights reserved.
Domains are Java classes that extend the basic data types
(String, Number, Date , and so on).
9 - 35
URLDomain
appears in the
list of types.
9 - 36
9 - 37
Summary
9 - 39
Practice 9 Overview:
Implementing Validation
This practice covers the following topics:
Using declarative validation
Using programmatic validation
Creating and using a domain
Testing the validation
9 - 40
Objectives
10 - 2
10 - 3
Troubleshooting the UI
10 - 4
10 - 5
10 - 6
Java Logging
10 - 7
SEVERE
WARNING
INFO
CONFIG
FINE
FINER
FINEST
ALL
NONE
Edit <Java_Home>/jre/lib/logging.properties:
Set
java.util.logging.ConsoleHandler.level=FINE
Add the line: com.sun.faces.level=FINE
10 - 9
10 - 10
Logging level
Module filter
10 - 11
10 - 13
10 - 14
10 - 15
10 - 16
10 - 17
10 - 18
10 - 19
JUnit
JDeveloper Profiler
FileMon
Web service sample client
JDeveloper HTTP Analyzer
JDeveloper Debugger
10 - 20
10 - 21
10 - 22
10 - 23
10 - 24
10 - 25
greetingService_Service=new GreetingService_Service();
GreetingService greetingService =
greetingService_Service.getGreetingServiceSoapHttpPort();
// Add your code to call the desired methods.
System.out.println(greetingService.sayHelloTo("Pam"));
10 - 26
10 - 27
10 - 28
Type
Breaks when
Exception
Source
Method
Class
Watchpoint
10 - 29
Using Breakpoints
10 - 31
Declarative UI Debugging
The Declarative Debugger enables you to set breakpoints on:
Executables
Task flow activities
Bindings
Breakpoint reached:
10 - 32
An evaluated expression
10 - 33
During debugging:
ADF Structure Pane shows items in current viewport
ADF Data Window shows data within:
Item selected in ADF Structure Pane
ADF context
Scoped variables
10 - 34
Object Preferences
10 - 35
10 - 36
10 - 37
10 - 38
10 - 39
JboException
DMLException
uicli.binding.JUCtrlActionBinding.doIt()
server.ViewObjectImpl.
executeQueryForCollection()
server.ViewRowImpl.setAttributeInternal()
server.EntityImpl.setAttributeInternal()
10 - 40
10 - 41
10 - 42
10 - 45
10 - 47
10 - 48
10 - 49
Obtaining Help
10 - 50
Requesting Help
Summary
10 - 52
Practice 10 Overview:
Troubleshooting
This practice covers running the JDeveloper debugger to
diagnose a problem with the ADF BC model.
10 - 53
Understanding UI Technologies
Objectives
After completing this lesson, you should be able to do the following:
Describe the use of Web browsers and HTML
Explain how Java has come into widespread use as a language
for developing Web applications
Describe the function of Servlets and JSPs
Define JavaServer Faces
Explain the JSF component architecture
List some JSF component types included in the standard
implementation
Describe the purpose of backing beans
Explain the use of managed beans
Describe the JSF life cycle
Explain how ADF Faces augments the JSF life cycle
11 - 2
Browser client
HTML document
11 - 3
Web
server
HTML files
Java:
Is both a platform and an object-oriented language
Was originally designed by Sun Microsystems for
consumer electronics
Contains a class library
Uses a virtual machine for program execution
Provides the following benefits:
11 - 4
Object-oriented
Interpreted and platform independent
Dynamic and distributed
Multithreaded
Robust and secure
Copyright 2008, Oracle. All rights reserved.
Web server
Presentation
Application server
Business
logic
11 - 6
Data
Servlets:
Are written in Java
Extend the Web server
HTTP
request
Back-end functionality
User interface
HTTP
response
Browser client
HTML document
Web
server
HTML files
Request
type?
Other
Servlet
Web
container
11 - 8
JSP:
Combines HTML and JSP tags
Is saved as .jsp
11 - 9
JavaBeans:
Are Java classes that comply with
certain standards
Consist of properties, methods, and events
Can be used by builder tools such as JDeveloper
Can store state based on defined memory scope
Can be used in JSPs
11 - 10
Server-side UI technology
Standard Java EE Web UI framework with a huge base of
vendor support; contributors include Sun, Oracle, IBM
11 - 11
11 - 13
11 - 14
Traditional Navigation
Hard-coded
hyperlink
navigation
11 - 16
Hard-coded
button
navigation
<body>
<a href="http://myNewPage.html">
Go To My New Page
</a>
</body>
firstPage
Button
firstPage.jsp
myNewPage
success
myNewPage.jsp
firstPage
Button
firstPage.jsp
11 - 19
11 - 21
Restore View
Process
Validations
Validate immediate
Initial
request
Exception
Render
Response
11 - 22
Apply
Request
Values
Invoke
Application
Exception
Update
Model
11 - 24
11 - 25
11 - 26
Input validation
State management
Security
Declarative transaction control
ADF Phases
Events
Restore View
Init Context
before(Init Context)
after(Init Context)
Prepare Model
before, after
before, after
Process Validations
before, after
before, after
before, after
before, after
Metadata Commit
before, after
before, after
before, after
before, after
Prepare Render
before, after
Invoke Application
Render Response
11 - 27
Summary
Objectives
12 - 2
12 - 5
12 - 6
Context menu of
editor
12 - 7
12 - 8
Bindings
Bindings
Data Control
Business service
12 - 9
12 - 10
Accessor iterator
Variable iterator
12 - 12
12 - 13
Data Bindings:
Are created automatically when you drag them from the
Data Controls panel to a page or panel
Can also be created and edited in the editor, the Property
Palette, or the Structure window
Quantity:
Price:
12 - 15
7
$3.49
Rebinding: Example
In the visual editor or its Structure window, perform the
following steps:
1. Right-click the component.
2. Select Rebind to Another ADF Control.
3. Select a different control to bind to.
12 - 16
12 - 17
1
2
12 - 18
12 - 19
Database table
ADF BC
Entity Object
12 - 20
ADF BC
View Object
ADF BC
Application
Module
Binding Container
ADF Model
Data Control
12 - 21
Binding
container
12 - 23
Data Control
Binding
container
Data Control
Binding
container
Binding
Container
Data
Control
Structure
definition
file
*.xml
*PageDef.xml
Binding Context
Binding
context
definition file
DataBindings.cpx
12 - 26
Data
Controls
definition
file
DataControls.dcx
12 - 28
("MyAppModuleDataControl").getDataProvider();
//Now use myAM to call app module methods.
12 - 29
12 - 30
Summary
12 - 31
Practice 12 Overview:
Creating Databound Pages
This practice covers the following topics:
Creating simple JSF pages
Creating and editing data bindings
Examining metadata files
Changing the file name of a JSP
Editing metadata files to maintain data binding
12 - 32
Objectives
After completing this lesson, you should be able to do the
following:
Describe the Model-View-Controller design pattern
Explain the role of the ADF Controller
Differentiate between bounded and unbounded task flows
Create task flows
Define control flows
Define global navigation
Create routers for conditional navigation
Call methods and other task flows
Convert task flows
Use validation in the user interface
13 - 2
Rich Clients
Controller
13 - 3
View
Controller
Model
Model
Business Services
Business
Services
Browser-based
JSP
Office
JSF
View
Controller
Struts
ADF
ADFBindings
Bindings
Java
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
BI
Essbase
Portlets
Business
Services
Data
Services
Relational Data
13 - 4
XML Data
Legacy Data
Packaged Apps
Browser-based
JSP
Office
JSF
View
Controller
Struts
ADF Bindings
Java
EJB
TopLink
BAM
BPEL
ADFbc
Web
Services
BI
Essbase
Portlets
Business
Services
Data
Services
Relational Data
13 - 5
XML Data
Legacy Data
Packaged Apps
13 - 6
13 - 7
13 - 8
Diagram
Source
Overview
History
Are modular blocks of task flow functionality for reuse, with the following
characteristics:
Consist of:
Activities
13 - 9
View
Router
Comparing Unbounded
and Bounded Task Flows
Unbounded:
Bounded:
No well-defined boundary or single point of entry Single point of entry, with zero or more exit
points
Cannot be used as a region on a page
Declarative transaction
management, save for later
Cannot be called
Can be bookmarked
Not bookmarkable
13 - 11
13 - 12
13 - 13
13 - 14
13 - 15
Bounded to unbounded
13 - 16
13 - 17
13 - 20
browseOrders Page:
<af:commandButton
text= "Return to Orders"
action="showOrders"/>
orderDetail Page:
13 - 21
13 - 22
Use from-action
to define dynamic
control flow.
13 - 23
13 - 25
13 - 26
Router activities:
Use expressions
that evaluate to
true or false
Define
from-outcomes
based on the
value of the expression
13 - 28
2
3
13 - 29
Method call
13 - 30
When you return from a called task flow, the task flow return
activity specifies the outcome that is returned to the caller.
13 - 31
URL parameters
Method to invoke before view is rendered
Adding UI Code
Managed beans:
Configured in adfc-config.xml or other task flow .xml
file
Plain Old Java Objects (POJOs), Lists and Maps
Have no-argument constructor
Lazy initialization by JavaServer Faces framework as
needed
13 - 33
13 - 34
3
4
13 - 35
Summary
Practice 13 Overview:
Defining Task Flows
This practice covers the following topics:
Building an unbounded task flow
Creating a bounded task flow
Defining control flow rules
Adding routers, wildcards, and task flow calls
Converting an unbounded task flow to a bounded task flow
13 - 37
Objectives
14 - 2
Internationalization
14 - 3
Resource Bundles
str.browserTitle=StoreFront Beispielanwendung
str.about=ber dieses Beispiel
str.copyright=\u00a9 Oracle Corp, 2007
str.contact=Kontakt
14 - 4
14 - 5
14 - 7
14 - 8
Facets are:
Placeholders for subcomponents
Similar to detail elements
Used to specify subordinate elements such as toolbars,
headers, or footers
Displayed with the component
14 - 9
14 - 10
14 - 11
Defining a List
14 - 13
14 - 14
Selecting a Date
<af:inputDate value="#{bindings.OrderDate.inputValue}"
label="#{bindings.OrderDate.label}"
required="#{bindings.OrderDate.mandatory}">
<af:convertDateTime pattern="#{bindings.OrderDate.format}"/>
</af:inputDate>
14 - 16
14 - 18
Using Tables
Data filtering
Row selection
(single or
multiple rows)
14 - 19
14 - 20
Description
Attribute(s)
Setting(s)
Grid Lines
(table attribute)
Lines separating
cells
verticalGridVisible
horizontalGridVisible
true or false
Banding
(table attribute)
Alternating
background
colors
rowBandingInterval
columnBandingInterval
number of rows or
columns you want to
be in each band
Column or row
headers
Labels for
columns or rows
attribute
text to display in
header
true or false
Column groups
Column
formatting
Align, wrap,
width, height
Align
14 - 21
nowrap
width, height
start,end,left,
right, center
true or false
number or %
Using Trees
14 - 23
Tree tables:
Display hierarchical data
in a table
Combine features of
trees and tables
14 - 24
<af:tree
value="#{bindings.RootCategory1.treeModel}"
var="node">
<f:facet name="nodeStamp">
<af:outputText value="#{node}"/>
</f:facet>
</af:tree>
14 - 26
A tree binding rule for the root tree node, with an additional
level for the child collection, provides the hierarchical data.
14 - 27
Design time:
<af:messages/>
<af:outputText value="Error icon:"/>
<af:icon name="error"
shortDesc="Error Icon"/>
<af:outputText value="Info icon:"/>
<af:icon name="info"/>
<af:outputText value="Media component: "/>
<af:media source="/Brian.wma"
standbyText="One moment please"/>
Run time:
14 - 28
14 - 29
14 - 30
A quick query:
Has a selectable list of attributes to search on
Has a single search criterion input field
Can have a link to more advanced search capabilities, with
switching implemented in managed bean
14 - 32
14 - 34
14 - 35
Using
ADF Data Visualization Components
Common features:
Design time creation by
using:
14 - 36
Visualizing Data
Gauge
Graph
Gantt chart
14 - 37
Pivot table
Geographic
map
Summary
14 - 39
Practice 14 Overview:
Using ADF Faces Components
This practice covers the following topics:
Using a tree component
Creating a search page
Defining LOVs
14 - 40
Objectives
15 - 2
15 - 3
Performing Navigation
15 - 4
Command components:
Include af:commandButton and af:commandLink
Submit requests and fire action events when activated
Typically used for internal navigation
Go components:
Include af:goButton and af:goLink
Navigate directly without server-side actions
Are typically used for external navigation
Do not use control flow rules
15 - 5
15 - 6
Defining Tooltips
15 - 8
Toolbox
Toolbar
Stretched component
15 - 9
Overflow icon
15 - 10
Creating Menus
15 - 11
15 - 13
15 - 14
15 - 16
Using Breadcrumbs
Breadcrumbs: af:breadCrumbs
Links: af:commandNavigationItem
You can:
Define breadcrumbs explicitly
Bind to XML Menu Model
15 - 17
15 - 18
menu
groupNode
itemNode
sharedNode
Home
Benefits
Insurance
Health
15 - 19
Employee Data
Paid
Time Off
Dental
Level 0 (root_menu)
Home
Level 1 (home_menu)
Benefits
Employee Data
Level 2 (benefits_menu)
Insurance
Level 3
(insurance_menu)
15 - 20
Health
Paid
Time Off
Dental
15 - 22
Home
Benefits
Insurance
Health
15 - 23
Employee Data
Dental
Employee Data
Paid
Time Off
Dental
Copyright 2008, Oracle. All rights reserved.
15 - 26
Creating a Train
<af:train value="#{controllerContext.currentViewPort.taskFlowContext.trainModel}"/>
<af:trainButtonBar
value="#{controllerContext.currentViewPort.taskFlowContext.trainModel}"/>
<af:outputText value="Train Stop 1"/>
15 - 28
15 - 29
Summary
15 - 30
Practice 15 Overview:
Using ADF Faces Navigation Components
This practice covers the following topics:
Creating buttons and links to implement navigation
Adding breadcrumbs
Defining a train
15 - 31
Objectives
16 - 2
16 - 3
af:spacer
af:separator
af:panelSplitter
af:panelStretchLayout
af:panelAccordion
af:panelFormLayout
af:panelTabbed
af:showDetail
af:panelGroupLayout
af:panelCollection
af:panelHeader
af:showDetailHeader
af:group
af:panelList
af:panelBox
af:panelBorderLayout
<af:form>
<af:spacer width="10"/>
<af:outputText value="outputText1"/>
<af:spacer width="10"/>
<af:outputText value="outputText2"/>
<p><af:spacer height="10"/></p>
<af:separator/>
<p><af:spacer height="10"/></p>
<af:spacer width="10"/>
<af:outputText value="outputText3"/>
<af:spacer width="10"/>
<af:outputText value="outputText4"/>
</af:form>
16 - 4
Stretching Components
16 - 5
16 - 6
16 - 7
16 - 8
Nested:
Vertical
orientation:
16 - 9
collapsed positionedFromEnd
16 - 10
true
false
true
true
false
true
false
false
Characteristics of Panel
Accordion component:
Does not automatically
stretch it children
Panes cannot be resized
at run time only expand
or contract
Panes defined by
showDetailItem
<af:panelAccordion>
<af:showDetailItem text="This is a pane"/>
<af:showDetailItem text="This is another pane"/>
</af:panelAccordion>
16 - 11
16 - 12
<af:showDetailItem
text="Selected Product"
inlineStyle="width:100%;
height:100%;" flex="2">
With discloseMany="true"
discloseNone="true"
16 - 13
16 - 15
16 - 17
<af:showDetail>
<af:panelGroupLayout layout="vertical">
<af:outputText value="Indexed Child 1"/>
<af:outputText value="Indexed Child 2"/>
</af:panelGroupLayout>
</af:showDetail>
16 - 18
16 - 20
16 - 22
Panel header
component with
sections and
subsections:
af:panelHeader
16 - 24
16 - 25
Group related
child components
<af:panelFormLayout>
<af:inputDate label="Pick a date"/>
<!-- first group -->
<af:group>
<af:selectManyCheckbox label=
"Select all that apply">
<af:selectItem label="Coffee" value="1"/>
//other select items
</af:selectManyCheckbox>
<af:inputText label="Special instructions"
rows="3"/>
</af:group>
<!-- Second group -->
<af:group>
<af:inputFile label="File to upload"/>
<af:inputText label="Enter passcode"/>
</af:group>
<af:inputText label="Comments" rows="3"/>
<af:spacer width="10" height="15"/>
<f:facet name="footer"/>
</af:panelFormLayout>
16 - 26
decimal
lower-alpha
upper-alpha
Copyright 2008, Oracle. All rights reserved.
16 - 27
16 - 28
Included skins:
Oracle
Minimal
Simple
16 - 31
16 - 32
16 - 33
PPR:
Is enabled by ADF Faces
Enables redrawing only a portion of a page
Requires server round-trip:
Rerenders only a portion of the server-side component tree
Downloads only the appropriate fragment of HTML
16 - 34
Target component:
(must specify triggering
component)
16 - 35
16 - 37
<af:commandToolbarButton
id="updateToolbarButton"
text="Update Shopping Cart"/>
<af:table
//bindings
partialTriggers="deleteToolbarButton
menuDelete updateToolbarButton">
//list of columns
</af:table>
16 - 38
<af:commandToolbarButton
id="deleteToolbarButton"
text="Delete/>
<af:commandMenuItem
id="menuDelete" partialSubmit="true"
text="Delete"/>
Why?
Need logic to determine if component should refresh
Refresh should occur on only one of several events that a
triggering component may fire (for example, on row selection
in table, use a selection listener)
16 - 40
16 - 41
Purposes of PPR:
Improve application performance
Improve the user experience
16 - 42
Summary
16 - 43
Practice 16 Overview:
Using ADF Faces Layout Components
This practice covers the following topics:
Modifying the layout of pages
Defining partial page rendering
16 - 44
Ensuring Reusability
Objectives
17 - 2
Benefits of Reusability
17 - 3
Easier maintainability
Rapid adaptability
Guidelines:
Use naming conventions.
17 - 4
A resource catalog:
Enables application developers to find and incorporate
shared resources, such as libraries containing ADF BC
Model Objects, validators, message bundles, and so on,
that were created by other members of the team
Provides a federated view of the resources from one or
more otherwise unrelated repositories in a unified search
and browse UI
Enables you to store libraries comprising a common
repository that can be used by the developers building any
client application
Ensures that all application developers use the same
business model without any discrepancies
17 - 5
Creating a catalog:
Adding resources to
a catalog:
17 - 6
Reusing Components
17 - 7
17 - 8
17 - 9
Remove by:
Using Resource
Palette
17 - 10
17 - 11
17 - 12
17 - 13
Page templates:
Are reusable
Enable consistent look across pages or page fragments
Are built from standard ADF components
Cannot be nested
Use partial page refresh when navigating between pages that
use the same template
Use three types of files:
Page-specific definition file (.jspx)
Definition file for all templates: pagetemplate-metadata.xml
Application or library file (.cpx)
17 - 14
17 - 15
Menu Regions
A
Named Facets
B
News Portlet
17 - 16
A
Must continue
to use the
same named
facets
B
Footer
Modified Template
Original Template
17 - 17
17 - 18
Declarative components:
Are component definitions that are reusable across
applications
When changed, affect all pages that use them
Are made up of any number of other components
Do not have data binding in their definition
Can be made available for reuse in the Component Palette
Are defined only at design time in:
One .jspx file for each component
One declarativecomp-metadata.xml file for all
declarative components in a project
17 - 19
17 - 21
Creates metadata
17 - 22
Page fragments:
Are built like regular pages
Have page definition files like regular pages do
Are not defined as a full Web page
Can be displayed within a page that contains other content
Cannot contain af:document or f:view tags
17 - 23
17 - 24
17 - 25
Characteristics of Regions
An ADF region:
Represents a task flow as part of a page
Is similar to a portlet, but for local functionality
Can share information and transaction boundaries with
other page content
17 - 26
17 - 27
17 - 28
You can use a bounded task flow when you want to:
Reuse a set of activities and control flows
Use multiple page fragments in a region on a page
Create a portlet from a set of activities and control flows
17 - 29
Summary
17 - 30
Practice 17 Overview:
Implementing Reusability
This practice covers the following topics:
Converting bounded task flows to use page fragments
Creating a page template for the main page and for the
checkout flow
Using bounded task flows in regions on the main page
17 - 31
Passing Values
Between
UI Elements
Objectives
18 - 2
18 - 3
How?
Managed properties
Scoped managed bean variables
18 - 4
Possible values:
18 - 5
null
Literal string
Lists and Maps
Value binding expression (EL)
18 - 6
JSF scopes:
application
session
request
none
pageFlow scope:
Retains values for current process (page flow) only
Independent of other processes, unless using LaunchEvent
Can be accessed via EL or Java
Can be explicitly cleared
18 - 7
EL:
<af:commandButton
text="#{pageFlowScope.buttonBean.label}"
action="#{pageFlowScope.buttonBean.action}"/>
Java:
import java.util.Map;
import
org.apache.myfaces.trinidad.context.RequestContext;
. . .
Map pageFlowScope =
RequestContext.getCurrentInstance().getPageFlowScope()
;
Object myObject = pageFlowScope.get("myObjectName");
18 - 9
<af:table
The Master page stores an employee
value="#{myManagedBean.allEmployees}"
row in pageFlowScope variable
var="emp" rowSelection="single">
empDetail.
<af:column headerText="Name">
<af:outputText value="#{emp.name}"/>
</af:column>
<af:column
The Detail page retrieves employee
headerText="Department Number">
<af:outputText
data from pageFlowScope variable
value="#{emp.deptno}"/>
empDetail.
</af:column>
<h:panelGrid columns="2">
<af:column headertext="Select">
<af:outputText value="Firstname:"/>
<af:commandButton
<af:inputText
text="Show more details"
value="#{pageFlowScope.empDetail.name}"/>
action="showEmpDetail">
<af:outputText value="Email:"/>
<af:setActionListener
<af:inputText
from="#{emp}"
value="#{pageFlowScope.empDetail.email}"/>
to=
<af:outputText value="Hiredate:"/>
"#{pageFlowScope.empDetail}"/>
<af:inputText
</af:commandButton>
value="#{pageFlowScope.empDetail.hiredate}"/>
</af:column>
<af:outputText
value="Salary:"/>
</af:table>
<af:inputText
value="#{pageFlowScope.empDetail.salary}"/>
</h:panelGrid>
2
3
18 - 10
Using Parameters
18 - 11
#{bindings.nameToPass}
18 - 12
18 - 13
Parameter
type
Parameter name
Parameter value
Parameter function
output
nameToPass
#{'Pam'}
1. The pname parameter is passed into the task flow, and its
value is assigned to the pageFlowScope variable pname.
2.
18 - 14
Inside the task flow, activities and pages can get the value
of the parameter using the EL expression:
#{pageFlowScope.pname}
Containing
page
parameter
Parameter
type
Parameter name
Parameter value
Parameter function
output
nameToPass
#{'Pam'}
?
Bounded
task flow
parameter
input
Page
fragment in
task flow
#{pageFlowScope.pname}
18 - 16
pname
#{pageFlowScope.
pname}
18 - 17
Parameter name
Parameter value
Parameter function
Containing
page
parameter
output
nameToPass
#{'Pam'}
Region
parameter
output
pname
#{bindings.
nameToPass}
Bounded
task flow
parameter
input
pname
#{pageFlowScope.
pname}
Page
fragment in
task flow
#{pageFlowScope.pname}
18 - 18
Parameter name
Parameter value
Parameter function
Containing
page
parameter
output
nameToPass
#{'Pam'}
Region
parameter
output
pname
#{bindings.
nameToPass}
Bounded
task flow
parameter
input
pname
#{pageFlowScope.
pname}
?
Page
fragment in
task flow
18 - 19
#{pageFlowScope.ename}
18 - 20
Parameter name
Parameter value
Parameter function
Containing
page
parameter
output
nameToPass
#{'Pam'}
Region
parameter
output
pname
#{bindings.
nameToPass}
Bounded
task flow
parameter
input
pname
#{pageFlowScope.
pname}
View activity
parameter
internal
#{pageFlowScope.
ename}
#{pageFlowScope.
pname}
Page
fragment in
task flow
#{pageFlowScope.ename}
18 - 21
Page parameter
Region
parameter
Region
Task Flow
View Activity
Task flow
parameter
View activity
parameter
Page Fragment
18 - 22
18 - 25
18 - 27
Summary
18 - 28
Practice 18 Overview:
Passing Values Between Pages
This practice covers the following topics:
Conditionally displaying tables based on parameters
Changing a panel header title based on parameters
18 - 29
Objectives
After completing this lesson, you should be able to do the
following:
Configure and use managed beans to contain code to
respond to events
Describe the different types of events
Use phase listeners
Create event listeners
Define action listeners
Create value change listeners
Describe ADF Faces enhanced event handling
List other types of server events used by ADF Faces
components
Explain how ADF components use AJAX events
Use contextual events to coordinate regions
19 - 2
Adding UI Code
Managed beans:
Configured in adfc-config.xml or other task flow .xml
file
Plain Old Java Objects (POJOs), Lists and Maps
Have no-argument constructor
Lazy initialization by JavaServer Faces framework as
needed
19 - 3
3. Search class.
5. Create method.
4. Select class.
19 - 5
Entry in adfc-config.xml:
<managed-bean>
<managed-bean-name> DepartmentBean </managed-bean-name>
<managed-bean-class> sample.DepartmentsManagedBean
</managed-bean-class>
<managed-bean-scope> request </managed-bean-scope>
</managed-bean>
19 - 6
<af:inputText
value="#{DepartmentBean.firstName}"/>
FacesContext facesContext =
FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression exp =
expressionFactory.createValueExpression(elContext,
"#{DepartmentBean}", DepartmentsManagedBean.class);
DepartmentsManagedBean dept =
(DepartmentsManagedBean)exp.getValue(elContext);
19 - 7
19 - 8
19 - 9
19 - 11
19 - 13
JSF supports:
Phase events
Execute as part of the JSF and ADF life cycle
Can be used to augment standard behavior
Action events
Occur when a command component is activated, such as
when a user clicks a button or a link
Return a control flow outcome
19 - 14
Restore/Create
Component Tree
(View)
Apply
Request
Values
Process
Events,
Validation
Render
Response
Invoke
Application
Update
Model
Initial
Request
19 - 15
Event Object
Ive been clicked!
Does anyone care?
Yes Im listening!
Now Ill get to work
Event Listener
Event Source
19 - 16
19 - 17
JDeveloper:
If the bean does not exist, creates Java class and registers
as a managed bean
If the method does not exist, creates a method stub in the
managed bean class
Adds the method to the action property of component
19 - 18
Action methods:
Are used for navigation
Execute last
19 - 19
19 - 20
19 - 21
19 - 23
19 - 24
19 - 25
Access data in
the current row:
getRowData().
19 - 27
Access children of
current row:
enterContainer()
Revert to parent
collection:
exitContainer()
19 - 28
19 - 29
Contextual events:
Provide a way to coordinate regions
Containing
Page
19 - 30
19 - 31
Consumer
method
Producer
region
Consumer
region
Handler
Method
1
Producer
2
Producer
PageDef
19 - 32
Containing
Page
3
Consumer
5
Containing
PageDef
Consumer
PageDef
Producer
Containing
Page
Define a page
that contains
two regions.
19 - 33
Consumer
Producer
19 - 34
Payload
Method
Containing
Page
Consumer
Producer
19 - 35
Invoke the
payload method.
Containing
Page
Consumer
Producer
Producer
PageDef
19 - 36
Containing
Page
Supply a value
for the payload
method argument.
Consumer
Producer
Producer
PageDef
19 - 37
Containing
Page
Raise an event
when the
payload method
is invoked.
Consumer
Producer
Handler
Method
Containing
Page
Producer
PageDef
19 - 38
Create an
event handler.
Consumer
19 - 39
Handler
Method
Producer
Bind the
event
Containing handler.
Consumer
Producer
PageDef
Containing
PageDef
Consumer
PageDef
Page
Handler
Method
Producer
Containing
Page
Consumer
Producer
PageDef
Containing
PageDef
Consumer
PageDef
19 - 40
Producer
Handler
Method
Containing
Page
Consumer
Specify producer
region refreshing.
Specify consumer
region refreshing .
Producer
PageDef
19 - 41
Containing
PageDef
Consumer
PageDef
Summary
In this lesson, you should have learned how to:
Configure and use managed beans to contain code to
respond to events
Describe the different types of events
Use phase listeners
Create event listeners
Define action listeners
Create value change listeners
Describe ADF Faces enhanced event handling
List other types of server events used by ADF Faces
components
Explain how ADF components use AJAX events
Use contextual events to coordinate regions
19 - 42
Practice 19 Overview:
Responding to Events
This practice covers the following topics:
Defining task flow parameters
Using a contextual event to coordinate user selection in a
tree in one region with the display in another region
Using phase listeners
19 - 43
Objectives
20 - 2
20 - 3
Database table
ADF BC
Entity Object
20 - 4
ADF BC
View Object
Binding Container
ADF BC
Application Module
ADF Model
Data Control
20 - 5
20 - 6
Back Button
Support
Save for later
Declarative
Commit
/ Rollback
20 - 7
In Property Inspector
In Structure window
20 - 8
20 - 9
20 - 11
<data-control-scope>
<shared/>
</data-control-scope>
20 - 13
20 - 15
<exception-handler>ShowError</exception-handler>
...
...
<view id="ShowError"></view>
20 - 16
reentry-allowed: OK
reentry-not-allowed: Throws exception
reentry-outcome-dependent: Depends on
outcome from exited task flow
Return
to exited
task flow?
20 - 17
Quitting time
Ill work some
more on this
tomorrow.
20 - 19
Next morning
Greatright
where I
left off!
Contains
button that
performs save
for later
Calls
createSavePoint
to add a
save-point-id
Restores
application state
and data to what
was captured in
save-point-id
20 - 21
You can use the task flow editor or the Property Inspector to mark the
task flow as critical.
20 - 23
Restoring Savepoints
20 - 24
20 - 26
Summary
20 - 27
Practice 20 Overview:
Controlling Transactions
This practice covers the following topics:
Implementing commit functionality in the shopping cart
Adding transaction control to the checkout flow
Adding the ability to insert, update, and delete suppliers
20 - 28
Implementing Security
in
ADF Applications
Objectives
21 - 2
21 - 3
Resource 1
Resource 2
Resource 3
Resource 4
21 - 4
Resource 5
Resource 6
21 - 5
21 - 6
21 - 7
21 - 8
LDAP:
Identity store configured outside of JDeveloper
Scalable and secure
Integrates with Oracle Single Sign On
21 - 9
21 - 10
21 - 11
21 - 12
jps-config.xml
jazn-data.xml
Modified
Created
21 - 13
<CredentialStoreContext
<CredentialStoreContext credentialStoreClass=
credentialStoreClass=
"oracle.adf.share.security.providers.jazn.JAZNCredentialStore"
"oracle.adf.share.security.providers.jazn.JAZNCredentialStore"
credentialStoreDefaultUser="anonymous"
credentialStoreDefaultUser="anonymous"
credentialStoreLocation="./credential-jazn-data.xml"/>
credentialStoreLocation="./credential-jazn-data.xml"/>
<sec:JaasSecurityContext
<sec:JaasSecurityContext initialContextFactoryClass=
initialContextFactoryClass=
"oracle.adf.share.security.JAASInitialContextFactory"
"oracle.adf.share.security.JAASInitialContextFactory"
jaasProviderClass=
jaasProviderClass=
"oracle.adf.share.security.providers.jps.JpsSecurityContext"
"oracle.adf.share.security.providers.jps.JpsSecurityContext"
authorizationEnforce="true"
authorizationEnforce="true"
<serviceProviders>
authenticationRequire="true"/>
<serviceProviders>
authenticationRequire="true"/>
<serviceProvider
<serviceProvider
class="oracle.security.jps.internal..."
class="oracle.security.jps.internal..."
...
...
</serviceProvider>
</serviceProvider>
Based Authentication
uthentication
...
...
<serviceInstances>
<serviceInstances>
<jazn-realm
<serviceInstance
<jazn-realm default="jazn.com">
default="jazn.com">
<serviceInstance
<realm>
provider="credstore.provider"
<realm>
provider="credstore.provider"
<name>jazn.com</name>
...
<name>jazn.com</name>
...
</realm>
</serviceInstance>
</realm>
</serviceInstance>
</jazn-realm>
...
</jazn-realm>
...
<policy-store>
<jpsContexts
<policy-store>
<jpsContexts default="Storefront-12">
default="Storefront-12">
...
<jpsContext
...
<jpsContext name="anonymous">
name="anonymous">
...
<serviceInstanceRef
...
<serviceInstanceRef ref="credstore"/>
ref="credstore"/>
</policy-store>
...
</policy-store>
...
</jpsContext>
</jpsContext>
</jpsContexts>
</jpsContexts>
21 - 14
Adding a user to
a role in the
identity store
21 - 15
21 - 16
Policy store is in
jazn-data.xml.
21 - 17
Roles
clerk
manager
21 - 18
app_manager
Defined In:
Groups of pages
jazn-data.xml editor
Individual pages
Page definitions *
jazn-data.xml editor
Rows
Entity objects or
attributes
21 - 19
21 - 20
21 - 21
Purpose is to:
Prevent unauthorized access to entity objects or attributes
Enable developers to:
Secure access to an entire entity object or only certain
attributes
Specify the actions that members of a role can perform on
entity objects or attributes
21 - 22
Attribute of EO
21 - 23
Securable
Operation
Individual
attributes:
Expected Mapped
Action
Implementation
read
Read
removeCurrentRow
Delete
update
Update
update
Update
Update specific
attribute.
21 - 24
Two types:
Implicit: Based on JAAS permissions for anonymousrole role
21 - 25
Implicit Authentication
JAAS Security
/app/Public.jspx
P1
ADF
Security
Filter
P2
*.jsp
*.jspx
P3
/app/MyPage.jspx
1
Public.jsp
/adfAuthentication?success_url=/app/MyPage.jspx
2
MyPage.jspx
User: Bob
3
Authentication servlet
protected by J2EE
Security Constraint,
Triggers Container
login process
No
Session
Redirect to success
URL=/app/MyPage.jspx
as per #1
5
adfAuthentication
Servlet
J2EE Security
4
submit=j_security_check()
21 - 26
Container Authentication
Logic
BOB
Enterprise
Identity
Management
/app/Public.jspx
/adfAuthentication?success_url=/app/Public.jspx
J2EE Security Constraint
User: Bob
2
Authentication servlet
protected by J2EE
Security Constraint,
Triggers Container
login process
No
Session
J2EE Container
J2EE Security
Redirect to success
URL=/app/MyPage.jspx
as per #1
adfAuthentication
Servlet
submit=j_security_check()
21 - 28
Container Authentication
Logic
BOB
Enterprise
Identity
Management
J2EE Container
Bob has No
View
Privilege Defined
on the Page.
SecPage.jspx
/app/SecPage.jsp
View
/app/MyPage.jspx
*.jsp
*.jspx
/app/Public.jsp
User: Bob
PageDefs
PageDefs used as
Security Def end
points
Privilege is
granted to a Role
of which Bob is a
MyPage.jspx member.
JAAS
JAAS AuthZ
AuthZ
request
request
View Privilege
granted to the
or
anyone
Public.jsp
Policy Store
Bob is a member of the
Staff role in the policy
store.
Unlike J2EE Container
Security, authorization
is not path based.
21 - 29
<grant>
<principal>
<type>role</type>
<name>Staff</name>
</principal>
<permission>
<name>MyPage</name>
<actions>view</actions>
</permission>
</grant>
Administrator
HR
Dev
Staff
Sales
Clerks
Role.
Programmatically Accessing
ADF Security Context
Is ADF security turned on?
if (ADFContext.getCurrent().getSecurityContext().isAuthorizationEnabled())
{ }
21 - 30
21 - 31
Example: UI expression:
#{userInfo.admin}
Expression
Purpose
#{securityScope.securityEnabled}
Is security on?
#{securityScope.remoteUser}
#{securityScope.authType}
Type of authentication in
use: BASIC, DIGEST, FORM
#{securityScope.
userInRole['admin,manager']}
#{securityScope.
userInAllRoles['admin,manager']}
21 - 33
Purpose
#{securityContext.userName}
#{securityContext.userInRole
['role list']}
#{securityContext.userInAllRoles
['role list']}
#{securityContext.
userGrantedPermission
['permission']}
21 - 34
Summary
21 - 35
Practice 21 Overview:
Implementing ADF Security
This practice covers the following topics:
Configuring the application to use ADF Security
Defining users, roles, and application roles
Implementing entity object security
Accessing security context programmatically
21 - 36
Objectives
22 - 2
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.
22 - 3
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.
22 - 4
22 - 5
Deployment descriptors
22 - 6
For the
View-Controller
project
22 - 7
Creating a
Business Components Deployment Profile
You can create business components deployment profiles by
using one of the following:
Context menu
Project Properties dialog box
New Gallery
22 - 8
22 - 9
22 - 10
2
4
Context root becomes part of URL
to access the Web application.
22 - 11
22 - 12
22 - 13
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.
22 - 14
22 - 15
22 - 16
OR
Configure an existing
domain for ADF
22 - 17
2
4
22 - 19
22 - 21
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.
22 - 23
Creating a Connection to an
Application Server
22 - 24
3. Select a deployment
profile.
4. Select to deploy to an
EAR file, an existing
connection, or a new
connection.
3
4
22 - 25
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.
22 - 26
22 - 27
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.
22 - 28
Advantages of Ant:
22 - 29
Well-documented
Widely adopted
Easy to configure
Extensible
22 - 30
22 - 31
Adding a target:
Adding a task:
22 - 32
Running
on a target
Running on
a project
Running Ant from the toolbar
22 - 33
22 - 35
22 - 36
22 - 38
22 - 39
Summary
22 - 40
Practice 22 Overview:
Deploying the Web Application
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
22 - 41