55
<Insert Picture Here> Reusability in Oracle ADF development Dmitry Nefedkin Oracle ISV Migration Center FMW Consultant [email protected]

Reusability in the Oracle ADF Development

Embed Size (px)

DESCRIPTION

Reusability in the Oracle ADF Development

Citation preview

Page 1: Reusability in the Oracle ADF Development

<Insert Picture Here>

Reusability in Oracle ADF development

Dmitry Nefedkin

Oracle ISV Migration Center FMW Consultant

[email protected]

Page 2: Reusability in the Oracle ADF Development

2

ISV Migration Center Team

• Who we Are ISV Migration Center Team is a team of senior technical consultants based in

Eastern and Central Europe and represents Oracle's technical investment for partners.

• Mission Statement Enable partners to rapidly and successfully adopt and implement Oracle

latest technology

• What do we Offer Whether you are selling Oracle technology, building business solutions,

including hosted Internet solutions or providing system integration and implementation services

for Oracle technology, IMC Team can help you succeed.

• How can we assist We offer a wide range of free services for partners such as one2one

assistance, webinars, seminars and hands-on workshops.

ISV Migration Center blog: http://blogs.oracle.com/imc

Contacts:

Ruxandra Radulescu, ISV Migration Center Manager, EE&CIS

[email protected]

Page 3: Reusability in the Oracle ADF Development

<Insert Picture Here>

Agenda

• ADF Opportunities for Reusability

• Resource catalogs and ADF Libraries

• Business logic reusability: ADF BC extension classes

• UI reusability: page templates, declarative components, skins

• Controller reusability: ADF Task Flows and templates

• Bringing it all together

• Getting more information

Page 4: Reusability in the Oracle ADF Development

Benefits of Reusability

• Designing code to be reused has the following benefits:

• Increased developer productivity

• Fewer bugs – debug once

• Consistency

• In functionality

• In look and feel

• Easier maintainability

• Rapid adaptability

Page 5: Reusability in the Oracle ADF Development

Business Services

Data Services

Model

Controller

JSFJSF View

Desktop Browser-Based

StrutsStruts

OfficeOffice ADFADF SwingSwing

Oracle ADF - The Bigger Picture

JSPJSP

EJBEJB BAMBAM ADFbcADFbc PortletsPortlets BIBI BPELBPEL Web ServicesWeb Services JavaJava

ADF FacesADF Faces

Me

tad

ata

Se

rvic

es (

MD

S)

Me

tad

ata

Se

rvic

es (

MD

S) MobileMobile

Database Web Services Legacy Systems Apps Unlimited

JSFJSF ADF ControllerADF Controller

ADF ADF Model (Model (DataControlsDataControls & Bindings)& Bindings)

Page 6: Reusability in the Oracle ADF Development

ADF Has a lot of Opportunities for

Reusability, But First…

• Don’t forget the obvious thing

• Java is an Object Orientated language with inheritance

• Use it!

• If using ADF

• Refactor common code into Framework superclasses

• Create common utility classes

• Use advanced features like polymorphic entities

Page 7: Reusability in the Oracle ADF Development

<Insert Picture Here>

Agenda

• ADF Opportunities for Reusability

• Resource catalogs and ADF Libraries

• Business logic reusability: ADF BC extension classes

• UI reusability: page templates, declarative components, skins

• Controller reusability: ADF Task Flows and templates

• Bringing it all together

• Getting more information

Page 8: Reusability in the Oracle ADF Development

The Resource Catalog

• Enables application developers to find and incorporate

shared resources created by other members of the team

• Provides a federated view of the resources from one or more

otherwise unrelated repositories in a unified search and

browse UI

• Enables you to store libraries comprising a common

repository that can be used by the developers building any

client application

• Ensures that all application developers use the same

business model without any discrepancies

Page 9: Reusability in the Oracle ADF Development

Working with the Resource Catalog

Creating a catalog

Adding to a Catalog

Page 10: Reusability in the Oracle ADF Development

Reusing Components with Libraries

• ADF Library enables you to reuse components:

• Package them into ADF Library JAR files

• Add them to a reusable component repository

• Add the library to a project to use its

