Functional. Pattern Embeding Regions inside PopUp Windows

Similar documents
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 launch a popup upon rendering of a page fragment in a region using JSF 2. Abstract: twitter.

OIG 11G R2 Field Enablement Training

ADF Region Interaction: External Train Navigation

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

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

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

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

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

Using JavaScript in ADF Faces Rich Client Applications

OES Permission Checks in ADF Task Flows

Oracle Hyperion Financial Management Developer and Customization Guide

Oracle Developer Day

web.xml Deployment Descriptor Elements

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

Oracle Retail Accelerators for WebLogic Server 11g

ADF Mobile Code Corner

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

ADF Mobile Code Corner

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

Extensibility Guide Oracle Financial Services Lending and Leasing Release [October] [2013] Part No. E

Oracle Fusion Middleware 11g: Build Applications with ADF I

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

1z0-419.exam.53q.

CS506 Web Design & Development Final Term Solved MCQs with Reference

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How!

User Scripting April 14, 2018

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar

Oracle Fusion Middleware 11g: Build Applications with ADF I

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.

sessionx Desarrollo de Aplicaciones en Red EL (2) EL (1) Implicit objects in EL Literals José Rafael Rojano Cáceres

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

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

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

Lab 3: Using Worklight Server and Environment Optimization Lab Exercise

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

ADF Mobile Code Corner

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

Contents. 1. JSF overview. 2. JSF example

Java EE 6: Develop Web Applications with JSF

Table of Contents. Introduction... xxi

ADF Mobile Code Corner

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

Advanced Software Engineering

3.2 Example Configuration

Eclipse Scout. Release Notes. Scout Team. Version 7.0

Chapter 6 Introduction to Defining Classes

Using SQL Developer. Oracle University and Egabi Solutions use only

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

Hello Worldwide Web: Your First JSF in JDeveloper

Topics Augmenting Application.cfm with Filters. What a filter can do. What s a filter? What s it got to do with. Isn t it a java thing?

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

Module 5 Developing with JavaServer Pages Technology

Oracle Developer Day

SESM Components and Techniques

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

Tapestry. Code less, deliver more. Rayland Jeans

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

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

Oracle JDeveloper/Oracle ADF 11g Production Project Experience

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

Introduction to Java Server Faces(JSF)

Question No: 1 In which file should customization classes be specified in the cust-config section (under mds-config)?

IBM Security Access Manager Version January Federation Administration topics IBM

JavaServer Pages. What is JavaServer Pages?

1 CUSTOM TAG FUNDAMENTALS PREFACE... xiii. ACKNOWLEDGMENTS... xix. Using Custom Tags The JSP File 5. Defining Custom Tags The TLD 6

Oracle Developer Day

CERTIFICATE IN WEB PROGRAMMING

Customizing Oracle Identity Governance: Populating Request Attributes

Roxen Content Provider

The Tie That Binds: An Introduction to ADF Bindings

FreeMarker in Spring Web. Marin Kalapać

Achieving the Perfect Layout with ADF Faces RC

Specialized - Mastering JEE 7 Web Application Development

Jquery Manually Set Checkbox Checked Or Not

SECTION II: JAVA SERVLETS

Anno Accademico Laboratorio di Tecnologie Web. Sviluppo di applicazioni web JSP

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

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

Setting Up the Development Environment

WebSign SDK (Java) Java(Client) - Java(Server) Developer s Guide

Oracle Fusion Middleware

Quick Web Development using JDeveloper 10g

<Insert Picture Here> Oracle Application Framework (OAF): Architecture, Personalization, and Extensibility in Oracle E-Business Suite Release 12

Experiment No: Group B_2

Jaffa Reference Guide Jaffa Components

JSF & Struts 1, 4, 7, 2, 5, 6, 3 2, 4, 3, 1, 6, 5, 7 1, 4, 2, 5, 6, 3, 7 1, 2, 4, 5, 6, 3, 7

extc Web Developer Rapid Web Application Development and Ajax Framework Using Ajax

