Académique Documents
Professionnel Documents
Culture Documents
D16975GC10
Production 1.0
May 2004
D39416
Author
Gary Williams
Lynn Munsinger
Patrice Daux
Introduction
Objectives
I-2
Course Overview
I-3
Objectives
1-2
J2EE Platform
Client Machine
1-3
J2EE Server
Database Server
Client tier
Web tier
Business tier
EIS tier
Browser/
Application
JSP/
Servlet
Business
Services
Database
1-4
Client
container
Application
Client
J2EE Server
Business
Web
container
container
JSP/
Servlet
Business
Services
JNDI
RMI
JTA
JDBC
JMS
JavaMail
JAF
APIs
1-5
EIS tier
Database
1-6
What Is Framework-Based
Application Development?
A framework:
Is a productivity layer for building applications
Is a set of intelligent cooperating software
components
Is designed to be specialized for your business
Handles the majority of common tasks with
sensible behavior
Enables easy customization of default behaviors
Uses standard, proven techniques and design
patterns
1-7
Understanding Framework-Based
Application Development
Provides hook points
to standard functions
Framework
1-8
Standard behaviors
Data access methods
Transaction management
No messy code
generation
1-9
Visual
WYSIWYG editors
UML modelers
Structure pane
Declarative
Structure pane
Property Inspector
1-10
Design Patterns
Design patterns:
Are proven solutions to specific problems
Are a means to an end, not the end itself
Address programming tasks, not business
problems
Are reusable
Provide a framework for re-creatable results
1-11
Model-View-Controller Architecture
MVC provides logical separation of an application.
Client
tier
Web
tier
Browser/
Application
Model
Business Services
Controller
Business
tier
View
1-12
EIS
tier
Database
MVC Structure
Controller
Handles routing to the
correct page
Maps UI data changes
to the Model
Display
1-13
Submit
page
Data and
transactions
View
Model
Renders the UI
Requests data from the
Model
Sends Events to the Model
Allows the Controller to
select the next View
Request
data
View
Controller
Model
1-14
ADF Bindings
ADF Data Control
Business
Services
EJB
Session
Beans
Java
Classes
JDBC
TopLink
Queries
Java
Classes
ADF
Application
Module
EJB
Finders
ADF
View Object
EJB Entity
Beans
TopLink Mapping
1-15
ADF
Entity
Object
Web
Services
Bindings:
Metadata that describes how the UI components on
a page use the values and actions provided by the
Business Service
Data controls:
Metadata that describes the data model returned by
the Business Service
1-16
1-17
Struts in JDeveloper
1-18
Controller: Summary
1-19
View
Controller
Model
1-20
View Concept
1-21
View Technologies in
Oracle JDeveloper 10g
JavaServer Pages (JSP)
UIX
ADF JClient
Creating databound clients is the same in JDeveloper
for any of these supported client technologies.
1-22
View: Summary
1-23
View
JSP
Controller
1-24
JSF
Swing/
ADF JClient
Struts
ADF Model
Model
Business
Services
ADF UIX
ADF
Business
Components
EJB
Session
Beans
Web
Services
JavaBeans/
Other
ADF: Summary
1-25
Summary
1-26
Objectives
2-2
2-3
View
JSP
Controller
2-4
ADF UIX
Swing/
ADF JClient
Struts
ADF Model
Model
Business
Services
JSF
ADF
Business
Components
Web
Services
EJB
Session
Beans
JavaBeans/
Others
A Sample Application
2-5
Building an Application
1.
2.
3.
4.
2-6
Application Workspaces
2-7
2-8
2-9
2-10
2-11
2-12
2-13
success
/customers
2-14
/orders
2-15
2-16
Databinding: Example
2-17
2-18
Results
2-19
Summary
2-20
2-21
Objectives
3-2
View
JSP
Controller
3-3
ADF UIX
Swing/
ADF JClient
Struts
ADF Model
Model
Business
Services
JSF
ADF
Business
Components
Web
Services
EJB
Session
Beans
JavaBeans/
Other
3-4
3-5
Support standard
deployment options: EJB,
Web tier, Web services
Copyright 2004, Oracle. All rights reserved.
3-6
Business Components
3-7
Entity Objects
Enforce business rules and data validation
Persistence, caching
Data manipulation
Entity Associations
Enforce relational rules between entity objects
3-8
Application Modules
Manage transactions
Define data and methods that a client can see
View Objects
Provide client access to data
Are collections of data for client access
View Links
Link View Objects for Master-Detail coordination
3-9
OrderEntryApp
View
objects
PriorityOrder
ItemList
Entity
objects
Customers
3-10
Client-Facing
Reusable
Query
Components
Orders
OrderItems
Business Domain
Reusable
Business Logic
and Persistence
Components
3-11
3-12
3-13
3-14
3-15
3-16
Item Quantity
Item Price
Product Description
PriorityOrder
Customers
3-17
Orders
ItemList
OrderItems Products
1.
2.
3.
4.
3-18
3-19
3-20
3-21
Summary
3-22
3-23
Objectives
Middle tier
EIS tier
Web Container
ADF Business Services Tier
Model
Controller
Client
Validation
4-3
ADF
Application
Module
ADF
View
Object
ADF
Entity
Object
Business Logic
Validation
Copyright 2004, Oracle. All rights reserved.
Database
Database
Validation
4-4
Customers
Id
Name
Status
Email
Attributes
Status List
(Gold Silver Platinum)
Validation
rule
CUSTOMERS
Database
table
4-5
ID
NAME
STATUS
201
202
Steve
Mike
Gold
Silver
Email
msmith@company.com
dgonzales@company.com
Entity Object
Customer
4-6
Order
4-7
Right-click the
package name in the
navigator, and select
New Entity Object.
Enter
a name.
Select a
database
object.
Move to the
next step.
4-8
Customers.xml: Metadata
The Entity Object Wizard obtains all its information
from this file.
Is created by default (mandatory)
4-9
4-10
4-11
4-12
4-13
Mapping an Attribute to a
Database Sequence
create or replace trigger
insert_ord_id
BEFORE INSERT ON orders
FOR EACH ROW
DECLARE
new_id number;
BEGIN
SELECT orders_seq.NextVal
INTO new_id from Dual;
:new.order_id := new_id;
END;
1. Create a database
trigger.
4-14
4-15
Adding Validation
Entity-level
validation
Attribute-level
validation
4-16
4-17
ListValidator: Example
Customers.xml
4-18
A UniqueKeyValidator:
4-19
Domains
4-20
Domains: Example
4-21
4-22
URLDomain
appears in the
list of types.
4-23
Summary
4-24
4-25
Objectives
5-2
Middle Tier
EIS Tier
Web Container
ADF Business Services Tier
Model
Controller
5-3
ADF
Application
Module
ADF
View
Object
ADF
Entity
Object
Database
Overview
View object
Entity object
Customers
CustomerStatus
SELECT name, status
FROM customers
ORDER BY name
Name
ID
Name
Status
Web site
5-4
Mike
Steve
Susan
ID
NAME
STATUS
WEBSITE
201
202
Steve
Mike
Gold
Silver
http://www...
http://www...
Database
table
Status
Silver
Gold
Platinum
View Objects
PriorityOrder
Order
5-5
CustomerStatus
Customers
getAttr()
VO
getCalcAttr() VO
5-6
setAttr()
EO
5-7
VO
Order status
is changed in
one view.
New value is immediately
displayed in other views
based on same entity.
5-8
5-9
ViewObjectImpl
This is the view object class.
It represents a view object.
Use this class to add or override behaviors that
apply to the view object.
ViewRowImpl
This is the view row class.
It represents a row in a view object.
Use this class to add or override behaviors that
apply to a row within the view object.
5-10
LineItemView.xml: Metadata
It is always generated.
The ADF framework retrieves
run-time metadata from this file.
JDeveloper design time uses this
file for View Object properties.
5-11
5-12
Customers
Orders
ID
FirstName
LastName
Status
Email
ID
Orderdate
Status
Custid
Trackingno
5-13
5-14
View Links
5-15
InventoryItem
OrderForItem
LineItem
Source
view object
Link
Destination
view object
Traversing Links
5-16
Source
entity
object
5-17
5-18
Middle Tier
EIS Tier
Web Container
ADF Business Services Tier
Model
Controller
5-19
ADF
Application
Module
ADF
View
Object
ADF
Entity
Object
Database
Application Modules
5-20
5-21
5-22
5-23
Summary
5-24
5-25
Objectives
6-2
Overview
Entity Object
Validation Type
Customers
Id
Name
Status
Email
Attribute
Method Validator
6-3
Domain
E-mail must
contain an "@"
and "."
Entity
Method
Validator
Customer e-mail
must exist
If the OrderMode
is "ONLINE"
Orders
Id
CustomerId
OrderMode
OrderTotal
Business Rule
6-4
Validating Attributes
6-5
6-6
Be defined as public
Accept a single argument of the same type as the
attribute
Return a Boolean value
Start with validate
6-7
6-8
6-10
6-11
Validation Order
Associations
6-13
Association Example
Customers
Source
6-14
OrderPlacedBy
Association
Orders
Destination
Accessor Methods
6-15
Association Types
Association
Entities are related but not completely dependent.
Either end of the association can exist without the
other.
It is usually a categorization.
Composition
Destination entity is completely dependent on the
source entity.
The source entity owns the destination entity.
No destination entity can be created without the
owning entity existing first.
6-16
6-17
The one
side of the
association
6-18
The many
side of the
association
6-19
Traversing Associations:
Destination to Source
LineItem
Order
getLineItem()
ItemOrderedOnAssoc
getTrackingNo()
6-20
Traversing Associations:
Source to Destination
LineItem
Order
getLineItem()
ItemOrderedOnAssoc
6-21
Summary
6-22
6-23
Objectives
7-2
Overview
View object
CustomerOrders
Customers
ID
Name
Status
Email
select c.name,
o.order_total from
customers c,
orders o where
c.id=o.customer_id
Orders
ID
CustomerId
OrderMode
OrderTotal
7-3
Custom method
getFullName()
7-4
7-5
7-6
SELECT...
7-7
VO
7-8
7-9
7-10
7-11
7-12
ViewObject vo = am.findViewObject("CustomersView");
while (vo.hasNext()) {
CustomersViewRow row = (CustomersViewRow) vo.next();
System.out.println("Customer First Name is " +
row.getAttribute("CustLastName));
}
Configuration.releaseRootApplicationModule(am,true);
7-13
7-14
7-15
Parameters
7-16
7-17
7-18
7-19
Summary
7-20
7-21
Objectives
8-2
8-3
Authentication
8-4
User
Authorization
Read/Write
Application
8-5
8-6
Principals
Subjects
Login module authentication
Roles
Realms
Policies and permissions
8-7
8-8
8-9
8-10
Entity Privileges
8-11
Attribute Permissions
8-12
8-13
8-14
Summary
8-15
8-16
Objectives
9-2
The Controller
Client Tier
Middle Tier
EIS Tier
Web Container
ADF Business Services Tier
Model
Controller
9-3
ADF
Application
Module
ADF
View
Object
ADF
Entity
Object
Database
JSP
Controller
9-4
ADF UIX
Swing/
ADF JClient
Struts
ADF Model
Model
Business
Services
JSF
ADF
Business
Components
Web
Services
EJB
Session
Beans
JavaBeans/
Other
Purpose of a Controller
9-5
<a href="page2.jsp">
<a href="page1.jsp">
page1.jsp
9-6
page2.jsp
<a href="page2.jsp">
<a href="page1.jsp">
page1.jsp
page2.jsp
page1a.jsp
9-7
<a href="page2.jsp">
<a href="page1.jsp">
page1.jsp
page2.jsp
page1a.jsp
9-8
page1.jsp
page2.jsp
<a href="page1a.jsp">
<a href="page1a.jsp">
page1a.jsp
9-9
Controller
Next
page1.jsp
9-10
Previous
page2.jsp
Next
Next
Previous
page1.jsp
page2.jsp
page1a.jsp
9-11
What Is Struts?
9-12
Struts Components
View
Tags
JSP
Action Form
Controller Servlet
Action
Resource Bundle
Controller
Struts Config
Model
Model
9-13
Struts Components
9-14
Struts
Controller Servlet
Action
Model
Action
Form
validate()
Forward
execute()
9-15
Return
Response
Page
Struts Components:
The Controller Servlet
9-16
Is designed to be extended
Is driven by XML
Struts Components:
The Configuration file
Is named struts-config.xml
9-17
Struts Components:
Actions
9-18
Struts Components:
ActionForms (Form Beans)
9-19
Struts Components:
Tag Libraries
9-20
9-21
9-22
Struts in
Oracle JDeveloper 10g
9-23
It is written in XML.
It is the road map of the application.
It can be cumbersome to update directly.
JDeveloper provides a graphical editing tool,
free of XML syntax.
<struts-config>
<action-mappings>
<action path="/action1">
<forward name="success" path="/page1.do"/>
</action>
</action-mappings>
<message-resources
parameter="view.ApplicationResources"/>
</struts-config>
9-24
9-25
9-26
9-27
9-28
Struts Components:
Actions
To create an action:
Use the Action icon to draw actions and
ActionForms on the Page Flow Diagram
Specify the path name for the action
The path name is a logical name
Modify the execute() method
Return a forward
9-29
Struts Components:
Pages and Page Forwards
Creating a page
Makes a direct reference to the page name
Requires to be changed for every occurrence
of the page when renaming it
9-30
Struts Components:
Forwards and Links
9-31
DataAction
Create as a standalone action for executing
custom methods of the business service
Handles standard actions from databound pages
9-32
Summary
9-34
Objectives
10-2
What Is a JSP?
Calls
Request
Client
JSP
Struts
Generates
Controls
Dynamic content
Response
10-4
ADF Business
Components
Example: JSP
10-5
10-6
Syntax
Purpose
Scriptlets
Java code
Expressions
Java code
that is
evaluated
Directives
<%@ page
language="java" %>
Global values
Declarations
Variable
declarations
JSP Directives
10-8
10-9
10-10
<c:out value="avalue"></c:out>
10-11
10-12
Struts Tags
10-13
10-14
10-15
10-16
10-17
Table
Dynamic Table
Navigation Buttons
Input Form
Read-Only Form
Select Row Link
Graph
Navigation List
10-18
Operations
Customizing Controls
10-20
10-21
Summary
10-22
10-23
Customizing Actions
Objectives
11-2
11-3
/auth
11-4
11-5
Forwards
success
/page1
/page2
<action path="/authUser"
type="view.AuthUserAction">
<forward path="/page1.do" name="success"/>
<forward path="/page2.do" name="failure"/>
</action>
11-6
11-7
11-8
Form Beans
Logon
User Name
Password
Logon
Submit
authUser
Populates
logonBean
menu
11-9
Form Beans
Can be dynamic:
Each field specified in struts.config.xml
Does not require Java code
11-10
/authUser
11-11
11-12
11-13
11-14
11-15
Logon
failure
authUser
success
<action-mappings>
<action path="/logon
forward="/logon.jsp"/>
<action path="/authUser"
name="logonBean"
type="view.AuthUserAction">
<forward
path="/logon.do
name="failure"/>
<forward
path="/menu.do
name="success"/>
</action>
<action path="/menu"
forward="/menu.jsp"/>
</action-mappings>
menu
11-16
Logon
failure
authUser
success
menu
11-17
<action path="/authUser"
name="logonBean"
type=" view.AuthUserAction ">
<forward
path="/logon.do
name="failure"/>
<forward
path="/menu.do
name="success"/>
</action>
<action path="/menu"
forward="/menu.jsp"/>
</action-mappings>
Logon
<action path="/authUser"
name="logonBean"
type=" view.AuthUserAction ">
failure
<forward
path="/logon.do
name="failure"/>
authUser
success
menu
11-18
<forward
path="/menu.do
name="success"/>
</action>
<action path="/menu"
forward="/menu.jsp"/>
</action-mappings>
Logon
Password
Logon
failure
Submit
authUser
success
logonBean
menu
11-19
Logon
failure
<form-beans>
<form-bean
name="logonBean
type="org.apache.struts.
action.DynaActionForm">
authUser
success
menu
11-20
<form-property
name="username"
type="java.lang.String"/>
<form-property
name="password"
type="java.lang.String"/>
</form-bean>
</form-beans>
Logon
Password
Logon
failure
Submit
authUser
Passed to
Populates
success
logonBean
menu
11-21
11-22
Logon
Password
Logon
failure
Submit
authUser
Passed to
Populates
success
logonBean
menu
11-23
11-24
Summary
11-25
11-26
Objectives
12-2
12-3
12-4
12-5
12-6
12-7
Displaying Data
12-8
Displaying Data
Generated code
<c:forEach var="Row"
items="${bindings.CustomersView1.range
Set}">
<tr><td>
<c:out value="${Row.CustomerId}">
</c:out></td>
12-9
12-10
/addCustomer
<action path="/addCustomers"
<set-property property="methodName"
value="addCustomersUIModel.Create"/>
</action>
12-11
setCurrentRowWithKey
Delete
12-12
12-13
5. Process updates
6. Validate updates
7. Handle model and UI events
12-14
12-15
Defined by:
Dragging operation from the Data Control Palette
Explicit creation in the Structure pane
Invoked by:
Button with the name event_<operation>,
for example, event_Commit.
Hyperlink with a parameter event=< operation>,
for example, event=Commit.
12-16
Invoked by:
12-17
12-18
12-19
<html:form action="/addCustomers.do">
12-20
Summary
12-21
12-22
Objectives
13-2
Overview of Validation
Form Bean validate()
method, Struts Validator
JSP
JavaScript
13-3
Struts
Form Bean
Method Validators,
Control Hints
Struts
Action
ADF
Business
Components
13-4
Client-Side Validation
13-5
13-7
<body>
<html:errors />
13-8
Validating Actions
13-9
13-10
13-11
Validation Results
13-12
Struts Validator
13-13
13-14
13-15
13-16
validation.xml: Example
13-17
13-18
Exception Handling
13-19
JavaScript
JavaScript is supported
in JDeveloper as a
simple way to
incorporate validation.
13-20
13-21
Summary
13-22
13-23
Objectives
14-2
14-3
Property Inspector:
Style
poplist
Font
poplist
Font
size
Bold/
italic/
underline
14-4
Foreground
color
Align left/
center/right
Background
color
Numbered/
bulleted
list
Decrease/
increase
indent
14-5
14-6
14-7
14-8
CSS File
untitled1.css
14-9
14-10
14-11
14-12
14-13
14-14
DepartmentsView1
Drop As:
Navigation Buttons
14-15
Cursor
14-16
14-17
14-18
Using EL Attributes
To reference attributes:
Enclose within ${}
Nest by using dot notation or []
<c:out value=
"${sessionScope.cart.numberOfItems} ">
14-19
Operators
<c:if test="${bean1.a
14-20
14-22
Summary
14-23
14-24
Objectives
15-2
JAAS Provider
15-3
15-4
JAZNUserManager
Obfuscates passwords in flat file storage
Supports full role-based access control
Supports full support for Java 2 permissions model
15-5
Client Authentication
Authentication:
Determines who clients are
Can they prove it?
15-6
Client Authorization
15-7
Servlet 1 Servlet 2
OracleAS
JAAS
JAZNUserManager
JAAS
HTTP Server
15-8
OracleAS
JAAS Policy
OracleAS
JAZN Provider
15-9
15-10
web.xml Properties
15-11
web.xml Results
<web-app>
<security-constraint>
<web-resource-collection>
<web-resource-name>TestApplication</web-resource-name>
<url-pattern>/</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>users</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>users</role-name>
</security-role>
</web-app>
15-12
15-13
Adding Users
15-14
Managing Roles
15-15
15-16
15-17
Summary
15-18
Objectives
16-2
Design-time benefits
Run-time benefits
16-3
Servlet
View
Controller
Model
Any data source
16-4
UIX Page
16-5
Markup
1.
2.
3.
4.
5.
16-6
Page Header
Tabs and Navigation
Global Buttons
Data Component Area
Page Footer
Interface Nodes
16-7
How Is It coded?
UIX XML is a dialect of the XML language for creating ADF
UIX pages declaratively.
16-8
16-9
16-10
16-11
16-12
16-13
Page Tabs
16-14
Global Buttons
16-15
Page Footers
16-16
16-17
16-18
16-19
16-20
16-21
16-22
16-23
Summary
16-24
16-25
Objectives
17-2
Overview
Servlet/JSP/HTML
Packaging
Libraries, Packages
17-3
Deployment
17-4
17-5
Archive Type
Module Type
Software Content
Java Application
components
EJB JAR
Enterprise
JavaBeans (EJB)
components
Servlets and
JavaServer Pages
(JSP) components
Enterprise Archive
(EAR)
Not applicable
J2EE application
17-6
Deploying to OC4J
17-7
Install OC4J
17-8
17-9
17-10
17-11
17-12
Deploying to OC4J
17-13
Running Applications
17-14
Customizing Deployment
17-15
Summary
17-16
17-17
Course Schema
Practice Solutions