Mastering Oracle ADF Task Flows Frank Nimphius Principal Product Manager Oracle JDeveloper / ADF 1
ADF Controller Introduction Real Life Control Flow: How to get to the Opera? The Rules You Are Here Opera Line 6 doesn't operate on Sundays You have 30 minutes to get there in time You have to meet a friend first to get the tickets You must get your evening dress from the laundry (closes at 5 pm) Train staff announced temporary power outage at 6 p.m for 2 minutes Train tickets can only be reimbursed if not used Day passes allow you to get on and off trains as often as you want 2
What is ADF Controller? ADFc Definition Extension to JSF page flow engine Addresses key enterprise requirements * Reuse * Navigation to non-visual targets * Declarative exception and transaction handling * Security Visually defined in task flow diagrammer Allows the definition of managed beans Additional memory scopes What we say, what we mean Unbounded Taskflow First entry on task flow stack the outer-most task flow No well-defined boundary or single point of entry Used to define the top level flow of an application Used to build menu models Declarative bookmarking of view activities Bounded Taskflow Reusable "white box" navigation and processing Single point of entry Well-defined boundary Own memory scope Declarative transaction management Declarative Back button support Input/output parameters 3
Key Concepts View Activity Activity flows (navigation cases) Method execution Router Task flow call activity Exception handling Declarative Exception Handling Exceptions can be mapped to an activity Generally for unexpected exceptions or security violations Not a normal part of a flow Only one handler per flow However, that could be a method or a router if different errors need different handling <exception-handler>unexpectederrorpage</exception-handler> 4
Product Demonstration Task Flow Design Time Control Flow Case Named events that link activities Just like JSF navigation rules Raised by command items in the page buttons / links / menus Defined as the action attribute, or the result of action code Have an origin Combination of page and raising method Wildcards are allowed so global rules are possible Have a destination An activity What does it really mean? You just draw a line on the diagram! 5
Control Flows pagehelp globalhelp editrecord apphelp <control-flow-rule> <from-activity-id> editrecord </from-activity-id> <control-flow-case> <from-outcome> pagehelp </from-outcome> <to-activity-id> apphelp </to-activity-id> </control-flow-case> </control-flow-rule> <control-flow-rule> <from-activity-id> * </from-activity-id> <control-flow-case> <from-outcome> globalhelp </from-outcome> <to-activity-id> apphelp </to-activity-id> </control-flow-case> </control-flow-rule> 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 6
Product Demonstration Task Flow Templates Bounded Task Flow 7
About Bounded Task Flows Modular blocks of task flow functionality Well-defined boundary Additional Memory scope Declarative transaction management Can accept input parameters and return values On-demand metadata loading Fragment reuse through task flow templates Declarative Back button support Declarative Security Train Model Consist of: Activities View, Router, Method, task flow call, URL Control flows between activities Bounded Task Flow Benefits Can be nested within and called from other task flows Invoked Task flow call activity Treated like any other activity Parent is suspended whilst the sub-flow has focus Has a defined API Parameters and outcomes (just like view activities) Has a strict entry point users can't just jump to a page Special handling for the browser back button Initializer and Finalizer code can be defined Automatically run Can be created based on templates 8
Use It in Another Flow Product Demonstration Creating Bounded Task Flows 9
Saving for Later Quitting time Next Morning I ll work some more on this tomorrow. Great right where I left off! Save for Later Unbounded and Bounded Task Flow feature Takes a Snapshot of current transaction and memory states Saves Snapshot in Database Allows users to recover to left state Automatic snapshots possible when bounded task flow is marked as critical Not a "save as draft" Snapshots are only stored for limited time (24h by default) 10
Save for Later Explicit save for later: Requires an action from the end user Enabled by calling SavePointManager.createSavePoint() Implicit save for later: Happens when browser is closed or session times out. Enabled by setting the critical property on the taskflow Data is restored using a save point restore activity with save-point id. Saved Content User Interface State UI state of the current page, including selected tabs, selected checkboxes, selected table rows, and table column sort order Managed Beans State information saved in memory scopes, including page flow scope The managed beans must be serializable in order to be saved. Navigation State Task flow call stack Tracks where the end user is in the application and the navigational path for getting there 11
Product Demonstration Implementing Save Points ADF Region 12
About ADF Regions A special use case of bounded task flow Display as independent areas of a page or a page fragment Executes task flow without requiring the parent view to refresh Key enabler of enterprise Web 2.0 development with the Oracle Fusion development platform Allows building desktop like web user interfaces that unveil the real power of Ajax Does not expose developers to the complexity of Ajax programming Type of ADF Regions Static Create by drag-and-drop of bounded task flow definition from Application Navigator Task flow binding in PageDef file points to bounded task flow af:region component referenced task flow binding Dynamic Create by drag-and-drop of bounded task flow definition from Application Navigator chosing "Dynamic Region" option Task flow binding in PageDef file references managed bean Managed bean defines which task flow to show in af:region tag Allows to switch between bounded task flows 13
Use it inside another View Product Demonstration Using Bounded Task Flows in Regions 14
Summary ADF Task Flows is an extension of the JSF Navigation Flow Two Types of Flows: Unbounded and Bounded Promotes Reuse and allows flows to run within areas of a page Visual design time Declarative transaction and exception handling 15