JSR-286: Portlet Specification 2.0

Name Default Type Description. id null String Unique identifier of the component.

Different color bars chart with Popup Box in ADF

1Z0-560 Oracle Unified Business Process Management Suite 11g Essentials

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

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

A web-based IDE for Java

ORACLE JHEADSTART 12C for ADF

Building Rich Enterprise JSF Applications with Oracle JHeadstart for ADF (11.1.1)

AngularJS Intro Homework

Transcription:

Pattern Pattern 2.8 Revision Technologies JDeveloper 11g, ADF, ADF Faces, ADF Controller Keywords Publisher Pattern Team Publish Date September 19. 2008 Last Updated May 21, 2009 Date: Problem Description Regions can be incorporated into ADF Faces popup content to support potentially complex navigation through a series of pages to complete a task. Another important benefit of including regions within ADF Faces popups is content reuse. These great benefits make ADF Faces popups containing regions a commonly used application development pattern. Incorporating regions into <af:popup> content can seem similar to incorporating regions into a page, especially since an <af:popup> is actually considered part of a page. However, there are some important differences to keep in mind. When incorporating regions into <af:popup> content, the following default development constraints must be taken into consideration: <af:popup> content is created and executed when its corresponding page is initially displayed. It s not automatically refreshed when a <af:popup> is disclosed. When disclosing an <af:popup> subsequent times from the same page, region content isn t automatically refreshed and restarted from the beginning. An <af:popup> is not automatically dismissed when its region content completes via navigation flow. Likewise, when an <af:popup> is dismissed, its corresponding region content is not automatically considered complete. Therefore, resources used by the corresponding task flow (e.g. memory, DB transactions, etc.) are not released.

Region components activate when their <af:region> UI component is invoked (component tree built), not when the component tree is rendered. Most JSF UI components build their component tree and wait until rendering to activate. The <af:region> UI component is different since it must first resolve its task flow s target view to include the corresponding page fragment. Many of these default development constraints are the result of <af:popup> behavior being mainly client-side only. When a user discloses an <af:popup>, JavaScript on the client unhides the <af:popup> created previously when the page was initially displayed. When the <af:popup> is dismissed, JavaScipt on the client simply hides the <af:popup> again. In both cases, no event or request is sent to the server to refresh the region content or retrieve data based on the current application state. If the <af:popup> is displayed a second time, it simply redisplays the <af:popup> content remaining from the previous disclosure. Technical Pattern Description The following document describes the recommended development approach for the ADF Faces Popup + Region pattern. Other development approaches may be possible to achieve the same desired use case behavior. The development approach described in detail within this document is considered the most comprehensive and least complex approach. The User Experience The following application development use case represents the commonly desired behavior of an <af:popup> containing region content: 1. During application runtime, the user selects a button on a page. 2. An <af:popup> containing a region is disclosed. All content displayed within the <af:popup> is based on the current application state. 3. The user interacts with the region within the <af:popup> to facilitate a task. 4. When the task is completed, the user returns to the page by exiting the region via navigation flow or closing the <af:popup>. 5. The user selects the same button on the same page a second time.