components

• Basically a standard JAR with a bit of

extra metadata

Page 11: Reusability in the Oracle ADF Development

Building ADF Libraries

• ADF supports reusing the following types of components in

ADF Libraries

• Data controls

• Application modules

• Business components

• Task flows

• Task flow templates

• Page templates

• Declarative components

Page 12: Reusability in the Oracle ADF Development

Building ADF Libraries

• Guidelines:

• Use naming conventions

• Avoid naming conflicts

• Facilitate identifying component functionality

• Standardize storage by agreeing on:

• Type of repository needed

• Storage and organization

• Access methods

Page 13: Reusability in the Oracle ADF Development

Creating an ADF Library

1

2

3

4

Page 14: Reusability in the Oracle ADF Development

Adding an ADF Library to a Project

1 2

3

4

Page 15: Reusability in the Oracle ADF Development

Removing an ADF Library from a Project

• Remove by:

• Using Resource

Palette

• Using Project Properties

Page 16: Reusability in the Oracle ADF Development

Restricting BC Visibility in Libraries

• Set Library Private property

for a business component to

true if you don’t want consumers

to see the object in the library JAR.

Page 17: Reusability in the Oracle ADF Development

<Insert Picture Here>

Agenda

• ADF Opportunities for Reusability

• Resource catalogs and ADF Libraries

• Business logic reusability: ADF BC extension classes

• UI reusability: page templates, declarative components, skins

• Controller reusability: ADF Task Flows and templates

• Bringing it all together

• Getting more information

Page 18: Reusability in the Oracle ADF Development

Create ADF BC extension classes

Create subclasses for ADF BC framework base classes

Page 19: Reusability in the Oracle ADF Development

Register your extension classes

• Tools->Preferences ->

ADF Business

Components -> Base

Classes

• These settings will be

inherited by the new

Model projects.

• Can be overridden on

the project level

19 Oracle Restricted and Confidential

Page 20: Reusability in the Oracle ADF Development

Basing an ADF Component on an Extension

Class

20 Oracle Restricted and Confidential

Page 21: Reusability in the Oracle ADF Development

<Insert Picture Here>

Agenda

• ADF Opportunities for Reusability

• Resource catalogs and ADF Libraries

• Business logic reusability: ADF BC extension classes

• UI reusability: page templates, declarative components, skins

• Controller reusability: ADF Task Flows and templates

• Bringing it all together

• Getting more information

Page 22: Reusability in the Oracle ADF Development

Page Templates

• Provides layout and behavior

• Layout

• Uses default ADF Faces layout managers

• Can have custom facets for content stamping

• Template is referenced, not compiled: easy to change at design time

and run time

• Behavior

• Can have bindings

• Can have attributes

Page 23: Reusability in the Oracle ADF Development

Creating a Page Template

Page 24: Reusability in the Oracle ADF Development

Creating a Page Template

Header (with Title)

A

B

Menu Regions

News Portlet

Named Facets

Page 25: Reusability in the Oracle ADF Development

Editing a Page Template

Header (with Title)

A

B

Header (with Title)

A

B

Footer

Modified Template Original Template

Must continue to use the

same named facets

Page 26: Reusability in the Oracle ADF Development

Applying a Page Template to a Page

Page 27: Reusability in the Oracle ADF Development

UI Shell – page template used by Fusion

Apps

UI Shell goals:

• Accelerate the ADF learning curve for teams new to ADF

• Provide a best practice layout based on a given UI design

• Provide high-level, best practice behavior out-of-the-box

• Make it easier to follow an Oracle UI design

Page 28: Reusability in the Oracle ADF Development

Anatomy of ADF UI Shell Best practice use of stretching & flowing layout

Page 30: Reusability in the Oracle ADF Development

Declarative Components

• Characteristics of Declarative Components:

• Are component definitions that are reusable across applications

• When changed, affect all pages that use them

• Are made up of any number of other components

• Do not have data binding in their definition

• Can be made available for reuse in the Component Palette

• Are defined only at design time in:

• One .jspx file for each component

• One declarativecomp-metadata.xml file for all components in a

project

Page 31: Reusability in the Oracle ADF Development

