39
<Insert Picture Here> Building Highly Reusable ADF Task Flows Steven Davelaar twitter:@stevendavelaar blogs: blogs.oracle.com/jheadstart and blogs.oracle.com/ateam_webcenter Oracle Fusion Middleware Architects Team (the “A-team”)

Building Highly Reusable Taskflows

Embed Size (px)

DESCRIPTION

Presentation conducted at ODTUG Kaleidoscope 2011, OOW 2011 and UKOUG 2011. Sample application can be downloaded from my blog: http://blogs.oracle.com/jheadstart/entry/core_adf11_building_reusable_task

Citation preview

Page 1: Building Highly Reusable Taskflows

<Insert Picture Here>

Building Highly Reusable ADF Task Flows

Steven Davelaar twitter:@stevendavelaarblogs: blogs.oracle.com/jheadstart and blogs.oracle.com/ateam_webcenterOracle Fusion Middleware Architects Team (the “A-team”)

Page 2: Building Highly Reusable Taskflows

Agenda

• Reusability requirements - generic

• Addressing generic reusability requirements

• Reusability requirements – taskflow specific

• Task flow reuse cases

2

Page 3: Building Highly Reusable Taskflows

Reusability Requirements - Generic

• Use with traditional menu structure

• Use with dynamic tabs

• Use with human workflow task list

• Use as WebCenter portlet

• Add at runtime using WebCenter Composer

3

• Add at runtime using WebCenter Composer

Develop User Interface Services – Not Pages!

Page 4: Building Highly Reusable Taskflows

Addressing Reusability Requirements

• Use bounded taskflows with page fragments

– Reusable UI service with clearly defined contract

• Embed as (Dynamic) ADF Region in any page.

• An ADF region:

– Represents a task flow as part of a page

4

– Is similar to a portlet, but for local functionality

– Can share information and transaction boundaries with other page content

Page 5: Building Highly Reusable Taskflows

UIShell – Tabbed Menu

5

Page 6: Building Highly Reusable Taskflows

UIShell – Dynamic Tabs with Tree Menu

6

Page 7: Building Highly Reusable Taskflows

Using Dynamic ADF Regions – Additional

complexity

• You can no longer use standard JSF navigation

– No pages to go to, only regions

• XMLMenuModel cannot be used out of the box

– focusRowKey maps to current page

• “Unioned” parameter list for all regions

7

– Parameters of each task flow in taskflow binding

Page 8: Building Highly Reusable Taskflows

Addressing the complexity

• Use DynamicRegionManager to provide current task flow and params

• Task flow details provided by TaskflowConfigBean

• Subclass NavigationHandlerImpl to allow your developers to use JSF-like navigation to regions

8

• Subclass XMLMenuModel to add support for regions

• Use parameter map for dynamic region binding

• Keep track of changed parameters

– Refresh=ifNeeded does not work with param map

Page 9: Building Highly Reusable Taskflows

UIShellPageDef

<taskFlow id="mainRegion“ taskFlowId="${pageFlowScope.dynamicRegionManager.currentTaskFlowId}"

UI Shell at Runtime

UIShell.jsf

Dynamic Region

<af:region value=“#{bindings.mainRegion.regionModel />

9

taskFlowId="${pageFlowScope.dynamicRegionManager.currentTaskFlowId}" parametersMap="${pageFlowScope.dynamicRegionManager.currentParamMap}" RefreshCondition="{pageFlowScope.dynamicRegionManager.currentParamMapChanged}“ />

TaskFlowConfigBean

nametaskflowIdparamMap

DynamicRegionManager

get/setCurrentTaskFlowNamegetCurrentTaskflowIdgetCurrentParamMap

Page 10: Building Highly Reusable Taskflows

UIShell at Runtime – Managed Beans

10

Page 11: Building Highly Reusable Taskflows

TaskFlowConfigBean - Jobs

11

Page 12: Building Highly Reusable Taskflows

Navigating Using Dynamic Regions

• Create custom RegionNavigationHandler

– configure in faces-config.xml

– Provides standard JSF navigation through superclass

