adf gold nuggets (oracle open world 2011)

71
GOLD NUGGETS IN ORACLE ADF (FACES) Lucas Jellema – AMIS (Nieuwegein, The Netherlands) ADF EMG Community Day - Oracle Open World 2011

Upload: lucas-jellema

Post on 19-May-2015

4.717 views

Category:

Technology


2 download

DESCRIPTION

Gold Nuggets in ADF Faces ADF Faces is a superior User Interface technology. Just look at Fusion Applications to confirm that statement. Or look at one of the hundreds of ADF applications deployed around the world. ACE Directors Chris Muir and Lucas Jellema draw from the experiences on many of these application to demonstrate a number of the most useful, productive, surprising, even amusing and sometimes quite obscure features in ADF Faces. To offer more insight in the richness of the ADF framework in general and also provide very concrete examples that will immediately help you add advanced functionality or benefit from increased productivity. Topics include task flows, push, desktop integration, event handling, reuse, change persistence, UI Shell and more. value: - learn about tricks and useful features in ADF Faces that will enable attendees to enhance their ADF applications (in term of visual richness and functionality) and to increase their productivity and improve their development process - get inspired about ADF (Faces)

TRANSCRIPT

Page 1: ADF Gold Nuggets (Oracle Open World 2011)

GOLD NUGGETS IN ORACLE ADF (FACES)

Lucas Jellema – AMIS (Nieuwegein, The Netherlands)

ADF EMG Community Day - Oracle Open World 2011

Page 2: ADF Gold Nuggets (Oracle Open World 2011)
Page 3: ADF Gold Nuggets (Oracle Open World 2011)

OVERVIEW

• IDE favorites• Fool’s Gold• UI (tw)Highlights• The Whole Wide World

Page 4: ADF Gold Nuggets (Oracle Open World 2011)

WHAT IS A GOLD NUGGET?

• Unexpected benefit• Underused, overlooked feature

– Small – frequently useful– Huge – unexplored concept or area of

infrastructure• Potentially useful to large community

– Not too much a niche option

Page 5: ADF Gold Nuggets (Oracle Open World 2011)

NUGGET CLOUD

Refresh after insert

Gro

ovy

so aDF

JHeadstartPPR

DVT

Decoupled D

evelopment &

ReuseTaskFlow

, Region, UIShell, D

eclarative Components, AD

F Library, …

active rowkey prepareSession

Java/JEE

Fusion Applications

EMG and wider community

OraFormsFaces

Popup

Change Persistence

Auto

Sug

gest P

anelCollection

ADFContext

OPSS/ADF Security

Tree S

ele

ct

VO Updateable Lookup

Multi Browser Supportserver event & listener

List

valid

ato

r

FormatString

Sele

nium

Hot Reload

Cust

omiza

tion

PanelDashboard

Programmatic VO

Bean Data Control

setPropertyListener

Activ

e D

ata

Serv

ice fo

r Push

Rich

Tab

le

Web

Logi

c Se

rver

EL

Save Points

Page Template

Skin editor

Page 6: ADF Gold Nuggets (Oracle Open World 2011)

ADF IN LARRY’S KEYNOTE ON ORACLE OPEN WORLD 2009 AND 2010

Page 7: ADF Gold Nuggets (Oracle Open World 2011)

FUSION APPLICATIONS – BIGGEST PROOF POINT IN THE WORLD

Page 8: ADF Gold Nuggets (Oracle Open World 2011)

ADF POWERS THE USER INTERFACE OF ALMOST ANY ORACLE PRODUCT

Page 9: ADF Gold Nuggets (Oracle Open World 2011)

ADF POWERS THE USER INTERFACE OF ALMOST ANY ORACLE PRODUCT (2)

Page 10: ADF Gold Nuggets (Oracle Open World 2011)

THE TABLE

• ADF Faces Rich Table (& Panel Collection)– Displays ADF Model data bound collection, bean

array, List, ResultSet, RowSet and more – Dynamic Table Configuration & Change Persistence

• Rearrange, resize, hide/show columns, freeze columns

– Post-load or Lazy Data Fetch– Fetch data rows upon scroll– Filter & Sort– Read-Only and Click-to-edit– [single or multiple] Row and Column Selection– Header, Footer, Column Grouping, DetailStamp– Many, many predefined facets– Export data set, Email & Print mode

Page 11: ADF Gold Nuggets (Oracle Open World 2011)

