56
1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

Embed Size (px)

DESCRIPTION

Slides from Oracle's ADF Architecture TV series covering the Design phase of ADF projects, looking into the different options for communication between ADF task flows. Like to know more? Check out: - Subscribe to the YouTube channel - http://bit.ly/adftvsub - Design Playlist - http://www.youtube.com/playlist?list=PLJz3HAsCPVaSemIjFk4lfokNynzp5Euet - Read the episode index on the ADF Architecture Square - http://bit.ly/adfarchsquare

Citation preview

Page 1: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Page 2: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Real World ADF Design & Architecture Principles Task Flow & Region Communication Patterns

ORACLE PRODUCT

LOGO

15th Feb 2013 v1.0

Page 3: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Learning Objectives

•  At the end of this module you should be able to:

– Understand different patterns of ADF region interaction – Be able to choose the right pattern to implement for a problem – Understand the dos and don’ts of task flow communication

Image: imagerymajestic/ FreeDigitalPhotos.net

Page 4: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes •  Contextual Events •  Exercises

Page 5: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Task Flow Communication Bounded Task Flow Call Options

Bounded Task Flow

Region

Task Flow Call Activity

displayed in

navigate to

URL GET Request navigate to

Page 6: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Task Flow Communication Call Activity

Task Flow

Task Flow Call Activity navigate to

provision Input Parameter Input Parameter Input Parameter

Page 7: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Task Flow Communication Call Activity

Task Flow

Task Flow Call Activity return control to

process

Return Value Return Value

Return Activity

Page 8: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Task Flow Communication ADF Region

Shared Data Control

Task Flow provision

Input Parameter Input Parameter Input Parameter

Region Parent View

Task Flow Binding

refresh

Parent View PageDef

get RegionModel

Page 9: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

But where is the return value in ADF regions?

Exercise

Image: imagerymajestic/ FreeDigitalPhotos.net

Page 10: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes •  Contextual Events •  Exercises

Page 11: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Example

Region 1

Region 2

Page 12: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region Interaction

•  Shared Data Control •  Input Parameters

– Parameter changes –  JavaBean instance references

•  ADF Region events •  Contextual events

Establishing Communication

Page 13: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Secret of Oracle ADF Rockstar Programmers

Often there is no single solution to a problem. Use case matters.

Page 14: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region

•  Master-detail synchronization between parent view and content shown in region

•  Parent view passing data to child region for further processing –  Embedded wizard use case

•  Parent view triggering navigation in region –  Generic CRUD flow –  Content switcher to display different views for a set of data

Usecase

Page 15: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent

•  Region to return value to parent view at end of task flow processing –  Region "exit" use case

•  Region method call to call behavior on parent view –  Dynamic Tab Shell Template use case

•  Navigate parent view in response to region change •  Change dynamic task flow configuration from region

Usecase

Page 16: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Region

•  Master-Detail behavior •  Region causing navigation in another •  Data passing

Usecase

Page 17: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes

– Shared Data Control –  Input Parameter – Region Events – Other

•  Contextual Events •  Exercises

Page 18: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region Master-Detail Behavior – Shared DC

Task Flow

af:region

Parent View

View <file>.jsff

Next Previous Administration PPR

1.

4.

Page 19: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region Master-Detail Behavior – Shared DC

Task Flow

af:region

Parent View

View <file>.jsff

<file>PageDef.xml

dependentEmployees Iterator

<file>PageDef.xml

allDepartmentsIterator

Next Previous Administration change row currency

PPR

1.

2.

4.

Page 20: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region Master-Detail Behavior – Shared DC

Task Flow

af:region

Parent View

View <file>.jsff

<file>PageDef.xml

dependentEmployees Iterator

<file>PageDef.xml

allDepartmentsIterator

Next Previous Administration change row currency

change row currency

PPR

update

1.

2.

3.

4.

Page 21: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region Master-Detail Behavior – Isolated DC

Task Flow

af:region

Parent View

View <file>.jsff

Next Previous Administration PPR

1.

4.

Page 22: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region Master-Detail Behavior – Isolated DC

Task Flow

af:region

Parent View

View <file>.jsff

<file>PageDef.xml