6. Once again, the <af:popup> containing the region is disclosed. Region content is refreshed and restarted from the beginning. All content displayed within the <af:popup> is based on the current application state when the <af:popup> is disclosed the second time. It does not redisplay content from the previous disclosure. The Artifacts When incorporating regions into <af:popup> content, the following development constructs are recommend to implement the desired use case behavior: Dynamic Region used instead of a region to swap between an empty task flow and the real task flow. Ensures resources and memory for the real task flow are only allocation when the <af:popup> is disclosed and appropriately released when the <af:popup> is dismissed. <af:popup> contentdelivery controls when the <af:popup> delivers it s content to the browser. When set to "lazyuncached" the <af:popup> markup is pulled down each time the <af:popup> is disclosed. <af:setpropertylistener> specified on the <af:popup> to swap the real task flow into the dynamic region when a popupfetch event is received. <af:region> regionnavigationlistener defined on the <af:region> UI component to identify when the region completes (task flow exits via

navigation flow to a task flow return activity). When executed includes logic to automatically hide the <af:popup>. If the region is not designed to exit, a regionnavigationlistener is not required. <af:serverlistener> specified on the <af:popup> to swap an empty task flow into the dynamic region when a popupclosed event is received. Implementing the Pattern Dynamic Region Dynamic regions use an EL expression to determine their corresponding taskflowid at runtime. This allows more advanced applications to dynamically specify the taskflowid to execute within the dynamic region at different points in the application runtime. Other regions simply specify their corresponding taskflowid as a static literal that cannot be changed. When a dynamic region taskflowid changes at runtime, the dynamic region is automatically refreshed with new parameter values and restarted from its default activity. Dynamic regions lend themselves well to being used within <af:popup> content. If the <af:popup> is hidden, an empty task flow can be assigned to the dynamic region. When the <af:popup> is disclosed, the real task flow can be swapped in. This ensures task flow resources and memory are only allocated when the <af:popup> is disclosed and properly released when the <af:popup> is hidden. Dynamic Region taskflow Binding A dynamic region page definition taskflow Binding example is shown below: <taskflow id="dynamicregion1" taskflowid="$viewscope.popupdynamicregionbean.dynamictaskflowid" xmlns="http://xmlns.oracle.com/adf/controller/binding"> <parameters> <parameter id="employeeid" value="#pageflowscope.employeeid" xmlns="http://xmlns.oracle.com/adfm/uimodel"/> </parameters> </taskflow> Note: Dynamic regions (and other regions) are initially refreshed when their parent page is first displayed. This includes those appearing within

<af:popup> content. taskflow Binding Refresh and RefreshCondition settings only control refreshing after the initial refresh. Therefore, application developers should ensure dynamic regions (or other regions) appearing within <af:popup> content don t result in errors due to unavailable data when the parent page is initially displayed. This is another benefit of assigning an empty task flow to a dynamic region appearing within <af:popup> content when the parent page is first displayed. Dynamic Region Managed Bean A dynamic region uses a managed bean to manage the value of the taskflow Binding taskflowid. An excerpt from a dynamic region managed bean example is shown below: public class PopupDynamicRegion private String taskflowid = ""; private String popuptaskflowid = "/WEB-INF/employeeupdate.xml#employee-update"; private String emptytaskflowid = ""; public PopupDynamicRegion() public String getdynamictaskflowid() if(taskflowid!=null) return taskflowid; else return getemptytaskflowid(); public void setdynamictaskflowid(string newtaskflowid) taskflowid = newtaskflowid; public String getemptytaskflowid() return emptytaskflowid;

public TaskFlowId getpopuptaskflowid() return TaskFlowId.parse(popupTaskFlowId); Note: When a dynamic region taskflowid EL expression evaluates to an empty String (e.g.: "") the taskflowid will be handled as an empty task flow. Currently, there isn't a constant of type TaskFlowId defined to represent an empty task flow. Dynamic Region Input Parameters When passing input parameters to dynamic regions within <af:popup> content an extra implementation step is required. Input parameters are still passed to a dynamic region by specifying <parameters> on the region s taskflow Binding. The task flow definition for the dynamic region must also still specify corresponding <input-parameter-definition>s with the same names (e.g.: EmployeeId ). The extra step comes in since input parameter values passed from the parent page to <af:popup> content should be accessed through a launcher component. Therefore, any input parameters should first be set as an <af:clientattribute> (e.g.: employee ). Once disclosed, the <af:popup> content can refer to the value passed using its launcher component (e.g.: #source.attributes.employee ). An example of setting an <af:clientattribute> is shown below. For an example of an <af:popup> retrieving a value passed from its launcher component, refer to the <af:setpropertylistener> section below. <af:commandbutton text="update" clientcomponent="true" id="updateemployee" partialsubmit="true"> <af:clientattribute name="employee" value="#row.empno"/> <af:showpopupbehavior popupid="::popupregion1"/> </af:commandbutton> Note: <af:showpopupbehavior> cancels any server-side event delivery automatically. Therefore, any actionlistener or action attributes on the parent component will be ignored. This cannot be disabled. For example, the following <af:setactionlistener> would be ignored if included on the