Creating a Declarative Component

• The JSF Declarative

Component dialog box:

• Is invoked with

New > Web Tier > JSF

> JSF Declarative Component

• Creates <af:componentDef>

tag in .jspx file

• Creates metadata

Page 32: Reusability in the Oracle ADF Development

Using a Declarative Component

on a Page

• To use a declarative component on a page:

• Deploy the component’s project as an ADF library JAR file.

• Add the ADF library to your current project.

• Select the ADF library from the Component Palette drop-down list.

• Select the declarative component and drag it to your page, providing

values for any attributes.

Page 33: Reusability in the Oracle ADF Development

Declarative Components – Use Cases

• Create layout fragments

• Use in addition to page templates for consistent look and feel

• Oracle Forms-like toolbar

• Wrap components to add functionality

• For example, provide table shell that applies keyboard functionality

• Create panel that allows you to export table content to Excel in binary

format

• Create complex components that operate on iterator or

bindings that are passed in as arguments

Page 34: Reusability in the Oracle ADF Development

ADF Skinning

• This allows you to customize the look and feel of an application

• Without affecting functionality

• Without editing individual pages

• A skin is a style sheet based on the CSS 3.0 syntax that is specified in one place for an entire application

• ADF delivers default skins for ADF Faces components

• The minimal look and feel is the ―simple‖ skin. It has very little styling

• The ―fusion‖ skin extends simple and provides a very rich styling of our components. This is the default

• Developers can change the styles, icons, properties, and text of ADF Faces components by creating a new skin

Page 35: Reusability in the Oracle ADF Development

Skinning Examples

• Icons

• Change messages, text, tooltips etc. af_messages.TIP_FATAL "What were you thinking"

af_messages.TIP_ERROR "You bozo, that is so wrong"

af_messages.TIP_CONFIRMATION "I got it!"

af_messages.TIP_INFO― "FYI Dude"

• Splash Screen

• Colors, styles

• Tabs

Page 36: Reusability in the Oracle ADF Development

Creating a skin

• When creating a skin, one extends a delivered skin

• You can create multiple skins to serve different purposes

• Skins can be dynamically applied at runtime

• A skin consists of the following artifacts: • An ADF Skin file (.css) that defines the actual look of the components

• A configuration file - ―trinidad-skins.xml‖ - that lists all skins available for the

application

• An entry in the ADF Faces configuration file - ―trinidad-config.xml‖

• Any other resources needed to create the actual look of the components -

additional CSS files, Images

Page 37: Reusability in the Oracle ADF Development

Creating a skin

Page 38: Reusability in the Oracle ADF Development

Skin development in JDeveloper 11g R1

• Code editing support

• ADF Faces Skin Extension • Tool > Preferences >CSS Editor

• Check ADF Faces Extension

• Syntax Help

• Image selection

• Code Completion

• E.g. type "af|inputr" then press ctrl+Enter

• Code Folding

• Collapses CSS style definitions

• Mouse-over code info

Syntax Help

Page 39: Reusability in the Oracle ADF Development

Skin development in JDeveloper 11g R2

Page 40: Reusability in the Oracle ADF Development

Configuring what skin to use in runtime

• Using static name

• Using Expression

<trinidad-config

xmlns="http://myfaces.apache.org/trinidad/config">

<skin-family>MYSKIN</skin-family>

</trinidad-config>

<trinidad-config

xmlns="http://myfaces.apache.org/trinidad/config">

<skin-family>

#{facesContext.viewRoot.locale.language =='de' ?'MYSKIN_DE' :

'MYSKIN'}

</skin-family>

</trinidad-config>

trinidad-config.xml

Page 41: Reusability in the Oracle ADF Development

<Insert Picture Here>

Agenda

• ADF Opportunities for Reusability

• Resource catalogs and ADF Libraries

• Business logic reusability: ADF BC extension classes

• UI reusability: page templates, declarative components, skins

• Controller reusability: ADF Task Flows and templates

• Bringing it all together

• Getting more information

Page 42: Reusability in the Oracle ADF Development

Characteristics of Bounded Task Flows

• Bounded task flows:

• Are modular blocks of task flow functionality for reuse, with the

following characteristics:

• Single point of entry

• Well-defined boundary

• pageFlow Memory scope

• Declarative transaction

management

• Declarative Back button support

Page 43: Reusability in the Oracle ADF Development

Characteristics of Bounded Task Flows

• Bounded task flows consist of :

• Activities (View, Router, Method Call, etc..)

• Control flows between activities

• Ability to accept input parameters and to return values

• On-demand metadata loading

• Fragment reuse through task flow templates

• Addressable

Page 44: Reusability in the Oracle ADF Development

Modular "UI Services"

Page 45: Reusability in the Oracle ADF Development

Use It in Another Flow

Page 46: Reusability in the Oracle ADF Development

Using a Bounded Task Flow

• Using a bounded task flow

in a region on a page

Page 47: Reusability in the Oracle ADF Development

Task Flow Templates • Reusable task flow definition

• Reuse by reference or as a copy

• Can contain common functionality and settings

• Exception handlers

• Task flow activity navigation outline

• Use of initializers and finalizers

• Visibility settings

• URL accessible

• Visible in ADF Library

• Behavior settings

• Train

• Task flow reentry

• Critical

• Data Control sharing

• Pre-defined input and output parameters

Page 48: Reusability in the Oracle ADF Development

Deciding Which to Use

• You can use a page template when you want:

• Similar page layout to be used on multiple pages

• Similar look on multiple pages

• You can use a declarative component when you want to:

• Use a similar grouping of components on multiple pages or

applications

• Select the component from the Component Palette

• You can use a bounded task flow when you want to:

• Reuse a set of activities and control flows

• Use multiple page fragments in a region on a page

Page 49: Reusability in the Oracle ADF Development

<Insert Picture Here>

Agenda

• ADF Opportunities for Reusability

• Resource catalogs and ADF Libraries

• Business logic reusability: ADF BC extension classes

• UI reusability: page templates, declarative components, skins

• Controller reusability: ADF Task Flows and templates

• Bringing it all together

• Getting more information

Page 50: Reusability in the Oracle ADF Development

Bringing it all together

Common Code Workspace

• ADF BC extension classes

• Utility classes

Common Model Workspace

• Entity Objects and Associations

•Shared View objects for LOVs

•Default VOs and AM for testing

Common UI Workspace

•Page Templates

•Declarative Components

•Task Flow templates

•Skins

Sybsystem Workspaces

• View objects and view links

•Application Module(s)

•Bounded Task Flows with fragments

Master Workspace

•Page(s) with the regions/dynamic regions,

maybe based on UIShell template • This sample shows how you can structure the artifacts of your ADF application between JDeveloper workspaces

•Arrows show ADF library dependencies

•Master workspace produce EAR file as the build output

Page 51: Reusability in the Oracle ADF Development

<Insert Picture Here>

Agenda

• ADF Opportunities for Reusability

• Resource catalogs and ADF Libraries

• Business logic reusability: ADF BC extension classes

• UI reusability: page templates, declarative components, skins

• Controller reusability: ADF Task Flows and templates

• Bringing it all together

• Getting more information

Page 52: Reusability in the Oracle ADF Development

Getting more information

• Oracle ADF Insider - recorded sessions that will help you get up to speed with Oracle ADF: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adfinsider-093342.html

• Oracle ADF Code corner - hints, tips and coding examples for ADF developer: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html

• Useful links for the ADF Developer: http://blogs.oracle.com/imc/entry/useful_links_for_the_adf

Page 53: Reusability in the Oracle ADF Development

Getting more information

• Quick Start Guide to Oracle Fusion Development

• Oracle JDeveloper 11g Handbook

• Oracle Fusion Developer Guide

Page 54: Reusability in the Oracle ADF Development

Getting more information

Sten E. Vesterli

Oracle ADF Enterprise Application Development — Made Simple

Page 55: Reusability in the Oracle ADF Development

QuestionsQuestions

©2011 Oracle Corporation

Dmitry Nefedkin

Oracle ISV Migration Center FMW Consultant

[email protected]

ISV Migration Center blog: http://blogs.oracle.com/imc