ADF Code Corner. 97. How-to defer train-stop navigation for custom form validation or other developer interaction. Abstract: twitter.

Similar documents
ADF Region Interaction: External Train Navigation

ADF Code Corner How-to launch a popup upon rendering of a page fragment in a region using JSF 2. Abstract: twitter.

ADF Mobile Code Corner

ADF Code Corner How-to enforce LOV Query Filtering. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to bind custom declarative components to ADF. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to declaratively build a master-detail behavior with DVT components. Abstract: twitter.com/adfcodecorner

ADF Code Corner How to cancel an edit form, undoing changes with ADFm savepoints

ADF Code Corner. 90. Filtering ADF bound lists. Abstract: twitter.com/adfcodecorner

ADF Mobile Code Corner

ADF Code Corner Implementing auto suggest functionality in ADF Faces. Abstract:

ADF Mobile Code Corner

ADF Code Corner How-to show a glasspane and splash screen for long running queries. Abstract: twitter.com/adfcodecorner

ADF Mobile Code Corner

ADF Code Corner. 048-How-to build XML Menu Model based site menus and how to protect them with ADF Security and JAAS. Abstract:

ADF Code Corner. 70. How-to build dependent list boxes with Web Services Business Services. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to further filter detail queries based on a condition in the parent view using ADF BC. Abstract: twitter.

ADF Code Corner. 71. How-to integrate Java Applets with Oracle ADF Faces. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to build a reusable toolbar with Oracle ADF Declarative Components. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to use Captcha with ADF Faces and Oracle ADF. Abstract: twitter.com/adfcodecorner

ADF Code Corner. 64. How-to implement a Select Many Shuttle with pre- selected values. Abstract: twitter.com/adfcodecorner

ADF Code Corner. 65. Active Data Service Sample Twitter Client. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to use the af:autosuggestbehavior component tag with ADF bound data sources. Abstract: twitter.

ADF Code Corner. 016-How-to customize the ADF Faces Table Filter. Abstract: twitter.com/adfcodecorner

Functional. Pattern Embeding Regions inside PopUp Windows

ADF Code Corner How-to restrict the list of values retrieved by a model driven LOV. Abstract: twitter.com/adfcodecorner

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

ADF Code Corner. Oracle JDeveloper OTN Harvest 01 / Abstract: twitter.com/adfcodecorner

ADF Code Corner. Oracle JDeveloper OTN Harvest 02 / Abstract: twitter.com/adfcodecorner

ADF Code Corner. Oracle JDeveloper OTN Harvest 04 / Abstract: twitter.com/adfcodecorner

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

ADF Hands-On. Understanding Task Flow Activities / 2011 ADF Internal Enterprise 2.0 Training. Abstract:

ADF Code Corner. Oracle JDeveloper OTN Harvest 10 / Abstract: twitter.com/adfcodecorner

Mastering Oracle ADF Task Flows. Frank Nimphius Principal Product Manager Oracle JDeveloper / ADF

Oracle Retail Accelerators for WebLogic Server 11g

OIG 11G R2 Field Enablement Training

Oracle Fusion Middleware 11g: Build Applications with ADF I

Oracle Middleware 12c: Build Rich Client Applications with ADF Ed 1 LVC

Oracle Fusion Middleware 11g: Build Applications with ADF I

ADF Code Corner. Oracle JDeveloper OTN Harvest 09 / Abstract: twitter.com/adfcodecorner

Attached Object, UI Component Wovening of Attributes using Meta Rule API - JSF

Customizing Oracle Identity Governance: Populating Request Attributes

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

Oracle Application Development Framework Overview

ADF Code Corner. Oracle JDeveloper OTN Harvest 12 / Abstract: twitter.com/adfcodecorner

Exam Questions 1Z0-419

InfoSphere Data Architect Pluglets

<Insert Picture Here> Advanced ADF Faces. Frank Nimphius Principal Product Manager

Achieving the Perfect Layout with ADF Faces RC

Introduction. My Safe Zones

6/13/2012. Sneak Preview: Oracle JDeveloper 12c New Features. Frank Nimphius Senior Principal Product Manager Oracle Development Tools

Oracle 1Z Oracle Application Development Framework 12c Essentials. Download Full Version :

Oracle Developer Day

Oracle Fusion Middleware

Content Author's Reference and Cookbook

Getting Started with Web Services

Oracle Digital Assistant: Strategies for Escaping the Validation Loop

WebCenter Program Management

Oracle Developer Day

Getting Started with Web Services

A Guide to Quark Author Web Edition 2015

User Scripting April 14, 2018