same <af:commandbutton>: <af:setactionlistener from="#row.empno" to="#requestscope.empno"/> Note: There are several client services to manage layering, positioning, dismissal, and modality. When a browser page is reloaded, these services are reinitialized resulting in dismissal of all open <af:popups>. For this reason, <af:popups> only support partial submit commands. Partial submit commands perform a postback to the server without reloading the page. <af:popup> contentdelivery To ensure <af:popup> markup will be delivered refreshed each time the <af:popup> is disclosed its contentdelivery attribute is set to lazyuncached. The contentdelivery default lazy only delivers markup when the <af:popup> is first disclosed and then caches it. The <af:popup> attributes launchvar and eventcontext should be set as shown in the example below so popupfetch and popupclosed events produced when an <af:popup> is disclosed and dismissed can be utilized. These events provide the timing for when to swap the dynamic region taskflowid. <af:popup id="popupregion1" contentdelivery="lazyuncached" launchervar="source" eventcontext="launcher"> <af:panelwindow id="window" title="employee Popup" modal="true"> </af:panelwindow> </af:popup> Note: When incorporating dynamic regions (or other regions) into <af:popup> content an <af:panelwindow> should be used within the <af:popup>. An <af:popup> without an <af:panelwindow> is an inline selector popup with auto-dismissal behaviors making it unusable with dynamic regions (or other regions). If an < af:dialog> is used within the <af:popup> instead of an <af:panelwindow>, connecting the <af:dialog> buttons in the footer up with the task flow navigation in the dynamic region is a very complicated endeavor. It s much easier to use an <af:panelwindow> and incorporate any buttons into the dynamic region content.

<af:setpropertylistener> Functional An <af:setpropertylistener> is specified within an <af:popup> to swap the real task flow into a dynamic region when a popupfetch event is received just before the <af:popup> is disclosed. An example of swapping the popuptaskflowid value into the dynamictaskflowid when a popupfetch event is received is shown below. For further details on these managed bean properties, refer to the Dynamic Region Managed Bean section of the document. An <af:setpropertylistener> can also be specified within an <af:popup> to pass values from the parent page set as an <af:clientattribute>. These values might be required for dynamic region input parameters. The <af:setpropertylistener> retrieves these values from the <af:popup> launcher component when a popupfetch event is received. An example of retrieving the passed value of the <af:clientattribute> employee from the launcher component is shown below. <af:popup id="popupregion1" contentdelivery="lazyuncached" launchervar="source" eventcontext="launcher"> <af:setpropertylistener from="#source.attributes.employee" to="#pageflowscope.employeeid" type="popupfetch"/> <af:setpropertylistener from="#viewscope.popupdynamicregionbean.popuptaskflowid" to="#viewscope.popupdynamicregionbean.dynamictaskflowid" type="popupfetch"/> <af:panelwindow id="window" title="employee Popup" modal="true"> </af:panelwindow> </af:popup> <af:region> regionnavigationlistener An <af:region> regionnavigationlistener is required if the dynamic region within the <af:popup> provides the ability to exit via navigation flow to task flow return activities. The regionnavigationlistener identifies when the region exits so the <af:popup> can be programmatically dismissed without the user manually selecting its close icon. Using the employee-update task flow definition below as an example, the regionnavigationlistener would be performed after executing either the save or cancel task flow return activities to exit the task flow definition.

