Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

download Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

of 399

Transcript of Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    1/398

    Oracle JDeveloper 10 g : Build Applications with ADF

    Electronic Presentation

    D16975GC10Production 1.0May 2004D39416

    ®

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    2/398

    Copyright © 2004, Oracle. All rights r eserved.

    This documentation contains proprietary information of Oracle Corporation. It is provided under alicense agreement containing restrictions on use and disclosure and is also protected by copyrightlaw. Reverse engineering of the software is prohibited. If this documentation is delivered to a U.S.Government Agency of the Department of Defense, then it is delivered with Restricted Rights and thefollowing legend is applicable:

    Restricted Rights Legend

    Use, duplication or disclosure by the Government is subject to restrictions for commercial computersoftware and shall be deemed to be Restricted Rights software under Federal law, as set forth insubparagraph (c)(1)(ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software(October 1988).

    This material or any portion of it may not be copied in any form or by any means without the expressprior written permission of the Education Products group of Oracle Corporation. Any other copying isa violation of copyright law and may result in civil and/or criminal penalties.

    If this documentation is delivered to a U.S. Government Agency not within the Department ofDefense, then it is delivered with “Restricted Rights,” as defined in FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).

    The information in this document is subject to change without notice. If you find any problems in thedocumentation, please report them in writing to Worldwide Education Services, Oracle Corporation,500Oracle Parkway, Box SB-6, Redwood Shores, CA 94065. Oracle Corporation does not warrantthat this document is error-free.

    Oracle and all references to Oracle Products are trademarks or registered trademarks of OracleCorporation.

    All other products or company names are used for identification purposes only, and may betrademarks of their respective owners.

    Author

    Gary WilliamsLynn Munsinger Patrice Daux

    Technical Contributors and

    Reviewers

    Jeff GallusPam Gamer Duncan Mills

    Publisher

    Joseph Fernandez

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    3/398

    Copyright © 2004, Oracle. All rights reserved.

    Introduction

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    4/398

    I-2 Copyright © 2004, Oracle. All rights reserved.

    Objectives

    After completing this course, you should be able to do

    the following:• Design and implement business services by using

    Oracle ADF Business Components

    • Generate and test the end-to-end components as acomplete ADF application• Build Web-based views for an application, using

    declarative tools in Oracle JDeveloper 10 g• Use Oracle JDeveloper 10 g to define user interface

    functionality and application flow based on Struts

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    5/398I-3 Copyright © 2004, Oracle. All rights reserved.

    Course Overview

    This course teaches:

    • How to build J2EE applications by using OracleJDeveloper 10 g

    • How to build and implement business services by

    using Oracle ADF Business Components• How to build MVC-based client applicationcomponents

    • How to use Struts as the controller in an MVC-based application

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    6/398Copyright © 2004, Oracle. All rights reserved.

    Oracle Application DevelopmentFramework

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    7/398Copyright © 2004, Oracle. All rights reserved.1-2

    Objectives

    After completing this lesson, you should be able to do

    the following:• Describe the Java 2, Enterprise Edition (J2EE)

    platform

    • Describe the benefits of framework-basedapplication development• Describe the purpose and benefits of Oracle ADF• Describe the Model-View-Controller (MVC)

    architecture• Describe the technologies used in each of the

    MVC layers

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    8/398Copyright © 2004, Oracle. All rights reserved.1-3

    J2EE Platform

    • Is a multit iered, distributed application model

    • Supports component-based J2EE applications

    Business tier

    JSP/Servlet

    Browser/ Application

    BusinessServices

    Web t ier Client tier EIS tier

    Database Server J2EE Server Client Machine

    Database

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    9/398Copyright © 2004, Oracle. All rights reserved.1-4

    Benefits of the J2EE Platform

    • “ Write once, run anywhere” provides simplified

    component development.• J2EE separates client requirements from business

    logic.

    • J2EE provides multiple development and designscenarios: – Multitier – Web – Stand-alone client

    • J2EE separates development tasks into specificskill areas.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    10/398Copyright © 2004, Oracle. All rights reserved.1-5

    J2EE Platform: Architecture Details

    JSP/Servlet

    Browser

    BusinessServices

    Webcontainer

    Clientcontainer

    EIS tier J2EE Server

    Database Application

    Client

    APIs

    Businesscontainer

    Client Machine

    JMS

    JNDI RMI

    JDBC

    JTA

    JavaMail

    JAF

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    11/398Copyright © 2004, Oracle. All rights reserved.1-6

    Building J2EE Applications

    • Building J2EE applications can be complex.

    • Development time can be extensive.• Choosing and implementing appropriate design

    patterns can be overwhelming.

    • “ Do it yourself” applications often repeat existingapplication code.• A large portion of “ Do it yourself” code is

    dedicated to common tasks.• The more code you write, the greater is the chance

    of errors.• Using an existing application framework enables

    you to concentrate on your business needs.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    12/398Copyright © 2004, Oracle. All rights reserved.1-7

    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 majori ty of common tasks with

    sensible behavior • Enables easy customization of default behaviors• Uses standard, proven techniques and design

    patterns

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    13/398Copyright © 2004, Oracle. All rights reserved.1-8

    Understanding Framework-Based

    Application Development

    A framework provides base

    functionality:• Standard behaviors• Data access methods• Transaction management

    You can augment

    or circumventbase functionality.

    Provides “ hook points”

    to standard functions

    Your objects haveonly your code.

    Framework

    No messy codegeneration

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    14/398Copyright © 2004, Oracle. All rights reserved.1-9

    Oracle Application Development

    Framework

    • Reduces the complexity of J2EE development by

    providing visual and declarative development• Increases development productivity

    – Less coding, more reuse – Focus on the application, not the “ plumbing”

    • Encourages J2EE best practices by implementingstandard J2EE design patterns (MVC)

    • Provides a flexible and extensible environment byallowing multiple technology choices anddevelopment styles

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    15/398

    Copyright © 2004, Oracle. All rights reserved.1-10

    Visual and Declarative Development

    • Visual

    – WYSIWYG editors – UML modelers – Structure pane

    • Declarative – Structure pane – Property Inspector

    • Code view/design view synchronization – No separate generation step—always synchronized – Underlying code always accessible

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    16/398

    Copyright © 2004, Oracle. All rights reserved.1-11

    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

    • The MVC architecture is an example of a designpattern.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    17/398

    Copyright © 2004, Oracle. All rights reserved.1-12

    Model-View-Controller Architecture

    MVC provides logical separation of an application.

    Browser/ Application

    Webtier Clienttier EIStier

    Database

    View

    Controller Model

    Businesstier

    B u s i n

    e s s S er v i c

    e s

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    18/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    19/398

    Copyright © 2004, Oracle. All rights reserved.1-14

    What Is the Model?

    • It is a wrapper and abstraction for business

    services: – Handles data events from the Controller – Feeds data to the View

    • It manages and presents data from differentBusiness Service types in a common way.

    View Controller

    Model

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    20/398

    Copyright © 2004, Oracle. All rights reserved.1-15

    The Model Layer

    BusinessServices

    Model

    TopLink Mapping

    ADF Bindings

    ADF Data Control

    WebServices

    ADF Application

    Module

    JavaClasses

    EJBSessionBeans

    TopLinkQueries

    ADFView Object

    JavaClasses

    EJBFinders

    ADFEntityObject

    EJB EntityBeans

    JDBC

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    21/398

    Copyright © 2004, Oracle. All rights reserved.1-16

    Components of the Model Layer

    • Bindings:

    – Metadata that describes how the UI components ona page use the values and actions provided by theBusiness Service

    • Data controls: – Metadata that describes the data model returned by

    the Business Service

    • The metadata has the same format for all business

    services. ADF Bindings

    ADF Data Control

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    22/398

    Copyright © 2004, Oracle. All rights reserved.1-17

    What Is the Controller?

    On a Web page, everything significant

    happens on submit or a link.• A Controller intercepts a request anddispatches it to the correct page.

    • The source page does not have to know how tohandle an event or where to go next.

    • The handling code does not need to know whatpage to display in response.

    • The Controller separates the Model and the View.• The Controller manages the flow of a Web

    application.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    23/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    24/398

    Copyright © 2004, Oracle. All rights reserved.1-19

    Controller: Summary

    • Controllers are key to MVC separation

    and to promote code and layer reuse.• Apache Struts is the de facto standard forWeb application controllers.

    • Oracle JDeveloper 10 g supports Struts as acontroller.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    25/398

    Copyright © 2004, Oracle. All rights reserved.1-20

    What Is the View?

    • The MVC View is the UI of the application.

    • It is what the end user sees and interacts with.

    View Controller

    Model

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    26/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    27/398

    Copyright © 2004, Oracle. All rights reserved.1-22

    View Technologies in

    Oracle JDeveloper 10 g

    • JavaServer Pages (JSP)

    • UIX• ADF JClient

    Creating databound clients is the same in JDeveloper

    for any of these supported client technologies.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    28/398

    Copyright © 2004, Oracle. All rights reserved.1-23

    View: Summary

    • Views contain only display code.

    • Views do not contain application logic.• Views do not contain navigation logic.• Views are independent of the Controller and the

    Model.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    29/398

    Copyright © 2004, Oracle. All rights reserved.1-24

    ADF Technology Stack

    WebServices

    EJBSessionBeans

    JavaBeans/Other

    JSP JSF

    Struts

    Swing/ ADF JClient ADF UIX

    ADFBusiness

    Components

    ADF Model

    View

    Controller

    Model

    BusinessServices

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    30/398

    Copyright © 2004, Oracle. All rights reserved.1-25

    ADF: Summary

    • Productive end-to-end development

    – Model-View-Controller – Visual – Declarative

    • Standard J2EE framework – Implements J2EE best practices – Uses the latest standards – Provides architecture choices – Is built on the MVC design pattern

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    31/398

    Copyright © 2004, Oracle. All rights reserved.1-26

    Summary

    In this lesson, you should have learned how to:

    • Identify the benefits of framework-basedapplication development• Describe the Java 2, Enterprise Edition (J2EE)

    platform• Define the components of the Model-View-

    Controller architecture• Describe the benefits of Oracle Application

    Development Framework (ADF)• Describe the technologies used in each of the

    MVC layers

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    32/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    33/398

    2-2 Copyright © 2004, Oracle. All rights reserved.

    Objectives

    After completing this lesson, you should be able to dothe following:• Identify the typical process cycle for developing

    an ADF application• List the main design-time features used to build

    ADF applications• Use the course application to query products and

    to perform a transaction

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    34/398

    2-3 Copyright © 2004, Oracle. All rights reserved.

    Project Technology Scopes

    • ADF is a design-time and run-time framework forJ2EE applications.

    • JDeveloper provides design-time tools to supportJ2EE development.

    • There are numerous technology stacks availablefor J2EE application development.

    • The choice is yours.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    35/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    36/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    37/398

    2-6 Copyright © 2004, Oracle. All rights reserved.

    Building an Application

    1. Create an application workspace.

    2. Select the technology scope.3. Design the business services for the Model.4. Design the application page flow for the

    Controller.5. Create pages for the View.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    38/398

    2-7 Copyright © 2004, Oracle. All rights reserved.

    Application Workspaces

    • An application workspace is a way of viewing thecomponents of your application.

    • JDeveloper provides several ways to view yourapplication: – Application-based view – File system view – Code-organized view

    • These views enable you to organize your project

    the way that works best for you.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    39/398

    2-8 Copyright © 2004, Oracle. All rights reserved.

    Application Workspace Templates

    • JDeveloper provides application templates basedon technology choices.

    • You can create your own template, or you canchoose the technology template for yourapplication: – Web Application (default)—ADF UIX, JSP, Struts,

    and ADF Business Components – Web Application (JSP, Struts, and EJB)

    – Java Application (default)—ADF JClient and ADFBusiness Components – Java Application—Java, Swing/JFC, and JavaBeans – Custom Application—All JDeveloper technologies

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    40/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    41/398

    2-10 Copyright © 2004, Oracle. All rights reserved.

    New Application Workspace

    The application contains:

    • A project for the model (business services)• A project for the View and the Controller

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    42/398

    D i h B i S i f h

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    43/398

    2-12 Copyright © 2004, Oracle. All rights reserved.

    Design the Business Services for the

    Model: ADF Business Components• Business Components also

    contain View components(View objects).

    • View objects expose data toclient applications.

    • Select all the objects that youwant to expose to the client.

    • The wizard creates the objects

    that you need.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    44/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    45/398

    Create JSP Pages

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    46/398

    2-15 Copyright © 2004, Oracle. All rights reserved.

    Create JSP Pages

    • Double-click the DataPage to create a viewcomponent.

    • Use a .jsp file name extension to create a JSPpage.

    • Use a .uix file name extension to create a UIXpage.

    • This opens the JSP or UIX Visual Editor.

    Using the Visual Editors

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    47/398

    2-16 Copyright © 2004, Oracle. All rights reserved.

    Using the Visual Editors

    • The Data Control Palette shows the data modelthat you have defined.

    • Select the data elements that you want to displayon the page.

    • Use “ Drag and Drop As:” to select how you wantto display the data.

    • Drag the element to the page.

    Databinding: Example

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    48/398

    2-17 Copyright © 2004, Oracle. All rights reserved.

    Databinding: Example

    Display Customer as an input form:

    Adding HTML to Enhance the User

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    49/398

    2-18 Copyright © 2004, Oracle. All rights reserved.

    Adding HTML to Enhance the User

    Interface Add HTML to enhance the user interface.

    Results

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    50/398

    2-19 Copyright © 2004, Oracle. All rights reserved.

    Results

    Right-click the Customers DataPage, and select run.

    Summary

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    51/398

    2-20 Copyright © 2004, Oracle. All rights reserved.

    Summary

    In this lesson, you should have learned how to:

    • Build a simple default application by usingJDeveloper • Describe and use an application workspace• Create default ADF Business Components• Create a simple page flow diagram• Create and edit JSP Pages

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    52/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    53/398

    Copyright © 2004, Oracle. All rights reserved.

    Getting Started with ADF BusinessComponents

    Objectives

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    54/398

    3-2 Copyright © 2004, Oracle. All rights reserved.

    Objectives

    After completing this lesson, you should be able to dothe following:• Identify the two groups of Business Components• Define the purpose and function of Business

    Components• Create an Entity Object• Create a View Object• Create an Application Module• Use the Business Components Browser to test an

    application

    ADF Technology Stack

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    55/398

    3-3 Copyright © 2004, Oracle. All rights reserved.

    gy

    WebServices

    EJBSessionBeans

    JavaBeans/Other

    JSP ADF UIX

    Struts

    Swing/ ADF JClientJSF

    ADFBusinessComponents

    ADF Model

    View

    Controller

    Model

    BusinessServices

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    56/398

    ADF Business Components

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    57/398

    3-5 Copyright © 2004, Oracle. All rights reserved.

    p

    • Are a complete business tierdevelopment framework

    • Implement J2EE design patternsand best practice solutions for: – Business logic

    implementation – Scalability and

    performance – Optimized database

    interaction

    • Support standarddeployment options: EJB,

    Web tier, Web services

    Benefits of ADF Business Components

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    58/398

    3-6 Copyright © 2004, Oracle. All rights reserved.

    p

    • ADF Business Components increase productivity – Reusable components – Reentrant wizard-driven creation of objects – Simple O/R mapping

    • They provide application logic infrastructure – Ready-to-use data functions – No need to hand-code standard data access

    routines.

    – You only code exceptions to standard behavior.

    Business Components

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    59/398

    3-7 Copyright © 2004, Oracle. All rights reserved.

    The Business Components framework comprises twogroups of components:• Business Domain components

    – Enforce business rules – Entity Objects, Entity Associations,

    and Custom Object types• Data Model components

    – Provide data access to

    client applications – View Objects, View Links,and Application Modules

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    60/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    61/398

    Business Components Model

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    62/398

    3-10 Copyright © 2004, Oracle. All rights reserved.

    Application tasksTransaction handlingOrderEntryApp

    Applicationmodule

    Viewobjects

    Entity

    objects

    PriorityOrder ItemList

    Customers Orders OrderItems

    Client-FacingReusable

    QueryComponents

    Business DomainReusable

    Business Logicand Persistence

    Components

    Building a Business Components Model

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    63/398

    3-11 Copyright © 2004, Oracle. All rights reserved.

    The basic steps to create a Business Componentsmodel are:1. Create a connection to a database.2. Create an application workspace.3. Create Entity objects based on database tables.4. Create View objects to support a client

    application.5. Create an Application module to publish data

    access methods.6. Test the Business Components.

    Creating a Database Connection

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    64/398

    3-12 Copyright © 2004, Oracle. All rights reserved.

    A database connection provides access to databaseobject definitions and data.To create a connection:1. Select New Database Connection.2. Complete the connection details:

    – Host name – Username and password – SID

    3. Test the connection.

    Creating ADF Business Components:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    65/398

    3-13 Copyright © 2004, Oracle. All rights reserved.

    Entity Objects• Entity objects encapsulate the business model:

    – Data – Rules – Persistence behavior

    • You can create one entity object for each of thetables that you want to represent in yourapplication.

    Creating ADF Business Components:b

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    66/398

    3-14 Copyright © 2004, Oracle. All rights reserved.

    Entity Objects

    1. Select Business Components from Tables in theNew Objects Gallery.

    2. Select a Database Connection.

    Creating ADF Business Components:E i Obj

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    67/398

    3-15 Copyright © 2004, Oracle. All rights reserved.

    Entity Objects

    Select the tables that you want to represent in yourapplication.

    Creating ADF Business Components: ViewObj

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    68/398

    3-16 Copyright © 2004, Oracle. All rights reserved.

    Objects

    • View objects expose data to client applications.• Create View objects that are specific to client

    requirements by: – Selecting a specific attribute list – Creating nonpersistent attributes

    – Supplying a where clause – Supplying an order-by clause

    – Joining multiple entity objects

    • Views may have Links that manage Master-Detailrelationships between View objects.

    Creating ADF Business Components: ViewObj t

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    69/398

    3-17 Copyright © 2004, Oracle. All rights reserved.

    Objects

    Customers Orders OrderItems Products

    PriorityOrder ItemList

    Customer NameOrder DateOrder Status

    Item QuantityItem PriceProduct Description

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    70/398

    Selecting the Attributes

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    71/398

    3-19 Copyright © 2004, Oracle. All rights reserved.

    • Select the attributes that you need from each ofthe entities.

    • JDeveloper creates the View object with the SQLSelect statement.

    Creating an Application Module

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    72/398

    3-20 Copyright © 2004, Oracle. All rights reserved.

    • The Application Module publishes View objects.• View objects must be part of the Application

    Module for client applications to have access.• Edit the Application Module and add the Views.• Rename the View instances—use names that

    make sense for your client application.

    Testing the Business Components

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    73/398

    3-21 Copyright © 2004, Oracle. All rights reserved.

    • Right-click the Application Module and selectTest.

    • Select the configuration and database connection.

    Summary

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    74/398

    3-22 Copyright © 2004, Oracle. All rights reserved.

    In this lesson, you should have learned how to:• Describe the two groups of Business Components• Define the role of Business Components• Describe the role of an Application Module• Describe the use of customized Views

    Practice 3-1: Overview

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    75/398

    3-23 Copyright © 2004, Oracle. All rights reserved.

    This practice covers the following topics:• Creating Business Components:

    – Entity objects – View objects – Application Module

    • Testing an Application Module• Creating a Business Components diagram

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    76/398

    Copyright © 2004, Oracle. All rights reserved.

    Building Business Logic

    Objectives

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    77/398

    4-2 Copyright © 2004, Oracle. All rights reserved.

    After completing this lesson, you should be able todo the following:• Decide where to place business logic• Describe entity objects’ role in business logic

    implementation

    • Create entity objects• Describe the different methods of implementing

    business logic in ADF Business Components

    • Add business logic to an ADF BusinessComponents application

    • Use the Business Components Modeler to create

    and manage Business Components

    Business Logic Validation

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    78/398

    4-3 Copyright © 2004, Oracle. All rights reserved.

    Middle tier

    Web Container

    Controller

    EIS tier

    ADF Business Services Tier

    Client tier

    ADFEntityObject

    ADF Applicat ion

    Module

    ADFView

    Object

    Database

    Validation

    Business Logic

    Validation

    Client

    Validation

    M o d e l

    Database

    Implementing Validation in the BusinessServices Tier

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    79/398

    4-4 Copyright © 2004, Oracle. All rights reserved.

    Services Tier

    Business logic tier:• Is used when creating or updating data• Assumes that existing data in the database is

    valid• Is defined at entity object level• Uses programmatic or declarative techniques

    – Declarative: Defined in wizards and editors – Programmatic: Coded in Java

    • Is specified in Java or XML or both

    Entity Object: Overview

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    80/398

    4-5 Copyright © 2004, Oracle. All rights reserved.

    Customers

    IdNameStatusEmail

    Entityobject

    Attributes

    Databasetable

    Status List(Gold Silver Platinum)

    Validationrule

    ID

    201

    NAME

    Steve

    STATUS

    Gold

    Email

    [email protected] 202 Mike Silver [email protected]

    CUSTOMERS

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    81/398

    Creating an Entity Object

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    82/398

    4-7 Copyright © 2004, Oracle. All rights reserved.

    • Select the BusinessComponents node inthe New Gallery, andthen select EntityObject.

    • Right-click thepackage name in thenavigator, and selectNew Entity Object.

    Entity Object Wizard

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    83/398

    4-8 Copyright © 2004, Oracle. All rights reserved.

    Select adatabaseobject.

    Move to thenext step.

    Entera name.

    Files Generated for the CustomersEntity Object

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    84/398

    4-9 Copyright © 2004, Oracle. All rights reserved.

    • Customers.xml : Metadata – The Entity Object Wizard obtains all its information

    from this file. – Is created by default (mandatory)

    • CustomersImpl.java : Entity object class

    – Extends the EntityImpl class – Is row level – Includes getter and setter methods for attributes

    – Is created by default (optional)

    Optional Files Generated for theCustomers Entity Object

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    85/398

    4-10 Copyright © 2004, Oracle. All rights reserved.

    • CustomersDefImpl.java : Entity definition class – Extends the EntityDefImpl class

    – Contains run-time metadata describing the entityobject

    – Describes all instances of the enti ty

    • CustomersCollImpl.java : Entity collectionclass – Extends the EntityCache class

    – Contains run-time querying the entity collection – Caches queried rows of the entity

    Using the Business Components Modelerfor Entity Objects

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    86/398

    4-11 Copyright © 2004, Oracle. All rights reserved.

    1. Create a diagram from the New Gallery.2. Drag objects to the diagram.

    – Entity objects – Database definitions

    Using the Business Components Modelerfor Entity Objects

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    87/398

    4-12 Copyright © 2004, Oracle. All rights reserved.

    • Create entity objects by using the ComponentPalette.

    • Use the Entity Object Editor for Entity Objectproperties.

    Assigning an Initial Valueto an Entity Attribute

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    88/398

    4-13 Copyright © 2004, Oracle. All rights reserved.

    • Add code to the create() method inEntityImpl.java .

    • create() runs automatically when the entity isinstantiated.

    Select the CreateMethod checkbox to generatea create()method.

    OptionalJava filesselection

    Mapping an Attribute to aDatabase Sequence

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    89/398

    4-14 Copyright © 2004, Oracle. All rights reserved.

    1. Create a databasetrigger.

    create or replace triggerinsert_ord_id

    BEFORE INSERT ON ordersFOR EACH ROW

    DECLAREnew_id number;

    BEGINSELECT orders_seq.NextVal

    INTO new_id from Dual;:new.order_id := new_id;

    END;

    2. Set the attribute typeto DBSequence .

    Practice 4-1: Overview

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    90/398

    4-15 Copyright © 2004, Oracle. All rights reserved.

    This practice covers the following topics:• Initializing an attribute to a default value• Assigning a database sequence to an attribute

    Adding Validation

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    91/398

    4-16 Copyright © 2004, Oracle. All rights reserved.

    Entity-levelvalidation

    Attribute-levelvalidation

    Declarative Validation Rules

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    92/398

    4-17 Copyright © 2004, Oracle. All rights reserved.

    • Use declarative validation rules to validate anentity attribute.

    • Use the Entity Object Wizard to add and edit rules.• The Entity Object Wizard provides different types

    of declarative rules:

    – Compare with a single value – Compare with a list of valid values—either hard

    coded or the results of a SQL query – Compare with the minimum value, maximum value,

    or a range of values – Validate using a custom method

    • Declarative validation is XML based.

    ListValidator : Example

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    93/398

    4-18 Copyright © 2004, Oracle. All rights reserved.

    Specify a list of values for Customers.Status .

    Customers.xml…

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    94/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    95/398

    Domains: Example

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    96/398

    4-21 Copyright © 2004, Oracle. All rights reserved.

    protected void validate(){

    try {// Make sure the user entered a valid URLjava.net.URL u = new java.net.URL(mData);

    }

    catch (java.net.MalformedURLException e){throw neworacle.jbo.domain.DomainValidationException("Invalid URL");

    }

    • URLDomain verifies that an attribute is a valid URL.• The validate() method is called by the domain’s

    constructor.URLDomain.java

    How to Create a Domain

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    97/398

    4-22 Copyright © 2004, Oracle. All rights reserved.

    1. Create the domain from the New Gallery.2. Add validation code to the validate() method

    automatically created in URLDomain.java .

    How to Use a Domain

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    98/398

    4-23 Copyright © 2004, Oracle. All rights reserved.

    Edit the entity object and change the type of anattribute to URLDomain .

    URLDomainappears in the

    list of types ..

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    99/398

    Practice 4-2: Overview

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    100/398

    4-25 Copyright © 2004, Oracle. All rights reserved.

    This practice covers the following topics:• Adding a list validator to an attribute• Creating a domain• Assigning an attribute to a domain

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    101/398

    Objectives

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    102/398

    Copyright © 2004, Oracle. All rights reserved.5-2

    After completing this lesson, you should be able todo the following:

    • Describe the role of view objects in the businesscomponents framework

    • Create view objects

    • Customize view objects by using the View ObjectWizard

    • Define relationships between view objects

    • Add calculated attributes to view objects• Explain the role of an application module• Create an application module

    View Object in the ADF Architecture

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    103/398

    Copyright © 2004, Oracle. All rights reserved.5-3

    EIS Tier Middle Tier

    Web Container

    Controller ADF Business Services Tier

    Client Tier

    M o d e l

    ADFViewObject

    ADFEntityObject

    ADF Applicat ionModule

    Database

    Entity object View object

    Overview

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    104/398

    Copyright © 2004, Oracle. All rights reserved.5-4

    y j

    Databasetable

    ID

    201202

    NAME

    Steve Mike

    STATUS

    Gold Silver

    WEBSITE

    http://www...http://www...

    j

    SELECT name, statusFROM customersORDER BY name

    CustomerStatusCustomers

    IDNameStatusWeb site

    Mike Silver Steve GoldSusan Platinum

    Name Status

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    105/398

    Interaction Between Views andEntities: Retrieving Data

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    106/398

    Copyright © 2004, Oracle. All rights reserved.5-6

    • The view object queries the database directly.• Data retrieved by the query is saved to the entity

    object’s cache.

    • Nonpersistent attributes are stored and retrievedfrom the view object's cache.

    getAttr() VO

    EO

    getCalcAttr() VO

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    107/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    108/398

    Creating a View ObjectUsing the View Object Wizard

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    109/398

    Copyright © 2004, Oracle. All rights reserved.5-9

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    110/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    111/398

    SELECT Cust ID Cust FIRSTNAMEPriorityOrder View Object

    Example of a View Object

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    112/398

    Copyright © 2004, Oracle. All rights reserved.5-12

    Customers

    IDFirstNameLastNameStatusEmail

    Orders

    IDOrderdateStatusCustidTrackingno

    SELECT Cust.ID, Cust.FIRSTNAME,Cust.LASTNAME, Cust.STATUSOrd.ID, Ord.ORDERDATE,

    Ord.STATUSFROM CUSTOMERS Cust, ORDERS Ord WHERE Cust.ID = Ord.CUSTOMER_ID AND Cust.status = 'Platinum'

    ORDER BY Ord.ORDERDATE

    Practice 5-1: Overview

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    113/398

    Copyright © 2004, Oracle. All rights reserved.5-13

    Select entityobjects

    Selectattributes

    Edit thequery

    This practice covers creating and editing a newview object.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    114/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    115/398

    Li k b d i i h di i

    Traversing Links

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    116/398

    Copyright © 2004, Oracle. All rights reserved.5-16

    public oracle.jbo.RowIterator getOrderItemsView()

    • Links may be traversed in either direction.• ViewRowImpl.java contains a method to get the

    associated row iterator.• Use the methods of RowIterator to move from

    row to row and get individual attribute values.

    For example, OrdersViewRowImpl contains themethod:

    • This method returns the detail items for an order.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    117/398

    Using the Business Components Modeler for View Objects (II)

    1 Create an empty view object from the Component

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    118/398

    Copyright © 2004, Oracle. All rights reserved.5-18

    1. Create an empty view object from the ComponentPalette.

    2. Drag entity objects to the view box.

    1

    2

    Application Module in the ADF Architecture

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    119/398

    Copyright © 2004, Oracle. All rights reserved.5-19

    Web Container

    Middle Tier

    Controller

    EIS Tier

    ADF Business Services Tier

    Client Tier

    M o d e l

    Database ADF

    Appl icat ionModule

    ADFView

    Object

    ADFEntityObject

    Application Modules

    • Represent the data model for clients

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    120/398

    Copyright © 2004, Oracle. All rights reserved.5-20

    • Represent the data model for clients• Track all changes that affect the database

    • Have one connection to the database• Provide remotely accessible methods• May be deployed to multiple platforms without

    code changes• May contain other application modules

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    121/398

    Using the Business Components Modeler for an Application Module (I)

    • Drag an application module from the Applications

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    122/398

    Copyright © 2004, Oracle. All rights reserved.5-22

    Navigator to the diagram.• Source view objects appear in the Application

    Module box.

    Using the Business Components Modeler for an Application Module (II)

    1. Create an empty application module from the

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    123/398

    Copyright © 2004, Oracle. All rights reserved.5-23

    p y ppComponent Palette.

    2. Drag view objects to the Application Module box.

    1

    2

    Summary

    In this lesson, you should have learned how to:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    124/398

    Copyright © 2004, Oracle. All rights reserved.5-24

    In this lesson, you should have learned how to:• Describe the role of view objects in the business

    components framework• Create view objects• Customize view objects using the View Object

    Wizard• Define relationships between view objects• Add calculated attributes to view objects

    • Explain the role of an application module• Create an application module

    Practice 5-2: Overview

    This practice covers the following topics:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    125/398

    Copyright © 2004, Oracle. All rights reserved.5-25

    p g p• Adding a calculated attribute to a view object

    • Modifying the source code to recalculate theattribute when the view row changes

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    126/398

    Copyright © 2004, Oracle. All rights reserved.

    Adding Custom Validation

    Objectives

    After completing this lesson, you should be able to do

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    127/398

    6-2 Copyright © 2004, Oracle. All rights reserved.

    p g ythe following:

    • Add custom methods to validate business data• Use the typesafe data access methods• Use entity associations in business logic

    • Traverse entity associations

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    128/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    129/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    130/398

    Creating a MethodValidator for an Attribute

    To create a custom validator, create a new method in

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    131/398

    6-6 Copyright © 2004, Oracle. All rights reserved.

    the EntityImpl.java file. Select the

    EntityImpl.java file in the Structure pane or selectGo to Entity Object Class from the context menu.

    Creating a MethodValidator for an Attribute

    To create the custom validation as ah h d

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    132/398

    6-7 Copyright © 2004, Oracle. All rights reserved.

    MethodValidator , the method must:

    • Be defined as public• Accept a single argument of the same type as the

    attribute

    • Return a Boolean value• Start with validate

    public boolean validateEmail(String value)

    {return (value.indexOf('@') != -1 );

    }

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    133/398

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    134/398

    Validating Entity Objects

    If entity MethodValidators are too limiting, create ac stom method in the E tit I l j file:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    135/398

    6-10 Copyright © 2004, Oracle. All rights reserved.

    public boolean checkOrderMode(){

    if ( ("ONLINE".equals(getOrderMode())) ||

    !(getCustomerEmail() == null))

    { //success

    }

    else {

    // Error - online order must have email address

    }}

    custom method in the EntityImpl.java file:

    Call EntityImpl Methods

    You can also override other methods inEntityImpl java For example:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    136/398

    6-11 Copyright © 2004, Oracle. All rights reserved.

    EntityImpl.java . For example:

    • doDML() —Log changes in another entity• beforeCommit() —Validate multiple instances of

    the same entity• remove() —Record a deletion in another entity

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    137/398

    Associations

    Associations define a relationship between entityobjects Associations:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    138/398

    6-13 Copyright © 2004, Oracle. All rights reserved.

    objects. Associations:

    • Facilitate access to data in related entity objects• May be based on database constraints• May be independent of database constraints

    • Consist of a source (master) and a destination(detail) entity

    Association Example

    • A customer can place one or many orders.A d i l d b j t t

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    139/398

    6-14 Copyright © 2004, Oracle. All rights reserved.

    Source Destination Association

    Customers Orders

    • An order is placed by just one customer.

    OrderPlacedBy

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    140/398

    Association Types

    • AssociationEntities are related but not completely dependent

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    141/398

    6-16 Copyright © 2004, Oracle. All rights reserved.

    – Entities are related but not completely dependent.

    – Either end of the association can exist without theother. – 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 theowning entity existing first .

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    142/398

    The “ one”side of the

    The “ many”side of the

    Creating Entity Associations

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    143/398

    6-18 Copyright © 2004, Oracle. All rights reserved.

    side of the

    association

    side of the

    association

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    144/398

    Traversing Associations:Destination to Source

    getLineItem()

    Order

    ItemOrderedOnAssoc

    LineItem

    getTrackingNo()

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    145/398

    6-20 Copyright © 2004, Oracle. All rights reserved.

    public String getTrackingNo() {return getOrd().getTrackingNo(); }

    • The destination entity’s EntityImpl.java filecontains methods to get and set the source entity.For example, LineItemImpl.java containsgetOrd() and setOrd() .

    • You can add a method to LineItemImpl.java toget the tracking number of the order containing

    this item:

    getLineItem() ItemOrderedOnAssoc getTrackingNo()

    Traversing Associations:Source to Destination

    getLineItem()

    Order

    ItemOrderedOnAssoc

    LineItem

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    146/398

    6-21 Copyright © 2004, Oracle. All rights reserved.

    • The source entity’s EntityImpl.java filecontains a method to get the destination entity.For example, OrdImpl.java contains the method:

    • Use the methods of RowIterator to step fromrow to row and get individual attribute values.

    public oracle.jbo.RowIterator getLineItem()

    getLineItem() ItemOrderedOnAssoc

    Summary

    In this lesson, you should have learned how to:• Add business rules to ADF Business Components

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    147/398

    6-22 Copyright © 2004, Oracle. All rights reserved.

    Add business rules to ADF Business Components

    • Validate entities, attributes, and domains• Test the validation rules

    Practice 6-1: Overview

    This practice covers the following topics:• Enforcing ListValidator rules

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    148/398

    6-23 Copyright © 2004, Oracle. All rights reserved.

    g

    • Creating domain validation code• Testing the validation rules

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    149/398

    Copyright © 2004, Oracle. All rights reserved.

    Providing for Efficient Queries

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    150/398

    Overview

    View object

    CustomerOrders

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    151/398

    7-3 Copyright © 2004, Oracle. All rights reserved.

    Customers

    IDNameStatus

    Email

    Orders

    IDCustomerIdOrderModeOrderTotal

    select c.name,o.order_total fromcustomers c,orders o where

    c.id=o.customer_id

    getFullName()

    Custom method

    Expert Mode View Objects

    Use expert mode queries to create custom viewobjects. Select expert mode in the Create View Object

    f

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    152/398

    7-4 Copyright © 2004, Oracle. All rights reserved.

    Wizard or in the Query category of the View ObjectEditor.

    • In normal mode, JDeveloper maintains mappingsbetween entity attributes and database columns.

    Mapping Attributes in Expert Mode

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    153/398

    7-5 Copyright © 2004, Oracle. All rights reserved.

    • Editing a query in expert mode may invalidatethese mappings.For example, edit the CustomersView query:

    • At run time, the value of the Status attribute doesnot match the value in the underlying table.

    • Performing an update with the view gives alocking error.

    SELECT ID, NAME, initcap(STATUS) AS StatusFROM CUSTOMERS

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    154/398

    SQL-Based View Objects

    • A SQL-based view object: – Is not based on any entity object

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    155/398

    7-7 Copyright © 2004, Oracle. All rights reserved.

    – Cannot be used for insert, update, or delete• Use SQL-based view objects for query-only

    views, which do not need the functionality ofentity objects.

    • SQL-based view objects provide betterperformance than entity-based view objects.

    SELECT... VO

    Creating a SQL-Based View Object

    • Create a view object without selecting an entityobject in the View Object Wizard.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    156/398

    7-8 Copyright © 2004, Oracle. All rights reserved.

    • Click the Query tab of the wizard, and enter yourquery in the field provided.

    Implementing Custom Methods

    To add custom methods to a view object, modify the ViewObjectRowImpl.java file:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    157/398

    7-9 Copyright © 2004, Oracle. All rights reserved.

    public String getCustFullName(){

    String custFullName = "";

    custFullName = getCustFirstName() +" " + getCustLastName();

    return custFullName;

    }

    Expose Methods to the Client Application

    Expose the view object client row methods:• getCustFirstName() , getCustLastName()

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    158/398

    7-10 Copyright © 2004, Oracle. All rights reserved.

    • getCustFullName()

    Creating a Test Client

    To create a test client:1. Instantiate the application module.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    159/398

    7-11 Copyright © 2004, Oracle. All rights reserved.

    2. Instantiate the view object.3. Find and manipulate data as required.4. Call custom methods as required.

    5. Close the application module.

    Instantiating an Application Module

    • Instantiate the application module by using theConfiguration class.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    160/398

    7-12 Copyright © 2004, Oracle. All rights reserved.

    • Use the fully qualified application name and theconfiguration name as arguments.

    // App module name

    String _am = "model.OEModule";// Configuration nameString _cf = "OEModuleLocal";

    // Create an instance of the AppModule

    ApplicationModule am =Configuration.createRootApplicationModule(_am,_cf);

    Instantiate a View Object and Output Data

    • Use findViewObject() to instantiate the viewobject.

    • Iterate through the Rowset

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    161/398

    7-13 Copyright © 2004, Oracle. All rights reserved.

    • Iterate through the Rowset .• Display the data by using getAttribute() .

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

    Calling Custom Methods

    1. Retrieve the View Object Row.2. Call the published methods on the view object.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    162/398

    7-14 Copyright © 2004, Oracle. All rights reserved.

    System.out.println("Customer First Name: " +row_Cust.getCustFirstName());

    System.out.println("Customer Last Name: " +row_Cust.getCustLastName());

    System.out.println("Customer Full Name: " +row_Cust.getCustFullName());

    Setting Parameters for the Where Clause

    The Where clause of a view object’s query can containeither variables or parameters.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    163/398

    7-15 Copyright © 2004, Oracle. All rights reserved.

    • Provides flexibility at run time• Can be JDBC stylecustomer_id = ?

    • Can be Oracle stylecustomer_id = :1

    At run time, you can assign values to the parameters.

    Setting Parameters for the Where Clause

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    164/398

    7-16 Copyright © 2004, Oracle. All rights reserved.

    Parameters

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    165/398

    Creating a View Object at Run time

    //am is an ApplicationModuleString entity = "orders.LineItem";

    • To create a new view object based on an entity:

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    166/398

    7-18 Copyright © 2004, Oracle. All rights reserved.

    String selectClause = "id, status, quantity";String fromClause = "line_item";String whereClause = "status = 'S'";

    ViewObject shippedItemsVo =

    am.createViewObjectFromQueryClauses(null, entity,selectClause, fromClause, whereClause, null);

    ViewObject queryItemsVo =am.createViewObjectFromQueryStmt("",

    "select id, status, quantity from line_item");

    • To create a new view object based on a query:

    • Check the command-line argument.• Create an oracle.jbo.Key object.

    Finding Data by a Row Key

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    167/398

    7-19 Copyright © 2004, Oracle. All rights reserved.

    • Call findByKey() , which returns an array of row objects.

    if (args.length==0) {system.out.println("Customer ID is required");System.exit(0);

    }

    Key custKey = new Key(new Object[] {args[0]});

    Row[] customers = vo.findByKey(custKey,1);

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    168/398

    Practice 7-1: Overview

    This practice covers the following topics:• Creating a programmatic view object

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    169/398

    7-21 Copyright © 2004, Oracle. All rights reserved.

    • Creating parameterized queries• Creating custom methods for a view object• Testing custom methods and providing query

    parameters by using a command-line Java client

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    170/398

    Copyright © 2004, Oracle. All rights reserved.

    Making the Model Secure

    Objectives

    After completing this lesson, you should be able to dothe following:• Define Java Authentication and Authorization

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    171/398

    8-2 Copyright © 2004, Oracle. All rights reserved.

    Services (JAAS)• Define security issues with respect to Web

    applications• Use ADF Model Security design-time features• Use the ADF Business Components Browser to

    test your security model

    Goals of J2EE Security Architecture

    • To decouple security logic from application logic• To maintain platform and vendor independence

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    172/398

    8-3 Copyright © 2004, Oracle. All rights reserved.

    • To ensure fine-grained access control toresources• To enable portable and secure Web applications

    Overview of J2EE Security Architecture

    Use JAAS APIs to:• Authenticate a client to access

    the system

    User

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    173/398

    8-4 Copyright © 2004, Oracle. All rights reserved.

    – Determine who the user is. – Can they prove it?

    • Authorize clients to accessresources – Determine the role of the

    authenticated user.

    – What actions can a userperform? Read/Write Application

    Authentication

    Authorization

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    174/398

    Java Authentication and AuthorizationServices

    • JAAS supports the following authorization,authentication, and user community (realm)features:

    i i l

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    175/398

    8-6 Copyright © 2004, Oracle. All rights reserved.

    – Principals – Subjects – Login module authentication

    – Roles – Realms – Policies and permissions

    • JDeveloper provides wizards and dialogs that helpmanage these objects.

    JDeveloper, JAAS, and Securing the ADFModel

    • JDeveloper provides application security by usingJAAS.

    • ADF Business Components use the JAAS securityd fi i i f i i h d l

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    176/398

    8-7 Copyright © 2004, Oracle. All rights reserved.

    definitions to enforce security in the model.• You can set access roles on entities and

    attributes.

    • The ADF Business Component Browser uses thisproperty to control model security duringdevelopment and testing.

    • JDeveloper deployment uses these access rolesto build deployment descriptors.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    177/398

    The jbo.security.enforce ApplicationProperty

    1. Select the Application Module ConfigurationEditor.

    2. Click the Properties tab.h

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    178/398

    8-9 Copyright © 2004, Oracle. All rights reserved.

    3. Set the jbo.security.enforce property.

    Setting Entity Permissions

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    179/398

    8-10 Copyright © 2004, Oracle. All rights reserved.

    Entity Privileges

    • The users role canupdate new rows.

    • The administratorsrole can update any

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    180/398

    8-11 Copyright © 2004, Oracle. All rights reserved.

    role can update anyrows.

    • The guests role can

    only read any row.

    Attribute Permissions

    • Attributes inherit entity permissions.• Permissions can be overridden at the attribute

    level.Th i i i i l f

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    181/398

    8-12 Copyright © 2004, Oracle. All rights reserved.

    • The most restrictive permissions apply—forexample: – If you set read-only at the entity level, you cannot

    set update at the attribute level. – Update at the entity level can have read-only at the

    attribute level.

    Using the Business Components Browser

    • Choose Test from the Application Module contextmenu.

    • Choose AppModuleLocal for the testingconfiguration

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    182/398

    8-13 Copyright © 2004, Oracle. All rights reserved.

    configuration.

    Testing Entity and Attribute Authorization

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    183/398

    8-14 Copyright © 2004, Oracle. All rights reserved.

    Summary

    In this lesson, you should have learned how to:• Set the login configurator for ADF BC applications

    • Enable JAAS authentication for ADF BCAdd d l

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    184/398

    8-15 Copyright © 2004, Oracle. All rights reserved.

    Enable JAAS authentication for ADF BC• Add users and roles• Add role-specific permissions to entities and

    attributes• Test an ADF BC application security scheme

    Practice 8-1: Overview

    This practice covers the following topics:• Setting up SSO authentication

    • Creating users and rolesAddi th i ti

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    185/398

    8-16 Copyright © 2004, Oracle. All rights reserved.

    Creating users and roles• Adding authorizations• Testing the authorizations

    Controlling an Application with Struts

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    186/398

    Copyright © 2004, Oracle. All rights reserved.

    Controlling an Application with Struts

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    187/398

    Middle Tier

    Web Container

    EIS Tier

    ADF Business Services Tier

    Client Tier

    The Controller

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    188/398

    9-3 Copyright © 2004, Oracle. All rights reserved.

    Controller ADF Business Services Tier

    ADFEntityObject

    ADF Applicat ion

    Module

    ADFView

    Object M o d e l

    Database

    ADF Implements MVC Using the StrutsController

    JSP ADF UIX

    Struts

    Swing/ ADF JClientJSFView

    Controller

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    189/398

    9-4 Copyright © 2004, Oracle. All rights reserved.

    Struts

    ADF Model

    Controller

    Model

    Web

    Services

    EJBSessionBeans

    JavaBeans/

    Other

    ADFBusiness

    Components

    Business

    Services

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    190/398

    Example: Page Flow Without a Controller

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    191/398

    9-6 Copyright © 2004, Oracle. All rights reserved.

    page2.jsp page1.jsp

    Example: Page Flow Without a Controller

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    192/398

    9-7 Copyright © 2004, Oracle. All rights reserved.

    page2.jsp page1.jsp

    page1a.jsp

    Example: Page Flow Without a Controller

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    193/398

    9-8 Copyright © 2004, Oracle. All rights reserved.

    page2.jsp page1.jsp

    page1a.jsp

    Example: Page Flow Without a Controller

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    194/398

    9-9 Copyright © 2004, Oracle. All rights reserved.

    page2.jsp page1.jsp

    page1a.jsp

    Example: Page Flow with a Controller

    Controller Next Previous

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    195/398

    9-10 Copyright © 2004, Oracle. All rights reserved.

    page2.jsp page1.jsp

    Example: Page Flow with a Controller

    Controller Next Previous

    N P i

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    196/398

    9-11 Copyright © 2004, Oracle. All rights reserved.

    page2.jsp page1.jsp

    page1a.jsp

    Next Previous

    What Is Struts?

    • Project from the Apache Software Foundationhttp://jakarta.apache.org/struts

    • Open source framework for MVC Web-basedapplications

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    197/398

    9-12 Copyright © 2004, Oracle. All rights reserved.

    – XML-driven controller servlet

    • De facto standard for JSP Model 2 development

    • Partially declarative, partially coded• Often used with other view layers

    – Tiles: A page layout mechanism using JSP

    templates – Velocity: Page scripting language

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    198/398

    Struts Components

    • Struts Controller Servlet: Handles requests andmarshals results

    • Struts configuration file: The roadmap for theservlet

    d d

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    199/398

    9-14 Copyright © 2004, Oracle. All rights reserved.

    • Actions: Processes a request and sends an actionforward

    • ActionForms: Passes information between theclient and the model

    • TagLibs: Set of Struts library tags usable in JSPs

    • Resource bundles: Text-based file used forinternationalization of messages

    Struts Components Flow

    StrutsController Servlet Action

    HTTP Request

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    200/398

    9-15 Copyright © 2004, Oracle. All rights reserved.

    Forward ReturnResponse

    Form

    Action

    execute()

    Model

    Page

    validate()

    Struts Components:The Controller Servlet

    • Controls the overall application process• Does not appear in the Applications Navigator

    pane of JDeveloper • Is referenced in the web .xml file

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    201/398

    9-16 Copyright © 2004, Oracle. All rights reserved.

    • Is designed to be extended• Is driven by XML

    Struts Components:The Configuration file

    • Is named struts-config.xml• Is used by the controller servlet• Provides the metadata that defines the

    application:A i i ( b i )

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    202/398

    9-17 Copyright © 2004, Oracle. All rights reserved.

    – Action mappings (abstractions) – Page flow

    – Data flow – Exception handling – Resources

    Struts Components: Actions

    • Actions process requests, via itsexecute() method, and return ActionForward objects that identify where control should be

    forwarded.• Actions are adapters between HTTP requests and

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    203/398

    9-18 Copyright © 2004, Oracle. All rights reserved.

    Actions are adapters between HTTP requests andthe corresponding business logic .

    • The possible tasks that can be specified for anaction are: – Forward to/represent a page – Encode page flow logic – Take data from the page and update the model

    Struts Components: ActionForms (Form Beans)

    • Represent HTML form data that the userenters

    • Shuttle data between the view and the action: – Fields in the page are populated from the

    ActionForm

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    204/398

    9-19 Copyright © 2004, Oracle. All rights reserved.

    ActionForm .

    – On submit, the ActionForm is repopulated from

    the page. – Populated ActionForm is passed to the handling

    action for processing.

    Struts Components:Tag Libraries

    • Tag libraries integrate the JSP and controllercomponents

    • – Directs the controller to thecorrect action on submit

    • – Displays any errors thrown by

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    205/398

    9-20 Copyright © 2004, Oracle. All rights reserved.

    Displays any errors thrown bythe model, including validation

    • – Outputs a string from theresource file (a field label, for example)

    • Much overlap with “ newer” tag libraries, for

    example JSTL

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    206/398

    Internationalizing Your Application

    To internationalize an application, performthese steps:• Create other bundle files.• Add the country code to the file name such as

    ApplicationResources fr.properties .

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    207/398

    9-22 Copyright © 2004, Oracle. All rights reserved.

    pp _ p p

    • Translate the message text:

    logon.title=Entrez votre nom d’utilisateur• The servlet then checks the browser locale

    variable at startup, and the corresponding file isloaded if found; otherwise the default file isloaded.

    Struts inOracle JDeveloper 10 g

    • JDeveloper supports Struts 1.1.• You can visualize the page flow from the modeler

    and: – Drill down to JSP/UIX Visual Editor for pages– Drill down to Code Editor for actions

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    208/398

    9-23 Copyright © 2004, Oracle. All rights reserved.

    Drill down to Code Editor for actions

    • You can edit in whatever way you choose:

    – Visually – Through the Structure pane and Property Inspector – In the XML

    Struts Configuration File

    • 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

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    209/398

    9-24 Copyright © 2004, Oracle. All rights reserved.

    free of XML syntax.

    Defining the struts-config.xmlFile Content

    The Structure pane and Property Inspector

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    210/398

    9-25 Copyright © 2004, Oracle. All rights reserved.

    p yp

    Defining the struts-config.xmlFile Content

    Using the Struts Configuration Editor

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    211/398

    9-26 Copyright © 2004, Oracle. All rights reserved.

    p yp

    Defining the struts-config.xmlFile Content

    The Struts Page Flow Diagram andComponent Palette

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    212/398

    9-27 Copyright © 2004, Oracle. All rights reserved.

    Creating a Page Flow Diagram

    • Using the Component Palette, dragcomponents to the diagram.

    • Components do not exist until you physicallycreate them (either as a Java class or a JSP).

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    213/398

    9-28 Copyright © 2004, Oracle. All rights reserved.

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    214/398

    Struts Components:Pages and Page Forwards

    • Pages symbolize the user’s view.• Creating a page forward

    (also called ActionForward ):

    – Creates an action entry in the struts-config.xmlfileCreates a logical name associated with the page

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    215/398

    9-30 Copyright © 2004, Oracle. All rights reserved.

    – Creates a logical name associated with the pagename

    • Creating a page – Makes a direct reference to the page name – Requires to be changed for every occurrence

    of the page when renaming it• Pages need to physically exist to be used as the

    target of a forward or link

    Struts Components:Forwards and Links

    • A link represents a flow between components• You can create a link (unnamed dotted line):

    – Between pages – Between a page and an action

    • You can create a forward (named line):

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    216/398

    9-31 Copyright © 2004, Oracle. All rights reserved.

    – Between actions

    – Between an action and a page – Default name of the first forward is Success.

    • More than one forward or link may exist at the

    source of a component.

    ADF provides two specialized action-subclassedcomponents:• DataPage

    – Create for databound pages – Used extensively in default ADF business

    ADF Components: DataAction andDataPage

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    217/398

    9-32 Copyright © 2004, Oracle. All rights reserved.

    component applications

    – Combination of a DataAction and astandard Struts Page Forward

    • DataAction – Create as a standalone action for executing

    custom methods of the business service – Handles standard actions from databound pages

    Summary

    In this lesson, you should have learned the followingabout Struts applications:• The Struts controller servlet intercepts each

    request.• The struts-config.xml file defines

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    218/398

    9-33 Copyright © 2004, Oracle. All rights reserved.

    components:

    – Actions (Processes a request) – Action Forwards (Pass HTML form data) – Page Forwards and/or Pages (Symbolize the user’s

    view of an action's result)

    – Resource Bundles (Componentization of Labels andText)

    – Navigation (Forwards and Page Links)

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    219/398

    Building ADF View Components

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    220/398

    Copyright © 2004, Oracle. All rights reserved.

    Objectives

    After completing this lesson, you should be able to dothe following:• Describe how a JSP works

    • Describe the fundamental components of a JSP• Create a JSP

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with ADF - Electronic Presentation.pdf

    221/398

    10-2 Copyright © 2004, Oracle. All rights reserved.

    • Include components into JSP (HTML, Struts, and

    JSTL tags)• Create a data-centric JSP using ADF data binding

    What Is a JSP?

    JavaServer Pages are aJ2EE component, which:• Is a “ View” in the ADF

    MVC structure• Contains presentation

    logic

  • 8/15/2019 Oracle JDeveloper 10g Build Applications with