Oracle Exam 1z0-419 Oracle Application Development Framework 12c Essentials Version: 7.0 [ Total Questions: 87 ]

Take Your Oracle Forms on the Road Using ADF Mobile. Mia Urman, OraPlayer & Denis Tyrell, Oracle Corporation

Productivity! Feature Matrix

<Insert Picture Here> The Latest E-Business Suite R12.x OA Framework Rich User Interface Enhancements

Developing an ADF 11g client for Agile PLM. Developing an ADF 11g client for Agile PLM

1Z0-430

Oracle Education Partner, Oracle Testing Center Oracle Consultants

Oracle Reports Developer 10g: Build Reports

ADF OAF Who Cares? You Do! Oracle Applications Framework / Application Development Framework - Which way do I go?

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

Lab 20: UI Customization

Oracle WebCenter Suite Integrating Secure Enterprise Search

Advanced Input Help - The Object Value Selector (OVS)

An Oracle White Paper June Guidelines for Creating Task Flows to Be Used in Oracle Composer-Enabled Pages

Oracle Fusion Middleware Developing Extensions for Oracle JDeveloper. 12c ( )

Java Server Faces - The View Part

Illustration 1: The Data Page builder inputs specifying the model variable, page and mode

AuraPlayer Server Manager User Guide

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

IBM. IBM WebSphere Application Server Migration Toolkit. WebSphere Application Server. Version 9.0 Release

Oracle Reports Developer 10g: Build Reports

A demo Wakanda solution (containing a project) is provided with each chapter. To run a demo:

A Guide to Automation Services 8.5.1

Teamcenter 11.1 Systems Engineering and Requirements Management

How to Develop a Simple Crud Application Using Ejb3 and Web Dynpro

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Joomla

BrightWork Team Member Training Guide

Oracle BPEL Process Manager Demonstration

Overview of generated code

Oracle Fusion Middleware

JSF Tools Reference Guide. Version: M5

Oracle Fusion Middleware

CIS 764 Tutorial: Log-in Application

1z0-419.exam.53q.

TRAINING GUIDE FOR OPC SYSTEMS.NET. Simple steps to successful development and deployment. Step by Step Guide

CaptainCasa Enterprise Client. CaptainCasa Enterprise Client. CaptainCasa & Java Server Faces

How-to Build Card Layout Responses from Custom Components

Using JavaScript in ADF Faces Rich Client Applications

Administrative Training Mura CMS Version 5.6

Transcription:

ADF Code Corner 97. How-to defer train-stop navigation for custom form Abstract: ADF developers can declaratively define a bounded task fow to expose a train model for users to navigate between views. As power comes with complexity, there is a lot you can do with trains if you go beyond drag-and-drop in ADF. This article explains how user train stop selections can be intercepted, followed or suppressed by the developer. The sample provided with this article displays a popup dialog for the user to confirms he/she wants to navigate off the current view. If the user presses cancel, no navigation is performed. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 21-FEB-2011

Oracle ADF Code Corner is a loose blog-style series of how-to documents that provide solutions to real world coding problems. Disclaimer: All samples are provided as is with no guarantee for future upgrades or error correction. No support can be given through Oracle customer support. Please post questions or report problems related to the samples in this series on the OTN forum for Oracle JDeveloper: http://forums.oracle.com/forums/forum.jspa?forumid=83 Introduction The train component and the associated train model in bounded task flows is a powerful feature in ADF that can be tailored and customized for different kind of cases beyond simple view to view navigation. In this article, the user train stop selection to naigate to another view is intercepted for the developer to object and cancel or continue with the navigation. The screenshots below are taking from the sample built for this code corner article. In this sample, when a user clicks on a train stop icon to perform navigation instead of navigating to the view associated with the train stop, a popup is displayed. The popup, for example, could be shown if custom validation fails for a view or if data needs to be be committed. 2

If the user OKs the dialog, navigation is performed according to the train navigation rule. If the user cancels the navigation, the current view is not left. Implementing the solution Implicit named navigation cases are used in ADF when navigating between views in a bounded task flow using the train model. To intercept the navigation request, which is triggered by the user clicking onto a train stop in an af:train component or on a train button in a af:trainbuttonbar component, you need to customize the train nodestamp facet, adding a custom command item that routes all train stop actions to a managed bean first. But, let's go step-by-step. The sample has four views displayed in a train. Each view is based on a page template that contains a popup component. 3