A regionnavigationlistener is specified on the <af:region> UI component as shown below. <af:popup id="popupregion1" contentdelivery="lazyuncached" launchervar="source" eventcontext="launcher"> <af:setpropertylistener from="#source.attributes.employee" to="#pageflowscope.employeeid" type="popupfetch"/> <af:setpropertylistener from="#viewscope.popupdynamicregionbean.popuptaskflowid" to="#viewscope.popupdynamicregionbean.dynamictaskflowid" type="popupfetch"/> <af:panelwindow id="window" title="employee Popup" modal="true"> <af:region value="#bindings.dynamicregion1.regionmodel" id="dynam1" regionnavigationlistener="#viewscope.popupdynamicregionbean.navigationlistener"/> </af:panelwindow> </af:popup> The regionnavigationlistener method used to programmatically hide the <af:popup> when the task flow exists would be similar to the following: public void navigationlistener(regionnavigationevent event) String newviewid = event.getnewviewid();

// null new view id indicates the taskflow has ended if (newviewid == null) RichRegion region = (RichRegion)event.getSource(); // look for the parent popup boolean found = false; UIComponent component = region.getparent(); do if (component instanceof RichPopup) found = true; else component = component.getparent(); if (component == null) break; while (!found); if (found) // send script to the client to hide the popup FacesContext context = FacesContext.getCurrentInstance(); Service.getRenderKitService(context, ExtendedRenderKitService.class).addScript(context, "var popup = AdfPage.PAGE.findComponent('" + component.getclientid(context) + "'); popup.hide();"); <af:severlistener> An <af:severlistener> is specified on the <af:popup> to swap an empty task flow into the dynamic region when a popupclosed event is received. But, since the popupclosed

event is a client side only event, an <af:clientlistener> is also implemented to identify the popupclosed event then launch a custom event the <af:serverlistner> can receive. <af:popup id="popupregion1" contentdelivery="lazyuncached" launchervar="source" eventcontext="launcher"> <af:setpropertylistener from="#source.attributes.employee" <af:setpropertylistener to="#pageflowscope.employeeid" type="popupfetch"/> from="#viewscope.popupdynamicregionbean.popuptaskflowid" to="#viewscope.popupdynamicregionbean.dynamictaskflowid" type="popupfetch"/> <af:panelwindow id="window" title="employee Popup" modal="true"> <af:region value="#bindings.dynamicregion1.regionmodel" id="dynam1" regionnavigationlistener="#viewscope.popupdynamicregionbean.navigationlistener"/> </af:panelwindow> <af:clientlistener method="popupclosedlistener" type="popupclosed"/> <af:serverlistener type="serverpopupclosed" method="#viewscope.popupdynamicregionbean.swapemptytaskflow"/> </af:popup> The following <script> is incorporated into the page containing the <af:popup> for the <af:clientlistener> to perform when a popupclosed event is received. It invokes a server side callback custom event the <af:serverlistener> can receive. Instead of incorporating JavaScript into the page, a custom JSP tag can be implemented to encapsulate the same behavior. For further details on implementing a custom JSP tag, refer to Appendix - Implementing a Custom JSP Tag. <script> function popupclosedlistener(event) var source = event.getsource(); var popupid = source.getclientid(); var params = ; params['popupid'] = popupid;

var type = "serverpopupclosed"; var immediate = true; Functional AdfCustomEvent.queue(source, type, params, immediate); </script> The method called by the <af:serverlistener> to swap the empty task flow into the dynamic region would be similar to the following: public void swapemptytaskflow(clientevent event) setdynamictaskflowid(""); // if event delivery set to immediate= true, short-circuit to renderresponse. // Forcing an empty taskflow releases the bindings and view port. FacesContext context = FacesContext.getCurrentInstance(); context.renderresponse(); String popupid = (String) event.getparameters().get("popupid"); System.out.println("**** Swapping Empty Taskflow on popupclosed for " + popupid + " ****"); Interaction Behavior <af:popup> Disclosed 1. Button/link is selected and invokes <af:showpopupbehavior> to identify the appropriate <af:popup> to disclose. 2. <af:popup> popupfetch event published. 3. <af:popup> popupfetch event received by <af:setpropertylistener>. 4. <af:setpropertylistener> assigns <af:clientattribute> values from the parent page to pass into the <af:popup>. 5. <af:setpropertylistener> swaps the real task flow into the dynamic region.

