Вы находитесь на странице: 1из 18

Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

1 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

2 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

3 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

4 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

5 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

6 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

7 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

Share

Tweet

Like 0

8 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

9 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

package com.vesterli.demo.popupapp1.view.beans;

import java.util.Map;

import oracle.adf.model.BindingContext;

import oracle.adf.model.binding.DCBindingContainer;

import oracle.adf.model.events.EventDispatcher;

import oracle.adf.share.logging.ADFLogger;

import oracle.adf.view.rich.context.AdfFacesContext;

import oracle.jbo.uicli.binding.JUEventBinding;

public class WrapperEvent {

private ADFLogger logger = ADFLogger.createADFLogger(WrapperEvent.class);

public void sendEvent() {

logger.finer("Getting the return object");

AdfFacesContext fctx =

AdfFacesContext.getCurrentInstance();

Map<String, Object> pfs = fctx.getPageFlowScope();

Object btfReturnValue = pfs.get("btfReturnValue");

logger.fine("Got object " + btfReturnValue.toString() + ", ready to send event");

DCBindingContainer bc =

(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

JUEventBinding evtBind = (JUEventBinding)bc.get("WrapperEventBinding");

EventDispatcher eventDispatcher = bc.getEventDispatcher();

logger.finer("Event ready, payload: " + btfReturnValue);

bc.getEventDispatcher().queueEvent(evtBind, btfReturnValue);

bc.getEventDispatcher().processContextualEvents();

10 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

logger.finer("Wrapper done sending event");

btfReturnValue
WrapperEventBinding

<task-flow-call id="popup-flow">

<task-flow-reference>

<document>/WEB-INF/popup-flow.xml</document>

<id>popup-flow</id>

</task-flow-reference>

<return-value id="__3">

<name>popupReturn</name>

<value>#{pageFlowScope.btfReturnValue}</value>

</return-value>

</task-flow-call>

11 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

<bindings>

<action id="sendEvent" RequiresUpdateModel="true" Action="invokeMethod"

MethodName="sendEvent" IsViewObjectMethod="false"

DataControl="WrapperEvent"

InstanceName="WrapperEvent.dataProvider"/>

<eventBinding id="WrapperEventBinding">

<events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">

<event name="wrapperEvent"/>

</events>

</eventBinding>

</bindings>

package com.vesterli.demo.popupapp1.view.beans;

import javax.faces.component.UIComponent;

import javax.faces.context.FacesContext;

import oracle.adf.share.logging.ADFLogger;

import oracle.adf.view.rich.component.rich.RichPopup;

12 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

import oracle.adf.view.rich.component.rich.fragment.RichRegion;

import oracle.adf.view.rich.event.RegionNavigationEvent;

import oracle.adf.view.rich.render.ClientEvent;

import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;

import org.apache.myfaces.trinidad.util.Service;

public class PopupHandler {

private ADFLogger logger = ADFLogger.createADFLogger(PopupHandler.class);

private String popupTaskFlowId = "/WEB-INF/wrapper-flow.xml#wrapper-flow";

private String taskFlowId = "";

private String emptyTaskFlowId = "";

public String getDynamicTaskFlowId() {

if (taskFlowId != null)

return taskFlowId;

else

return getEmptyTaskFlowId();

public void setDynamicTaskFlowId(String newTaskFlowId) {

taskFlowId = newTaskFlowId;

public String getEmptyTaskFlowId() {

return emptyTaskFlowId;

public String getPopupTaskFlowId() {

return popupTaskFlowId;

public void regionNavigationListener(RegionNavigationEvent event) {

logger.fine("Handling region nav event");

String newViewId = event.getNewViewId();

// null new view id indicates the taskflow has ended

if (newViewId == null) {

RichRegion region = (RichRegion)event.getSource();

13 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

// 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();");

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");

logger.finer("Swapping Empty Taskflow on popupClosed for " + popupId);

14 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

<af:popup id="p1" contentDelivery="lazyUncached">

<af:setPropertyListener

from="#{viewScope.PopupHandlerBean.popupTaskFlowId}"

to="#{viewScope.PopupHandlerBean.dynamicTaskFlowId}"

type="popupFetch"/>

<af:panelWindow id="pw1" title="Popup demo" modal="true">

<af:region value="#{bindings.dynamicRegion1.regionModel}" id="r1"

regionNavigationListener=

"#{viewScope.PopupHandlerBean.regionNavigationListener}"/>

</af:panelWindow>

<af:clientListener method="popupClosedListener" type="popupClosed"/>

<af:serverListener type="serverPopupClosed"

method="#{viewScope.PopupHandlerBean.swapEmptyTaskFlow}"/>

</af:popup>

serverPopupClosed

15 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

<af:resource type="javascript">

function popupClosedListener(event) {

var source = event.getSource();

var popupId = source.getClientId();

var params = {

};

params['popupId'] = popupId;

var type = "serverPopupClosed";

var immediate = true;

AdfCustomEvent.queue(source, type, params, immediate);

</af:resource>

package com.vesterli.demo.popupapp1.view.beans;

import java.util.Map;

import oracle.adf.share.logging.ADFLogger;

import oracle.adf.view.rich.context.AdfFacesContext;

public class EventHandler {

private ADFLogger logger = ADFLogger.createADFLogger(EventHandler.class);

public void handleEvent(Object payload) {

logger.fine("Handling event, payload=" + payload);

16 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

Row row = (Row)payload;

Number DeptNo = (Number)row.getAttribute("DepartmentId");

String DeptName = (String)row.getAttribute("DepartmentName");

AdfFacesContext fctx = AdfFacesContext.getCurrentInstance();

Map<String, Object> pfs = fctx.getPageFlowScope();

pfs.put("DepartmentId", DeptNo);

pfs.put("DepartmentName", DeptName);

<methodAction id="handleEvent" InstanceName="EventHandler.dataProvider"

DataControl="EventHandler" RequiresUpdateModel="true"

Action="invokeMethod" MethodName="handleEvent"

IsViewObjectMethod="false">

<NamedData NDName="payload" NDValue="${payLoad}"

NDType="java.lang.Object"/>

</methodAction>

${payLoad}

<eventMap xmlns="http://xmlns.oracle.com/adfm/contextualEvent">

<event name="wrapperEvent">

<producer region="*">

<consumer handler="handleEvent"/>

</producer>

17 of 18 2/10/2017 7:32 PM
Running an ADF Task Flow in a Popup - Oracle Wiki - Oracle - Toad World http://www.toadworld.com/platforms/oracle/w/wiki/11169.running-an-ad...

</event>

</eventMap>

wrapperEvent

18 of 18 2/10/2017 7:32 PM

Вам также может понравиться