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

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

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

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

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

ADF Mobile Code Corner

ADF Code Corner How-to declaratively build a master-detail behavior with DVT components. 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. 016-How-to customize the ADF Faces Table Filter. Abstract: twitter.com/adfcodecorner

ADF Mobile Code Corner

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

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

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

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

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

ADF Code Corner. 90. Filtering ADF bound lists. 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. 048-How-to build XML Menu Model based site menus and how to protect them with ADF Security and JAAS. Abstract:

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

ADF Mobile Code Corner

How To Create Employee With Designation Report In ADF Attractively

ADF Mobile Code Corner

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

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

ADF Region Interaction: External Train Navigation

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

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

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

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

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

OIG 11G R2 Field Enablement Training

Functional. Pattern Embeding Regions inside PopUp Windows

Oracle Developer Day

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

Oracle Fusion Middleware 11g: Build Applications with ADF I

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

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

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

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

Oracle Fusion Middleware 11g: Build Applications with ADF I

Achieving the Perfect Layout with ADF Faces RC

Using JavaScript in ADF Faces Rich Client Applications

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

Oracle Application Development Framework Overview

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

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

Creating a Model-based Builder

Oracle JDeveloper/Oracle ADF 11g Production Project Experience

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

... AND UIX BEGAT ADF FACES: HOW RICH IS ADF FACES RICH CLIENT? Peter Koletzke, Quovera

Oracle Developer Day

Customizing Oracle Identity Governance: Populating Request Attributes

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

Java EE 6: Develop Web Applications with JSF

If you wish to make an improved product, you must already be engaged in making an inferior one.

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

We didn t need dialogue. We had faces.

Oracle ADF: The technology behind project fusion. Lynn Munsinger Principal Product Manager Application Development Tools Oracle Corporation

Oracle Business Intelligence Publisher

Oracle WebCenter 11g PS3 Administration Cookbook

Rich Web UI made simple Building Data Dashboards without Code

Oracle WebCenter Suite Integrating Secure Enterprise Search

JSF Tags. This tutorial will cover a number of useful JSF tags. For a complete listing of available JSF tags consult the Oracle documentation at:

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

The Arrangement of the Screens: Introduction to Layout in ADF Faces

Exam Questions 1Z0-419

The Tie That Binds: An Introduction to ADF Bindings

Oracle Retail Accelerators for WebLogic Server 11g

Different color bars chart with Popup Box in ADF

Oracle Developer Day

Oracle Fusion Middleware

Oracle Fusion Middleware

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

Getting Started with Web Services

Hello Worldwide Web: Your First JSF in JDeveloper

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

Oracle Fusion Developer Guide (ISBN: ) Preview Chapter 1. The Quick Lerner s Guide to Oracle Fusion Web Application Development PREVIEW

ADF Mobile : Data Services Java Beans. Ma Ping

Oracle Developer Day

<Insert Picture Here> The Oracle Fusion Development Platform: Oracle JDeveloper and Oracle ADF Overview

Creating your first JavaServer Faces Web application

<Insert Picture Here> Productive JavaEE 5.0 Development

JavaServer Faces 2.0. Sangeetha S E-Commerce Research Labs, Infosys Technologies Ltd

1z0-419.exam.53q.

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

Freely Programmed Help- Web Dynpro

Sun Java Studio Creator. Ken Paulsen Staff Engineer Sun Microsystems, Incorporated (Slides by: Craig R. McClanahan)

An Oracle White Paper September Oracle Fusion Middleware MapViewer

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

An Oracle White Paper September Exposing WebCenter Services Task Flows as WSRP Portlets and Ensemble Pagelets

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

Oracle WebCenter Hands-On Practices. A Practical Introduction to Oracle WebCenter

Getting Started with Web Services

<Insert Picture Here> Accelerated Java EE Development: The Oracle Way

In this topic: Extrac t Style. Inline Style Extract Layout Inline Layout Refactoring

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

<Insert Picture Here> JDeveloper Treasure Hunt

Oracle Utilities Customer Self Service

Contents. 1. JSF overview. 2. JSF example

MVC. Peter Koletzke, Quovera. Figure 1. MVC layers

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

Transcription:

ADF Code Corner 108. How-to launch a popup upon rendering of a page Abstract: A common requirement in Oracle ADF is to launch a popup dialog when a page fragment is rendered in a region. In JDeveloper 11g R1, the best option was to use a hidden text field with its value referencing a managed bean method that then launches the popup from Java. In JDeveloper 11g R2 and JDeveloper 12c, another option becomes available, which is the use of JSF 2 system events. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 21-AUG-2013

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 Launching a popup upon rendering a page fragment in a region is a frequent requirement among ADF application developers. In JDeveloper 11g R1, and JavaServer Faces 1.2, the only reliable option is to use a hidden output text field that has its value property referencing a managed bean method, which then launches the popup. With the new JavaServer Faces system events in JSF 2, there now is a better approach available for Oracle JDeveloper 11g R2 and JDeveloper 12c: https://javaserverfaces.java.net/nonav/docs/2.1/vdldocs/facelets/f/event.html The following example shows how to invoke a dialog upon initial page fragment rendering and view navigation within an ADF region using Oracle JDeveloper 11g R2 (11.1.2.4) 2