6. taskflow Binding of the dynamic region is refreshed and restarted since its taskflowid has been changed. 7. <af:popup> popupfetch event delivers new markup to the browser and displays it to the user since <af:popup> contentdelivery= lazyuncached. <af:popup> Dismissed By Selecting Close Icon 1. User dismisses <af:popup> by selecting the close icon. 2. <af:popup> popupclosed event published. 3. <af:popup> popupclosed event received by <af:clientlistener>. 4. <af:clientlistener> invokes <script> to publish custom event for server side callback. 5. Custom event for server side callback is published. 6. Custom event for server side callback is received by <af:serverlistener>. 7. <af:serverlistener> method swaps an empty task flow into the dynamic region. 8. taskflow Binding of the dynamic region is refreshed and restarted since its taskflowid has been changed. Memory and resources remaining from the previous taskflowid are released appropriately. 9. If event delivery set to immediate= true, jump is forced to renderresponse phase. 10. Next time user discloses the <af:popup> its content will once again be refreshed. <af:popup> Dismissed By Exiting Region 1. User dismisses <af:popup> by exiting the dynamic region via navigation flow to a task flow return activity. 2. <af:region> regionnavigationlistener is performed. 3. <af:region> regionnavigationlistener identifies the task flow has exited by newviewid=null. 4. <af:region> regionnavigationlistener programmatically hides <af:popup>. 5. <af:popup> popupclosed event published. 6. <af:popup> popupclosed event received by <af:clientlistener>. 7. <af:clientlistener> invokes <script> to publish custom event for server side callback. 8. Custom event for server side callback is published.

9. Custom event for server side callback is received by <af:serverlistener>. 10. <af:serverlistener> method swaps an empty task flow into the dynamic region. 11. taskflow Binding of the dynamic region is refreshed and restarted since its taskflowid has been changed. Memory and resources remaining from the previous taskflowid are released appropriately. 12. If event delivery set to immediate= true, jump is forced to renderresponse phase. 13. Next time user discloses the <af:popup> its content will once again be refreshed. Appendix Implementing a Custom JSP Tag The ADF Faces Popup + Region pattern described within this document utilizes JavaScript embedded within page markup to publish a server side custom event when the popupclosed client side event is received. If the application developer prefers not to include JavaScript directly within page markup, a custom JSP tag can be created to encapsulate the same behavior. For example, an <adfdemo:closepopupdynamicregionbehavior> custom JSP tag could accept a popupid, an event delivery immediate flag, and method as attributes. The method specified would be performed when the popupclosed client side event is received. The new custom JSP tag could be incorporated into an <af:popup> as shown in the example below. <af:popup id="popupregion1" contentdelivery="lazyuncached" launchervar="source" eventcontext="launcher"> <af:setpropertylistener from="#source.attributes.employee" to="#pageflowscope.employeeid" type="popupfetch"/> <af:setpropertylistener from="#viewscope.popupdynamicregionbean.popuptaskflowid" to="#viewscope.popupdynamicregionbean.dynamictaskflowid" type="popupfetch"/> <af:panelwindow id="window" title="employee Popup" modal="true"> <af:region value="#bindings.dynamicregion1.regionmodel" id="dynam1" regionnavigationlistener="#viewscope.popupdynamicregionbean.navigationlistener"/> </af:panelwindow> <adfdemo:closepopupdynamicregionbehavior popupid="popupregion1" immediate= true

</af:popup> method="#viewscope.popupdynamicregionbean.swapemptytaskflow"/> The #viewscope.popupdynamicregionbean.swapemptytaskflow method specified by the custom JSP tag would be similar to the following: public void swapemptytaskflow(clientevent event) setdynamictaskflowid(""); // if event delivery set to immediate="true", short-circuit to renderresponse. // Forcing an empty taskflow releases the bindings and view port. Boolean immediate = (Boolean)event.getParameters().get("immediate"); if (immediate!= null && immediate) FacesContext context = FacesContext.getCurrentInstance(); context.renderresponse(); String popupid = (String)event.getParameters().get("popupId"); System.out.println("**** Swapping Empty Taskflow on popupclosed for " + popupid + " ****"); To create the custom JSP tag described above, the following items should be implemented: JSP Tag Library (*.tld) describes design time behavior of the custom JSP tag. Custom Tag Behavior Class (*.java) describes server side behavior of the JSP custom tag. Custom Tag Behavior JavaScript (*.js) describes client side behavior of the JSP custom tag. Resources (adfdemo.resources) specifies servlet resource files to include. No need to create if existing servlet resource already defined.