ACTIVE ROW KEY

• Property on table that is ‘click to edit’• EL expression that resolves to the primary

key of the row that should be displayed as editable– Table will scroll that row into view

Page 12: ADF Gold Nuggets (Oracle Open World 2011)

"SMART" COMPLETION INSIGHT

Ctrl-Space (x 2)

Page 13: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

}

Page 14: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

}

}

Page 15: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

this.

}

} Ctrl Space

Page 16: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

this.

}

}

Page 17: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

this.getB

}

}

Page 18: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

this.getBookingView1Impl()

}

}

Page 19: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

? = this.getBookingView1Impl()

}

} Ctrl Space

x 1

Page 20: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

this.getB

}

} Ctrl Space

x 1

Ctrl Space

x 2

Page 21: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

this.getB

}

}

Page 22: ADF Gold Nuggets (Oracle Open World 2011)

public class AppModuleImpl extends ApplicationModuleImpl {

public BookingsViewImpl getBookingsView1() { return (BookingsViewImpl)findViewObjects("BookingsView1"); }

public void doSomething() {

BookingsViewImpl bookingsView = this.getBookingsView1();

}

}

Page 23: ADF Gold Nuggets (Oracle Open World 2011)

JDEVELOPER GO TO SHORTCUTS

• Go to Class: CTRL -

• Go to File: CTRL ALT -

• Find usages: CTRL ALT u – For class, method,

EO and VO Attribute, …

Page 24: ADF Gold Nuggets (Oracle Open World 2011)

MORE BEST SHORT CUTS…

• CTRL Shift Space: parameter insight• CTRL = : list of recently opened files• CTRL Space: completion insight• CTRL Space (2x): declaration insert• CTRL /: selection commented• CTRL Shift C:

copy file path toClipboard

• Alt Home : selectfile in ‘tree’

Page 25: ADF Gold Nuggets (Oracle Open World 2011)

DATA VISUALIZATION

Page 26: ADF Gold Nuggets (Oracle Open World 2011)

THE RIGHT MOUSE CLICK

• ContextMenu client listener and Popup (menu and window)

Page 27: ADF Gold Nuggets (Oracle Open World 2011)

POPUP MAGIC

Page 28: ADF Gold Nuggets (Oracle Open World 2011)

EXAMPLE: ADDING FANCY BALLOON HELP• Create a popup with a noteWindow child

to contain the fancy help content

• Add a showPopupBehavior tag to the inputText that we want to add the help to

Page 29: ADF Gold Nuggets (Oracle Open World 2011)

FUSION APPS – ‘UI DESIGN PATTERN’

Page 30: ADF Gold Nuggets (Oracle Open World 2011)

EXPRESSION LANGUAGE

• IoC: Injection of Value and Listener into page

• Dynamic, context sensitive behavior• Extension points

– Custom Functions invoked from EL– Integration of Spring Beans– Custom EL Resolver

• To resolve values from property files, ….

#{user.settings['NAME']}

Page 31: ADF Gold Nuggets (Oracle Open World 2011)

EXTEND EL TO SUPPORT CUSTOM FUNCTIONS WITH MULTIPLE PARAMETERS

• Create the static methods that implement the custom EL functions

• Configure <function> elements in a custom tag library descriptor

• Associate the tag library to the JSF page• Use the function in expressions such as:

Page 32: ADF Gold Nuggets (Oracle Open World 2011)

NO CODING QUICK START ADF - LEVERAGING BEST PRACTICES & UNIFORM UI PATTERNS

Page 33: ADF Gold Nuggets (Oracle Open World 2011)

EVEN MORE DECLARATIVE ADF DEVELOPMENT – WITH JHEADSTART

Page 34: ADF Gold Nuggets (Oracle Open World 2011)

PROGRAMMATIC CROSS TIER INTERACTION

Web Browser

JEE Application Server

Page 35: ADF Gold Nuggets (Oracle Open World 2011)

Client

Server (middle tier)

Database

JavaScript Components

ComponentsBeans & Objects

activeOutputText

Active DataModel

activeOutputText

push

serverListener

Bean

Load JSON, CSS, Image, XML, JSRequest

data orPush message

push (DB QRCN)

Object

clientListener

componentuser action

serverListener

partial page

refresh

partialSubmit autoSubmit

JavaScript Function

Queue Custom Event

componentcomponent

manipulate

pollsetPropertyListener