Setting up the use case The use case for this example is simple and shows a region embedded in a JSF page exposing a task flow that has two page fragments view1.jsff and view2.jsff. The default page fragment, and also the fragment that launches the popup is view1.jsff. The wanted outcome is that a popup is launched whenever view1.jsff initially renders as the default view of the region and when the view is navigated to in context of task flow navigation. Creating view1.jsff View1.jsff is created declaratively by dragging the view component from the task flow component palette to the bounded task flow definition. To keep the sample simple, the views only contain a single command button to simulate navigation in the region. A simplified page source code of view1.jsff is shown below <?xml version='1.0' encoding='utf-8'?> <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich" xmlns:f="http://java.sun.com/jsf/core"> <af:panelgrouplayout id="pgl3"> <af:commandbutton text="goview2" id="cb1" action="goview2"/> 3

<af:popup childcreation="immediate" autocancel="disabled" id="p1" contentdelivery="lazyuncached"> <af:dialog id="d1" resize="on" stretchchildren="first" type="ok" title="information"> <af:outputtext value="this is a dialog that shows on page fragment load" id="ot1"/> </af:dialog> </af:popup> </af:panelgrouplayout> </ui:composition> There are two things to mention about the source code shown above: 1. The af:popup component is set to immediately create its child objects by setting the popup childcreation property to immediate. 2. The root component of the page fragment is a group layout that contains to child components: the command button and the popup. With this we know that the popup component is within the same JSF naming container, which means we can perform relative searches as will be shown later. Defining the system event System events in JSF 2 allow developers to add a component phase listener f:event to UI components, which then fire to defined times in the page lifecycle. Select the view1,jsff page fragment in the JDeveloper Application Navigator and open the Structure Window (ctrl+shift+s). Select the af:panelgoruplayout component (the oage fragment root component) as this components is unlikely to be partially refreshed when the application user works within the view. Open the Component panel (ctrl+shift+p) and switch the tag library selection to JSF as shown in the image below. 4

Then drag the Event component tag from the component palette and drop it on top of the af:panelgrouplayout component. Use the Insert Event dialog to create and/or map the tag to a managed bean method. 5

Create a new managed bean or select an existing managed bean to create or reference the event listener method in. Ensure that the managed bean is in backing bean scope as the view is exposed in a bounded task flow (!). Press New next to the Method field to create the event listener method skeleton and signature in the managed bean. Press OK to close the managed bean creation dialog. In the Insert Event dialog, choose the prerendercomponent phase as the event type. This way the referenced managed bean is called whenever the component is rendered. 6

Press Ok to add the event tag to the parent component (the panel group in this example) The view1bean managed bean referenced by the listener is shown below: public class View1Bean { private String sayhello; private boolean popuplaunched = false; public View1Bean() {} public void invokepopup(componentsystemevent componentsystemevent) { //find popup relative to event component and //and avoid double invocation if (!popuplaunched) { UIComponent pagefragmentroot = componentsystemevent.getcomponent(); } //show dialog RichPopup p1 = (RichPopup)pageFragmentRoot.findComponent("p1"); RichPopup.PopupHints hints = new RichPopup.PopupHints(); p1.show(hints); 7

} } popuplaunched = true; Conclusion Using component events (aka. system events) in JSF 2 provides an optimized solution for launching ADF Faces popups upon view rendering in a region. This article explained the declarative steps to implement this solution. At runtime, for this example, the popup below shows when the page containing the region renders and when view1.jsff is navigated to from view2.jsff The completed page source is shown below: <af:panelgrouplayout id="pgl3"> <af:panelgridlayout id="pgl1"> <af:commandbutton text="goview2" id="cb1" action="goview2"/> <f:event listener="#{backingbeanscope.view1bean.invokepopup}" type="prerendercomponent"/> <af:popup childcreation="immediate" autocancel="disabled" id="p1" contentdelivery="lazyuncached"> <af:dialog id="d1" resize="on" stretchchildren="first" type="ok" title="information"> <af:outputtext value="this is a dialog that shows on page fragment load" id="ot1"/> </af:dialog> </af:popup> 8

</af:panelgrouplayout> </ui:composition> RELATED DOCOMENTATION System event tag: https://javaserverfaces.java.net/nonav/docs/2.1/vdldocs/facelets/f/event.html 9