dependentEmployees Iterator

Data Control Layer

<file>PageDef.xml

allDepartmentsIterator

Next Previous Administration change row currency

PPR

Data Control Layer

taskFlowBinding

DepartmentName

detect change parameter value

Input Parameter

query

1.

2.

3.

4.

Page 23: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes

– Shared Data Control –  Input Parameter – Region Events – Other

•  Contextual Events •  Exercises

Page 24: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region Common Usecase: Navigate to Specific View in Region

Task Flow

af:region

Input Parameter

Parent Flow

control flow case 1

control flow case 2 view1

view2

view3

view3 Show View 3 On Click

PPR

Page 25: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent Bean Reference Injection

Bounded Task Flow

af:region

Input Parameter

Insert References to Parent View API

Managed Bean

Parent Task Flow (unbounded or bounded)

#{viewScope.ManagedBean}

Managed Bean

invokes method on caller

reference saved in

Page 26: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent: Chaperone in Action Usecase: Self closing regions in tabs

Bounded Task Flow

af:region

Managed Bean

Parent View Dynamic Tab Shell

Managed Bean View Scope

Input Parameter

View1 View2 Return Activity

Method Activity

Page 27: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent: Chaperone in Action Usecase: Self closing regions in tabs

Bounded Task Flow

af:region

Managed Bean

Parent View Dynamic Tab Shell

Managed Bean View Scope

View1 View2 Return Activity

Method Activity

Invoke method on

Page 28: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent: Chaperone in Action Usecase: Self closing regions in tabs

Bounded Task Flow

af:region

Managed Bean

Parent View Dynamic Tab Shell

Managed Bean View Scope

View1 View2 Return Activity

Method Activity

Invoke method on

Page 29: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent: Chaperone in Action Usecase: Self closing regions in tabs

Bounded Task Flow

af:region

Managed Bean

Parent View Dynamic Tab Shell

Managed Bean View Scope

View1 View2 Return Activity

Method Activity

Invoke method on

close tab

Page 30: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes

– Shared Data Control –  Input Parameter – Region Events – Other

•  Contextual Events •  Exercises

Page 31: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent Navigate Parent View : RegionNavigationListener

af:region

Shopping Cart View Checkout View

checkOut

Task Flow

View1 View2 Return Activity

"view1" "view2" null

Page 32: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent Navigate Parent View : RegionNavigationListener

af:region

Shopping Cart View Checkout View

checkOut

Task Flow

View1 View2 Return Activity

"view1" "view2" null

?

Page 33: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent Navigate Parent View : RegionNavigationListener

af:region

Shopping Cart View Checkout View

checkOut

Task Flow

View1 View2 Return Activity

RegionNavigation Listener