userorprogrammaticaction

add JS toexecute (ERKS) add

componentsas partial target

ERKS ‘ppr script’

partial triggers, added targets

actionListener, valueChangeListener,

…Listener

componentcomponent

prop

erty

chan

ge

Full pagereload

CLIENT SERVER INTERACTIONS VV.

Page 36: ADF Gold Nuggets (Oracle Open World 2011)

USE SETPROPERTYLISTENER TO PUSH DATA TO THE SERVER

• The setPropertyListener will pass from value to the to target when type event occurs on parent

– A very simple way to inform the server about an event and the data associated with the event

– Supported types: action, focus, poll, query, rangeChange, selection, sort, rowDisclosure, valueChange and many more

<af:image id="removeFromSetImage“ source="/images/removeFromSet.png“ shortDesc="Remove from Shopping Basket"/> <af:setPropertyListener from="#{item}“ to="#{shoppingBasket.itemToRemove}" type="action"/></af:commandLink>

Page 37: ADF Gold Nuggets (Oracle Open World 2011)

SERVERLISTENER FOR CUSTOM AJAX (BACKGROUND CLIENT TO SERVER PUSH)

• A serverListener associates a server side method with a client side custom event– This allows JavaScript functions

to call a server side method by queuing an event

– A custom event carries a payload

Page 38: ADF Gold Nuggets (Oracle Open World 2011)

ADF ACTIVE DATA SERVICE – SERVER PUSH TO CLIENT• Push: server sends messages to client• ADF Active Data Service enables UI

components to be ‘automatically refreshed’ when server side events occur

• Active UI Components include Table, Image, OutputText, DVT Components– Based on BAM Data Control– Based on Custom Beans

that extend ActiveAdapter• Nudge: push-to-refresh• Note: client-2-client push

can easily be implementedas client-to-server-followed-by-server-to-client push

Web Browser

JEE Application Server

Page 39: ADF Gold Nuggets (Oracle Open World 2011)

AUTO-PPR FOR IMMEDIATE REFRESH OF DATA BOUND COMPONENTS

• To have ADF automatically refresh data bound components when underlying value binding has changed its value

• Set changeEventPolicy=ppr on iterator– Refresh as piggy back on any request cycle– No partialTriggers attribute required!

Page 40: ADF Gold Nuggets (Oracle Open World 2011)

CROSS TIER PUSH

Web Browser

RDBMS

JEE Application Server

trg

job

servlet

activeOT

evt lsnrCache

refresher

table

Page 41: ADF Gold Nuggets (Oracle Open World 2011)

PUSH TO THE LIMIT – RICH AND PRO-ACTIVE USER INTERFACES WITH ADF

Session Plug – Session Plug – Session Plug – Session Pl

Wednesday, 5-6 PM, Mariott Marquis, Golden Gate A Oracle Open World 2011

Page 42: ADF Gold Nuggets (Oracle Open World 2011)

THE “HISTORY” FEATURE IN JDEVELOPER• Quick comparison of file with previous states

– Can leverage Source Code Control system (Subversion, CVS) but also maintains local file history

– The compare feature is ‘XML aware’• Revert to a previous state of a file

Page 43: ADF Gold Nuggets (Oracle Open World 2011)

MARRYING FORMS AND ADF TOGETHER – MIGRATE WITH (i/o FROM) FORMS TO ADF

• OraFormsFaces leveraging the JavaScript-Applet bridge for two-way event exchange

Page 44: ADF Gold Nuggets (Oracle Open World 2011)

ADF BC PROPERTIES

Property Inspector

Page 45: ADF Gold Nuggets (Oracle Open World 2011)

LIBRARY PRIVATE

Page 46: ADF Gold Nuggets (Oracle Open World 2011)

THE WORLD WIDE ADVANCED DEVELOPERS FAMILY

Page 47: ADF Gold Nuggets (Oracle Open World 2011)

THE WORLD WIDE ADVANCED DEVELOPERS FAMILY• ADF Enterprise Methodology Group• OTN Discussion Forum• OTN and ADF Resources

– Documentation, samples, tutorials, testimonials, virtual developer days, rea.oracle.com

• Blog-o-sphere• Conferences around the globe

– OOW, ODTUG Kaleidoscope, UKOUG, OBUG, AUSOUG/OAUG/ODTUG 20:20, DOAG, …