– Allows setting current dynamic region: region name specified after navigation outcome, separated by colon

12

Page 13: Building Highly Reusable Taskflows

Navigating Using Dynamic Regions

• Action ”uishell:Jobs”

– navigates to UIShell.jsf page (if needed)

– sets current task flow “Jobs” on mainRegionManager

– TaskFlowId picked up from JobsTaskFlowConfigBean

– Parameters picked up from JobsTaskFlowConfigBean

13

Page 14: Building Highly Reusable Taskflows

Reusability Requirements – Taskflow Specific

• Configure to show in read-only mode

• Configure to show one specific row (deeplinking)

• Configure to go to summary or detail page

• Configure to start in create mode (new row)

• Configure to hide UI components buttons (Save,

14

• Configure to hide UI components buttons (Save, Cancel, Nav. Buttons, Search region)

• Configure to use both as “parent” or as “child” within another region

• Configure to use in popup / details lookup

Page 15: Building Highly Reusable Taskflows

Reuse Case 1 – Adding Menu Entry to View Jobs

15

Page 16: Building Highly Reusable Taskflows

Reuse Case 1 – Adding Menu Entry to View Jobs

• Enable jobs task flow to run in read-only mode

– Add readOnly parameter to the jobs task flow

– Set job fields readOnly based on readOnly param

– hide save button based on readOnly param

– Set title to View Job in readOnly mode

• Add menu entry “ViewJobs” to menu.xml

16

• Add menu entry “ViewJobs” to menu.xml

• Create ViewJobsTaskFlowConfig bean

– Set readOnly parameter to true

Page 17: Building Highly Reusable Taskflows

Reuse Case 1 – Adding Menu Entry to View Jobs

17

Page 18: Building Highly Reusable Taskflows

Reuse Case 2 – Add Deeplinking to Edit Job

18

Page 19: Building Highly Reusable Taskflows

Reuse Case 2 – Add Deeplinking to Edit Job

Prepare Jobs task flow:

• Add rowKeyValue parameter

• Create method activity SetCurrentRow

– DnD SetCurrentRowWithKeyValue method, or

– DnD custom queryByKeyValue AM method

– Navigate to EditJob page

19

• Start task flow with router activity

– Check value rowKeyValue parameter

– If not null, go to setCurrentRow method activity

– If null, go to SearchJobs page

Page 20: Building Highly Reusable Taskflows

Reuse Case 2 – Add Deeplinking to Edit Job

20

Page 21: Building Highly Reusable Taskflows

Reuse Case 2 – Add Deeplinking to Edit Job

21

Page 22: Building Highly Reusable Taskflows

Reuse Case 2 – Add Deeplinking to Edit Job

Prepare Employees task flow:

• Add task flow call activity CallJob to Employees TF

• Create Page Definition for CallJob

• Set rowKeyValue param to current JobId:

– Reuse EditEmployee Page Def for CallJob activity

22

– How: Change usage in PageMap in Databindings.cpx, delete newly created page def

• Add control flow rule from EditEmployee to CallJob

• Add editJob command link to EditEmployee page

Page 23: Building Highly Reusable Taskflows

Reuse Case 2 – Add Deeplinking to Edit Job

23

Page 24: Building Highly Reusable Taskflows

Reuse Case 3 – View Job Details in Popup

24

Page 25: Building Highly Reusable Taskflows

Reuse Case 3 – View Job Details in Popup

Two implementation strategies:

• Jobs TF Call with Run as Dialog option

– This option cannot be used with page fragments!

– Need PopupShell TF with PopupShell page that embeds Jobs region

– Too complex ....

25

– Too complex ....

• Add popup component, and drag and drop Jobs TF as region inside popup

Page 26: Building Highly Reusable Taskflows

Reuse Case 3 – View Job Details in Popup

• (Add readOnly param to Jobs TF)

• Add Popup with Dialog to EditEmployee

– Set childCreation=deferred to prevent premature region loading

– Set contentDelivery=lazyUncached

• DnD Jobs TF into Dialog

26

• DnD Jobs TF into Dialog

– Set readOnly and rowKeyValue params

– Set refresh=ifNeeded

• Set rowKeyValue param to current JobId

• Add ViewJob command link to invoke Popup

– Or use contextFacet on JobId

• Optional: add hideToolbarButtons param

Page 27: Building Highly Reusable Taskflows

Reuse Case 3 – View Job Details in Popup

27

Page 28: Building Highly Reusable Taskflows

Reuse Case 4 – Employees TF as Child in

Department Page

28

Page 29: Building Highly Reusable Taskflows

Reuse Case 4 – Employees TF as Child in

Department Page

• Restrict query employees based on department

– Set up view criteria with departmentId bind var, or

– Use dynamic iterator to bind to EmployeesView3

• Using dynamic iterator binding

– Add TF parameter dataCollection

– Set “Binds” property of iterator to dataCollection param

29

– Set “Binds” property of iterator to dataCollection param

• Auto-query in Departments page

– Use initialQueryOverridden property on search binding

• Hide DepartmentId, Save, Cancel items when used in Departments page

– Check dataCollection parameter, or add new params

Page 30: Building Highly Reusable Taskflows

Reuse Case 4 – Employees TF as Child in

Department Page

30

Page 31: Building Highly Reusable Taskflows

Reuse Case 4 – Employees TF as Child in

Department Page

31

Page 32: Building Highly Reusable Taskflows

Reuse Case 5 – Deeplinking from External Source

32

Page 33: Building Highly Reusable Taskflows

Reuse Case 5 – Deeplinking from External Source

• DynamicRegionManager checks request params

– PostConstruct method looking for taskFlowName param

– Set current taskflow

– Map other request params to TF params

../faces/UIShell?taskFlowName=Jobs&rowKeyValue=AC_MGR

33

Page 34: Building Highly Reusable Taskflows

Data Control Scope and Transactions

• Data Control Scope

– Shared: all TF’s share same app module instance

– Isolated: Each TF instance has own app module instance

• Transaction Scope

– With isolated data control scope each TF has own transaction

– With shared data control scope, transaction is shared by

34

default, but can be changed using Transaction setting

Page 35: Building Highly Reusable Taskflows

Data Control Scope and Transactions

• Data Control Scope and Transaction are defined at task flow definition level

• Limits reuse options!

• Isolated transactions needed for dynamic tabs

• Shared transaction needed for child region

• Enhancement request: set DC scope and transaction

35

• Enhancement request: set DC scope and transaction on TF Call activity and TF binding

• Work around:

• Create complete TF as template (templates can be nested)

• Create one TF with isolated transaction based on this template

• Create one TF with shared transaction based on this template

Page 36: Building Highly Reusable Taskflows

Testing Task Flows

• ADF EMG Taskflow Tester

• Testing of bounded task flows with pages and fragments

• Support for complex, composite input parameters

• Input parameters and run options can be saved as testcases

• XML Import/export facility for testcases

• It’s Free! Install through Help -> Check for Updates

36

• It’s Free! Install through Help -> Check for Updates

Page 37: Building Highly Reusable Taskflows

Summary

• Use bounded task flows with page fragments

• Set up infrastructure to use ADF regions in UIShell

• Think about possible reuse cases

• Define required input parameters

• Add router activity for reuse-case-based conditional flows

• Configure use of dynamic iterator binding

37

• Configure use of dynamic iterator binding

• Configure conditional display of UI components

• Think carefully about data control scope and transaction settings

• Use the ADF EMG Task Flow Tester

Page 38: Building Highly Reusable Taskflows

Useful Resources

• Blog post: UIShell with Menu Driving a Dynamic Region

• Contains links to presentation and sample application

• blogs.oracle.com/jheadstart/entry/core_adf11_uishell_with_menu

• ADF EMG Samples

• java.net/projects/smuenchadf/pages/ADFSamples

• ADF EMG Task Flow Tester

38

• ADF EMG Task Flow Tester

• java.net/projects/adf-task-flow-tester

• ADF Architecture Square

• Task Flow Fundamentals (http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adf-task-flow-trans-fund-v1-1-1864319.pdf)

Page 39: Building Highly Reusable Taskflows

39