Using a page template is a convenient and time saving option to add a popup dialog to views without coding the popup into each view. In JDeveloper 11g R2, page templates can be nested, which allows you to reference functional templates like this containing a popup to share with page layout templates. Each view contains an af:train component that in its nodestamp facet has a commannavigationitem component defined. Using a commannavigationitem in the nodestamp allows developers to change the default train rendering and behavior. The commannavigationitem ActionListener property is set up to point to a managed bean method. Each view and train stop references the same managed bean method. The managed bean method's responsibility is To determine the train stop the user clicked on Show the popup dialog (or if the use case is to conditionally show the popup, to determine the condition) 4

The commannavigationitem has an f:attribute component added to keep track of which train stop the user clicked on. The f:attribute item adds a custom attribute to the ADF Faces component that can be accessed in the managed bean. The #{trainnode reference is of type TaskFlowTrainStopModel and exposes the train stop navigation case by its getoutcome() method. The commannavigationitem instance is accessible from the managed bean method using the ActionEvent object that is passed to it. Two managed beans are used in this sample. The TrainHandlerBean is defined in request scope and is referenced from the commannavigationitem in the af:train component on the views and the af:popup 5

component in the template. The TrainHandlerBeanHelper is configured in viewscope and holds the reference to the outcome value of the train stop clicked by the user. The TrainHandlerBeanHelper is configured as a managed property in the TrainHandlerBean definition. Both beans are configured in the bounded task flow metadata. Shown below is the managed bean configuration for the TrainHandlerBean. As you can see, the TrainHandlerBeanHelper bean is referenced as a managed property, which is required for the popup listener that notifies the managed bean about the dialog close by the user to get access to the user selected train node. The two managed bean code listings are shown below. I commented the code source so you know what each method therein does and from where it is accessed. TrainHandlerBean (request scope) The TrainHandlerBean implements all of the logic. It saves the user selected train stop node's outcome value (the implicit navigation case) in the TrainHandlerBeanHelper so the information persists beyond the request. The bean also opens the popup dialog by searching within the ADF region container for the af:popup instance. When the popup is closed by the user pressing Ok or Cancel, the managed bean is called again. If the selected outcome is Ok, then the bean queues an action event on the ADF region to navigate to the next view. 6