• Books and articles– Oracle Press, Packt Publishing, … – Oracle Magazine, ODTUG Technical Journal, …

• Also: Leverage Java/JEE community and resources

Page 48: ADF Gold Nuggets (Oracle Open World 2011)

JAVA AND JEE

• ADF is a framework on top of Java, JEE and JVM• Anything that is/extends/runs on one of these is

potentially usable with and relevant for ADF• Zillion frameworks and libraries

– iText (PDF), Apache POI (Excel), Jasper Reports, BIRT

– Spring (IoC, AOP, Acegi/Security, Social, ..)– Apache Commons, Google Collections, Joda Time

• Software Engineering– Test (Junit, EasyMock), build (Ant, Maven),

check/QA (FindBugs, CheckStyle, Sonar), • JEE facilities in WLS including JMS, WS* & RS,

JMX… • Dynamic JVM languages: Groovy, Scala, JRuby, …• Java 7 SE and beyond• Java FX?

Page 49: ADF Gold Nuggets (Oracle Open World 2011)

PREPARE SESSION

• Before any other database communication is performed during the processing of a request …

• ADF BC will execute the prepareSession() method that you can override in ApplicationModuleImpl

• This is the perfect place to– Reset package state– Set application and client info– Set application context

• User details, current session context, view filter conditions(real or poor man VPD)

– Fetch any events published inside the database Database

ADF BCAppMod

Page 50: ADF Gold Nuggets (Oracle Open World 2011)

CHALLENGE

• Create a Sliding Tile puzzle that tiles up an image in a configurable number of tiles

• Using drag and drop, the user can reassemble the image

Page 51: ADF Gold Nuggets (Oracle Open World 2011)

THE PANELDASHBOARD COMPONENT• Renders a ‘portal-like’ dashboard – as a grid

of PanelBox-components• Configurable

– number of columns– row height– Collapsible (boxes)

• Supports drag & drop for reorganization– And change persistence to remember (per user)

• Very easy to use

Page 52: ADF Gold Nuggets (Oracle Open World 2011)

STEPS

• Create Servlet that produces tiles from a JPEG image– Parameters: image name, tile factor, x and y

• Create PanelDashboard with panelBoxes with richImage components– That request their source from the servlet

corresponding to their position in the grid

• Bind the PanelDashboard and dynamically create the panelBox components

• Allow user to set the tile factor and choose the image– Use a Carousel for image selection

Page 53: ADF Gold Nuggets (Oracle Open World 2011)

DEMO

Page 54: ADF Gold Nuggets (Oracle Open World 2011)

EDN

Task UI

SDO Entity

EDN Events

SO ADF

•EDN Events from ADF BC•BAM Data Control•Human Task UI•ADF BC SDO Service•WebService Proxy and Data Control

Page 55: ADF Gold Nuggets (Oracle Open World 2011)

ADF TO SOA INTERACTIONS IN FAPPS Business LogicView Data

OrchestrationHuman interaction Policy evaluationMonitoring

RulesEngineAssign

Task

TaskComplete

Human WorkflowService

Mediator /BPEL Process

results

factsBusinessActivityMonitoring

Business ServicesADF Business Components

DataBinding

SDO Services

DatabaseSchema

Events

User InterfaceADF Faces components

Web

Cent

er

Page 56: ADF Gold Nuggets (Oracle Open World 2011)

PROGRAMMATIC VIEW OBJECT

• It walks, talks and looks like a ‘regular’ View Object– (regular being based on Entity Objects or SQL

Query)• But it is entirely fueled by custom written

overridden Java methods – possibly without database connection– A bit like a View with Instead Of trigger – against

a Collection based Table Function and PL/SQL API

• Programmatic View Objects can be used as normal in a Data Control for binding ADF Faces components

• Normal rich declarative ADF BC data binding can be provided to UI developers for data sources such as– WebService, JMS Queue, Memory Grid,

Document Management System, Email, cross session data, …

• Note: with the evolution of the Bean Data Control, some of the use cases will fade away

Page 57: ADF Gold Nuggets (Oracle Open World 2011)

THE ROOT OF AJAXSuggestions

Page 58: ADF Gold Nuggets (Oracle Open World 2011)

AUTO SUGGESTIONS

• User is entering a field– As she types characters,

suggestions can be presented for what the full entry should read• Based on a list of allowable values, based on

previous (popular) entries or anything really– User can pick a suggestion for ‘short-cut typing’