ResourceLoader (*.java) identifies resource loaders for handling JavaScript files in the resources servlet. No need to create if existing file already defined. web.xml servlet mapping. No need to create if existing servlet mapping for appropriate servlet already specified. Project Properties - compiler Settings, Trinidad Runtime Library, and Trinidad Tag Library. No need to add if existing file inclusion types and libraries are already specified. Script Delivery Using <trh:script> - No need to add to page markup if already specified. JSP Tag Library - adfdemo.tld \ViewController\public_html\WEB-INF\adfdemo.tld (if project only JSP tag library) <?xml version = '1.0' encoding = 'windows-1252'?> <taglib xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" version="2.1" xmlns="http://java.sun.com/xml/ns/javaee"> <display-name>adfdemo</display-name> <tlib-version>1.0</tlib-version> <short-name>adfdemo</short-name> <uri>/webapp/adfdemo</uri> <tag> <description> </description> <name>closepopupdynamicregionbehavior</name> <tag-class>oracle.adf.view.closepopupdynamicregionbehaviortag</tag-class> <body-content>jsp</body-content> <attribute> <name>popupid</name> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>method</name>

<deferred-method> <method-signature>void mymethod(oracle.adf.view.rich.render.clientevent)</methodsignature> </deferred-method> </attribute> </tag> </taglib> Custom Tag Behavior Class - ClosePopupDynamicRegionBehaviorTag.java \ViewController\src\oracle\adf\view\ClosePopupDynamicRegionBehaviorTag.java package oracle.adf.view; import javax.el.methodexpression; import javax.faces.component.uicomponent; import oracle.adf.view.rich.event.clientlistenerset; import oracle.adfinternal.view.faces.taglib.behaviors.behaviortag; public class ClosePopupDynamicRegionBehaviorTag extends BehaviorTag private String popupid = null; private Boolean immediate = false; private MethodExpression method = null; public ClosePopupDynamicRegionBehaviorTag() @Override protected String getbehavior(uicomponent uicomponent) StringBuilder buff = new StringBuilder(); buff.append("new

AdfDemoClosePopupDynamicRegionBehavior('").append(popupId).append("',").append(immediate).append(")"); return buff.tostring(); public void setpopupid(string popupid) this.popupid = popupid; public String getpopupid() return popupid; public void setimmediate(boolean immediate) this.immediate = immediate; public Boolean getimmediate() return immediate; public void setmethod(methodexpression method) this.method = method; public MethodExpression getmethod() return method; protected void updateclientlistenerset(uicomponent component, ClientListenerSet cls)

Functional super.updateclientlistenerset(component, cls); if (method!= null) cls.addcustomserverlistener("serverpopupclosed", method); Custom Tag Behavior JavaScript - AdfDemoClosePopupDynamicRegionBehavior.js \ViewController\src\oracle\adf\view\AdfDemoClosePopupDynamicRegionBehavior.js function AdfDemoClosePopupDynamicRegionBehavior(popupId, immediate) this.init(popupid, immediate); AdfObject.createSubclass(AdfDemoClosePopupDynamicRegionBehavior, AdfClientBehavior); AdfDemoClosePopupDynamicRegionBehavior.prototype.initialize = function(component) component.addeventlistener(adfpopupclosedevent.popup_closed_event_type, this._handlepopupclosed, this); AdfDemoClosePopupDynamicRegionBehavior.prototype._handlePopupClosed = function (event) var source = event.getsource(); AdfAssert.assertPrototype(source, AdfRichPopup); var popupid = this._popupid; AdfAssert.assertString(popupId);

var immediate = this._immediate; Functional AdfAssert.assertBoolean(immediate); var params = ; params['popupid'] = popupid; var type = "serverpopupclosed"; AdfCustomEvent.queue(source, type, params, immediate); AdfDemoClosePopupDynamicRegionBehavior.prototype.Init = function (popupid, immediate) AdfDemoClosePopupDynamicRegionBehavior.superclass.Init.call(this); AdfAssert.assert(popupId!= null); this._popupid = popupid; this._immediate = immediate; Resources - adfdemo.resources \ViewController\src\META-INF\servlets\resources\adfdemo.resources oracle.adf.view.resourceloader ResourceLoader - ResourceLoader.java \ViewController\src\oracle\adf\view\ResourceLoader.java package oracle.adf.view; import org.apache.myfaces.trinidad.resource.aggregatingresourceloader; import org.apache.myfaces.trinidad.resource.classloaderresourceloader; import org.apache.myfaces.trinidad.resource.regexresourceloader; public class ResourceLoader

extends RegexResourceLoader public ResourceLoader() register("(/.*\\.(jpg gif png jpeg))", new ClassLoaderResourceLoader("META-INF")); register("(/.*all-adfdemo.js)", new AcmeScriptsResourceLoader("/adfdemo/all-adfdemo.js")); public static class AcmeScriptsResourceLoader extends AggregatingResourceLoader public AcmeScriptsResourceLoader(String scriptsuri) super(scriptsuri, _LIBRARIES, new ClassLoaderResourceLoader()); this.setseparator(acmescriptsresourceloader._newline_separator); static private final String[] _LIBRARIES = "oracle/adf/view/adfdemoclosepopupdynamicregionbehavior.js" ; static private final String _NEWLINE_SEPARATOR = "\n"; web.xml Servlet Mapping \ViewController\public_html\WEB-INF\web.xml Add web.xml servlet mapping for the resources servlet to the /adfdemo/ URL pattern. <servlet-mapping> <servlet-name>resources</servlet-name> <url-pattern>/adfdemo/*</url-pattern>

</servlet-mapping> Project Properties Add file inclusion types to project properties complier "Copy File Types to Output Directory" field for bundling in.resource and.js. The Trinidad Tag Library should be added to the project properties JSP Tag Libraries and the Trinidad Runtime Libraries to the Libraries and Classpath. Script Delivery Using <trh:script> Script delivery is only automatic for library components. Therefore, it should be accounted for within the page markup using <trh:script> as shown below. The file referenced by the source attribute is utilized by the script ResourceLoader. <jsp:root mlns:trh= http://myfaces.apache.org/trinidad/html > <trh:head> <trh:script source="/adfdemo/all-adfdemo.js"/> </trh:head> Known Issues Automatic Partial Page Rendering: Automatic Partial Page Rendering for dynamic regions within <af:popups> is not supported by ADF Faces and ADF Controller. The "ChangeEventPolicy" attribute on the iterator bindings and value bindings should be set to 'none'. Instead, ADF Faces Partial Page Rendering can be used. For further information on ADF Faces Partial Page Rendering, refer to the "Oracle Fusion Middleware Web User Interface Developer's Guide for Oracle Application Development Framework 11g Release" Chapter 7 "Rendering Partial Page Content".

Appendix Object Definitions Used by the Prototype In order to test this pattern out, included is a JDeveloper 11g Application called PopupRegionSample.zip that can be unzipped into your designated work area and explored / executed from within JDeveloper 11g. Simply download PopupRegionSample.zip, unzip the archive, open the ADFPopupRegionSampleApplication.jws within JDeveloper 11g and explore. When using an Oracle Database version 10g or higher download the PopupRegionSample10.zip. This version utilizes the EMPLOYEES database table rather than the EMP database table. As of the Oracle Database version 10g, the EMP database table was removed. Note: This sample uses the HR schema that comes with the Oracle Database since version 9i. In some cases, you will need to unlock the HR account in the database.