package adf.sample; import javax.el.elcontext; import javax.el.expressionfactory; import javax.el.methodexpression; import javax.faces.component.uicomponent; import javax.faces.context.facescontext; import javax.faces.event.actionevent; import javax.faces.event.phaseid; import oracle.adf.controller.taskflowtrainstopmodel; import oracle.adf.view.rich.component.rich.richpopup; import oracle.adf.view.rich.component.rich.fragment.richpagetemplate; import oracle.adf.view.rich.component.rich.fragment.richregion; import oracle.adf.view.rich.component.rich.nav.richcommandnavigationitem; import oracle.adf.view.rich.event.dialogevent; public class TrainHandlerBean { /** * Managed bean property reference to a helper bean in view scope private TrainHandlerBeanHelper trainhandlerbeanhelper = null; public TrainHandlerBean() { /** * Action method that is referenced from the train stop command * action to defer train navigation and allow developers to * interact with the user. In this sample a popup dialog is opened * for the user to confirm train navigation. * * The use case for deferred trains top navigation includes manual * complex field validation, to check for * uncommitted data, e.g. * ControllerContext.getInstance().getCurrentViewPort() *.isdatadirty(), etc. * * @param actionevent public void ontrainstopselect(actionevent actionevent) { RichCommandNavigationItem rni = (RichCommandNavigationItem)actionEvent.getSource(); TaskFlowTrainStopModel selectedtrainstop = 7

(TaskFlowTrainStopModel)rni.getAttributes().get("trainStopNode"); String outcome = selectedtrainstop.getoutcome(); trainhandlerbeanhelper.setselectedtrainstopoutcome(outcome); /* * ADD YOUR DEFERRED ACTION. FOR EXAMPLE, LAUNCH POPUP. TO * CONTINUE THE TRAIN NAVIGATION, CALL * queuetrainstopeventtoregion(... ) //launch popup. Start search from af:region. The af:region and //the af:pagetemplate tags are //naming container. This has an impact to the runtime ID of the //popup component. So to find popup component just by its ID //"pt_p1", we enter the region container, then the template to //then call findcomponent("pt_p1") RichRegion adfregion = this.findrichregioncontainer(rni); //in this sample, the popup component is in a template. Page //Fragments can only have a single //root component (everything else is flagged as an error) so //that the template must be the first children in the region RichPageTemplate regiontrainstoppopuptemplate = null; regiontrainstoppopuptemplate = (RichPageTemplate) adfregion.getchildren().get(0); UIComponent component = regiontrainstoppopuptemplate.findcomponent("pt_p1"); if(component!= null){ RichPopup richpopup = (RichPopup) component; //align popup to screen center RichPopup.PopupHints hints = new RichPopup.PopupHints(); richpopup.show(hints); else{ //TODO change to use logger System.out.println("The popup instance with ID pt_p1 could not be found"); /** * Method that finds the af:region container for a bounded task * flow exposed in a region. Don't use this method outside of ADF * regions. * @param uicomponent Component within the region that is the 8

* starting point for the search * @return The RichRegion instance as UIComponent private RichRegion findrichregioncontainer(uicomponent uicomponent) { UIComponent currentcomponent = uicomponent; while(!(currentcomponent instanceof RichRegion)){ //task flows in a region always have a RichRegion container //sonewhere. currentcomponent = currentcomponent.getparent(); return (RichRegion) currentcomponent; /** * In this sample the popup contains a dialog with OK, Cancel * button. * When OK is clicked, the train stop navigation should progress. If * not, the train stop should not continue and remain on the current * page * * @param dialogevent public void ondialogaction(dialogevent dialogevent) { //only if user confirmed navigation to the next train stop, //perform navigation. Otherwise ignore request and remain //on current train stop view if (dialogevent.getoutcome() == DialogEvent.Outcome.ok) { //perform saved train stop navigation queuetrainstopeventtoregion("#{viewscope.trainhandlerbeanhelper.getselectedtrainstopoutcome", dialogevent.getcomponent()); /** * Wrapper method around the RichRegion queueactioneventinregion * API. * @param outcomeel The EL to access a managed bean that returns * the navigation string to to follow. This can be an outcome for a * navigation case, or as in this sample, the implicit navigation * case used in trains * * @param searchcomponentinregion To queue the action, we need a 9

* handle to the RichRegion component. Providing us with a * component residing in a region is all that is * needed to search the af:region container private void queuetrainstopeventtoregion(string outcomeel, UIComponent searchcomponentinregion) { //This sample assumes bounded task flows to be exposed in an //af:region. So it is safe to assume a parent component to be of //type RichRegion. Let's find it to queue the train stop //outcome event for navigation. RichRegion adfregion = null; adfregion = this.findrichregioncontainer(searchcomponentinregion); FacesContext fctx = FacesContext.getCurrentInstance(); ExpressionFactory expressionfactory = fctx.getapplication().getexpressionfactory(); ELContext elctx = fctx.getelcontext(); MethodExpression methodexpression = expressionfactory.createmethodexpression(elctx, outcomeel, String.class, new Class[] { ); //queue action in region adfregion.queueactioneventinregion( methodexpression, null, null, false, 0, 0, PhaseId.INVOKE_APPLICATION); /** * Managed bean property reference to a managed bean in view scope * @param trainhandlerbeanhelper Managed bean inserted as a managed * property reference public void settrainhandlerbeanhelper( TrainHandlerBeanHelper trainhandlerbeanhelper) { this.trainhandlerbeanhelper = trainhandlerbeanhelper; public TrainHandlerBeanHelper gettrainhandlerbeanhelper() { return trainhandlerbeanhelper; TrainHandlerBeanHelper (view scope) 10

This managed bean is just a helper class that saves the selected train node outcome value for later navigation when the user confirms the popup dialog with Ok. package adf.sample; public class TrainHandlerBeanHelper { private String selectedtrainstopoutcome = null; public TrainHandlerBeanHelper() { super(); public void setselectedtrainstopoutcome( String selectedtrainstopoutcome) { this.selectedtrainstopoutcome = selectedtrainstopoutcome; public String getselectedtrainstopoutcome() { return selectedtrainstopoutcome; Sample Download The Oracle JDeveloper 11.1.2.1 sample workspace is available as sample 97 from ADF Code Corner. http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html Though the sample is developed with JDeveloper 11g R2, the solution also works with previous versions of Oracle JDeveloper 11g. RELATED DOCOMENTATION Oracle Magazine article about trains http://www.oracle.com/technetwork/issue-archive/2011/11-sep/o51adf-452576.html Trains in the ADF product documentation http://docs.oracle.com/cd/e16162_01/web.1112/e16182/taskflows_complex.htm#cjhfbfie Related ADF Code Corner articles http://www.oracle.com/technetwork/developer-tools/adf/learnmore/93-differentuifortrainstops- 1413952.pdf http://www.oracle.com/technetwork/developer-tools/adf/learnmore/82-programmaticallynavigate-trains-396873.pdf http://www.oracle.com/technetwork/developer-tools/adf/learnmore/80-dyn-sequential-configtrain-387002.pdf 11

12