• Auto suggestions can be model-driven (declarative) or custom– And can do things beyond plain list based

suggestions

Page 59: ADF Gold Nuggets (Oracle Open World 2011)

INTRO

• Google Suggest set off the AJAX hype in anger

• Many implementations for a ‘suggestions’ feature in ADF 10g and 11g have been created– Using custom JavaScript or libraries like

Jquery• With PS1, ADF 11g introduced a native

component for ‘auto suggestions’– The <af:autoSuggestBehavior> component,

to be included in inputText or inputListOfValues orinputComboboxListOfValues

Page 60: ADF Gold Nuggets (Oracle Open World 2011)

MODEL DRIVEN SUGGESTIONS

• The suggestions can be derived declaratively from List of Values reference on a VO Attribute

• Steps:– On ViewObject

• Create ViewAccessor (for list values)• Create List of Values for Attribute• Link LoV to ViewAccessor

– In Page• Add InputListOfValues component based on

attribute• Add af:autoSuggestBehavior with suggestions

based on List of Values Binding’s suggestedItems

Page 61: ADF Gold Nuggets (Oracle Open World 2011)

IN PAGE:

Page 62: ADF Gold Nuggets (Oracle Open World 2011)

CUSTOM SUGGESTIONS

• Auto Suggestions can be provided by managed bean that implements signature: – List getSuggestions( String currentValue)

• And the List returned is really List<SelectItem>

• Potential use cases– Based on some (application wide) cached

collection (of previously entered ?) values– Retrieve values from WebService, file, …– Use common abbreviations, codes

• Country code, airport– Show translations in other languages

Page 63: ADF Gold Nuggets (Oracle Open World 2011)

STATIC LIST OF COUNTRIES

Suggestions

Page 64: ADF Gold Nuggets (Oracle Open World 2011)

SUGGESTIONS … OR?

• Suggested Values do not need to be suggestions in a very literal sense– What you see may not be what you get– The SelectItem as a label (WYS) and a value

(ISWYG)• Examples:

– Add words to field instead of replacing value– Perform selected

operation on value– Show an updated

indicator based on the value

Page 65: ADF Gold Nuggets (Oracle Open World 2011)

PAGE TEMPLATE

• Turns page layout inside out: – the page references the template– the page template determines the overall

structure – the page provides the content for the designated

areas in the template (through the facets)• Can be dynamically, context-sensitively

selected using an EL expression• Can also be used for areas within a page

– With multiple page templates used within the same page

– More an area template than a page template to define UI Design Patterns• Tree-with-Detail-Form, Table-and-Chart, Master-

Form-Detail-Table, Search block-Results table…

Page 66: ADF Gold Nuggets (Oracle Open World 2011)

USING MULTIPLE PAGE TEMPLATES

• Two templates: mainpage and Table-Form template

Page 67: ADF Gold Nuggets (Oracle Open World 2011)

OTHER PAGE CONSUMING THE TEMPLATE(S)

Page 68: ADF Gold Nuggets (Oracle Open World 2011)

CHANGING THE MICRO-TEMPLATE

Page 69: ADF Gold Nuggets (Oracle Open World 2011)

SUMMARY

• Twinkle, twinkle little stars…– #1 nugget– #2 nugget– #3 nugget

• Don’t give up [too soon]– There is more in ADF than meets the eye– There is a world of Java/JEE to leverage– There is a community to lean on

• Scan release notes and monitor blog-o-sphere for valuable new (and re-discovered) nuggets

• Share! Yes, you too! Your findings are just as valuable.– Participate in EMG and OTN Forum discussions,

write blog articles, present in conferences, …

Page 70: ADF Gold Nuggets (Oracle Open World 2011)

SESSION PLUGGING

• Tuesday – Reaching Out from PL/SQL (S08625 )10.15-11.15, Mariott Marquis, Salon 7

• Tuesday – (JavaOne) Cross Tier Push Architecture (Don’t call us, we’ll push you) (S24722)4.30-5.15 PM, Hotel Nikko, Monterey I/II

• Wednesday – Push to the Limit: Rich and Proactive User Interfaces with Oracle ADF (S08620)5-6 PM, Mariott Marquis, Golden Gate A

• Thursday – Instant Agility in Oracle Fusion Middleware through Design Time @ Run Time (S08623)4-5 PM, Moscone West – 2020

Page 71: ADF Gold Nuggets (Oracle Open World 2011)