If(viewId == null){ //navigate to //checkout }

"view1" "view2" null

Managed Bean

Page 34: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Secret of Oracle ADF Rockstar Programmers

The Region Navigation Listener listens for what happens in a region not for what happens to a region

Page 35: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region

•  Method of the af:region component –  RichRegion

•  Invokes an ActionEvent as if it was queued from a command component inside a region –  Does not require the ADF region to refresh –  Used for navigating between activities

•  Control flow cases are discoverable

Navigate Region: queueActionEventInRegion

Page 36: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region

•  Region capabilities are used by a page to identify the available navigation cases for a view displayed in a region

Determine Region Capabilities in EL

#{bindings.[regionId].regionModel.capabilities['outcome']}

Page 37: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region

•  Determine Region Capabilities in Java

//backing bean with region component binding RichRegion region = this.getEmpRegion(); RegionModel model = region.getRegionModel(); Set<String> capabilities = model.getCapabilities(); ...

Page 38: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent-to-Region Navigate Region: QueueActionEventInRegion

af:region

Parent View

Task Flow

View2

View3

View4 View5

toView2 toView5

View1

Managed Bean

Handle Navigation

RichRegion region = ... region.queueActionEventInRegion(...)

Press to Navigate

toView1

Page 39: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes

– Shared Data Control –  Input Parameter – Region Events – Other

•  Contextual Events •  Exercises

Page 40: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent Navigate Parent View : Parent Activity

af:region

Shopping Cart View

CheckoutView

checkout

Task Flow

View1 View2 FailView

Task Flow

checkoutCallFailed

Page 41: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent Navigate Parent View : Parent Activity

af:region

Shopping Cart View

CheckoutView

checkout

Task Flow

View1 View2 FailView

Task Flow

checkoutCallFailed

Page 42: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Region-to-Parent Navigate Parent View : Parent Activity

af:region

Shopping Cart View

CheckoutView

checkout

Task Flow

View1 View2 FailView

Task Flow

checkoutCallFailed

Page 43: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes

– Shared Data Control –  Input Parameter – Region Events – Other

•  Contextual Events •  Exercises

Page 44: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

About Contextual Events

•  Mechanism on the ADF binding layer for creating loosely coupled publish and subscribe event models

•  Events may carry a data payload –  Payload does not have to be a single simple scalar type but can be a

complex object

•  Require fragment based task flows embedded within page regions •  Task flows with event producer and consumers can be saved in ADF

libraries

Page 45: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Contextual Events #1 Parent View

ParentViewPageDef

View Port View Port

Region 1 Region 2 ViewPageDef ViewPageDef

1 2

Event Map

Raise Event

Page 46: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent View

ParentViewPageDef

View Port View Port

Region 1 Region 2 ViewPageDef ViewPageDef

Contextual Events #2

2 1

Event Map

Raise Event

Page 47: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Parent View

ParentViewPageDef

View Port View Port

Region 1 Region 2 ViewPageDef ViewPageDef

Region 3

View Port

Contextual Events #3

1

2 3 Event Map

Raise Event

Page 48: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

48 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Contextual Events

•  Discoverability –  Event producer and event receiver

•  Documentation •  Event payload

–  What type of object is it? –  What is in a payload?

•  Developer "skill-up"

Challenges

Page 49: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Program Agenda

•  Task Flow Call Options •  Region Interaction Recipes

– Shared Data Control –  Input Parameter – Region Events – Other

•  Contextual Events •  Exercises

Page 50: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

50 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Exercise #1

•  The corporate architecture board is asked to suggest a solution for implementing master-detail behavior between two regions

•  The application requirement is to coodinate the content displayed in the region such that one shows customer information and the other the selected customer's orders

•  Further the requirement is that the view shows the master-detail behavior upon its initial rendering

•  Changing the customer displayed in the parent (customer) region should immediately show the associated orders is response

Parent-Child Relationship Between Regions

Page 51: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

51 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Exercise #1 Parent-Child Relationship Between Regions

Parent View

Customer View Customer - Orders View

Page 52: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

52 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Exercise #2

•  The requirement is for a task flow in a region to be able to hide / show components in the parent view

•  The use case that needs to be implemented is to conditionally hide / show (default) a panel accordion

Help the Team

Page 53: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

53 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Exercise #2 Hide/Show Components From a Region

Parent View

Region Customer

Orders Pending Shipments

Payments

Conditionally Hide&Show Accordion

Questions?

Page 54: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

54 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Conclusion

•  Keep it simple! Contextual events is powerful but not needed in many cases

•  Don't make any assumption in a task flow about the environment the task flow executes in and how it is called

•  Document task flow requirements for input parameters and return values

•  Use task flow templates

Page 55: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

55 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Further Reading

•  ADF Region Interaction Functional Pattern –  http://www.oracle.com/technetwork/developer-tools/adf/adfregioninteraction-155145.html

•  Contextual Events Introduction –  http://www.oracle.com/technetwork/issue-archive/2011/11-may/o31adf-352561.html

•  Contextual Events: Callback pattern –  http://www.oracle.com/technetwork/developer-tools/adf/learnmore/

regionpayloadcallbackpattern-1865094.pdf

•  Master- commander: reusable contextual event solution –  http://www.oracle.com/technetwork/issue-archive/2012/12-nov/o62adf-1867716.html

•  Parent view initializing region navigation –  http://www.oracle.com/technetwork/developer-tools/adf/learnmore/

externaltrainnavigationpattern-1845645.pdf

Page 56: Oracle ADF Architecture TV - Design - Task Flow Communication Pattern

56 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.