Programmatically publishing Contextual Events

Does anyone know whether there is a programmatic way of publishing contextual events? The usual route of course involves invoking an operationBinding or updating an attributeValueBinding, but those seem some what complex ways of publishing an event if you would want to do so from for example a serverListener or some other part of managed bean logic.
thanks.
Lucas

Lucas,
Below is an event producer binding and the code that invokes it from an ADF Faces button. If you call the same from a managed bean then you need to create the
ActionEvent manually before you invoke it
<eventBinding id="MyEventBinding"
   Listener="javax.faces.event.ActionListener">
   <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
     <event name="mActionEvent"/>
   </events>
</eventBinding>
public void onEmployeeSelect(ActionEvent actionEvent) {
  BindingContext bctx = BindingContext.getCurrent();
  BindingContainer bindings = bctx.getCurrentBindingsEntry();
  JUEventBinding eventBinding = null;
  //get a handle to the eventBinding
  eventBinding = (JUEventBinding) bindings.get(“MyEventBinding”);
  ActionListener al = (ActionListener)eventBinding.getListener();
  al.processAction(actionEvent);
}Frank

Similar Messages

  • How to publish contextual event from dynamic region

    Hi Experts, plz help.
    Scenario :
    I have a page , say Page A.
    I have two bounded task flows, say HeaderTF and LinesTF.
    HeaderTF is placed as a static Region in page A and LinesTF is a dynamic region in page A.
    LinesTF has a table with Amount Column.
    HeaderTF has a text field which shows the total of amount column.
    Requirement :
    when user adds new rows or changes existing rows or deletes any rows in LinesTF, total field in HeaderTF should be updated.
    On change of amount value in lines, I am calculating and updating the total attribute of header VO as all of them are sharing same DC.
    but the value is not reflecting becos partial triggers cannot be kept for total field.
    So I am using contextual events.
    I created a contextual events for amount field, delete button and table as well (In LinesTF).
    and I created handler method in AM which calculates total and dragged it as a text field in HeaderTF.
    Now when I am trying to subscribe from pagedef of pageA, i am able to find the handler which is created in HeaderTF but could not find any contextual events in event lov.
    Question :
    1. Is my approach correct?
    2. Cant we publish contextual events from dynamic regions?
    3. Is there any alternate way of achieving this?
    I did not try refreshing HeaderTF by passing input params because I dont want the entire region to be refreshed.

    Try creating the event mapping - please see "28.7.2 How to Create Contextual Events Manually" in Dev Guide http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/web_adv.htm#CACJBFGI

  • Contextual Event question (Currency Change Event)

    Hello,
    I have published a contextual event on my table (Currency Change Event)
    I also have a SelectionListener on the same table.
    Will I have to manually/programmatically publish the event within the selection listener code? (and if so, how?)
    The reason I ask is that I practiced with a small app containing a region from an ADF library that handled currency change event from the referenced task flow and everything was great, but now I am trying to apply the same principles to my "proper" application and there is no currency change event being received in the parent application.
    I had a look at Andrejus example (http://andrejusb.blogspot.co.uk/2010/10/contextual-events-framework-and-adf-11g.html) but he has hand crafted the events on the page binding will I have to do that too? Is it not enough that I have the currency change event declared?
    Any help appreciated, thanks
    JDeveloper 11.1.2.2

    I've applied the same processing to another table that uses the standard collectionModel.makeCurrent selection listener and it's firing the contextual event handler in the parent application, so that almost confirms that it's the bespoke selection listener that needs code adding to it to invoke the currency change event
    edit :
    I added this code to invoke the makeCurrent and everything is ok again, thanks for listening
    FacesContext fc = FacesContext.getCurrentInstance();
    ELContext elContext = fc.getELContext();
    ExpressionFactory ef =
    fc.getApplication().getExpressionFactory();
    MethodExpression meth = ef.createMethodExpression(elContext, "#{bindings.partnersVO1.collectionModel.makeCurrent}", Object.class, new Class[]{SelectionEvent.class});
    meth.invoke(elContext, new Object[]{selectionEvent});

  • Programmatic Navigation invoked by Contextual Events

    Using JDeveloper 11.1.1.3.0
    I'm having trouble doing a programmatic navigation triggered by a contextual event in the case of layered bounded taskflows.
    My scenario has 2+ taskflows.
    TaskFlow 1: BoundedTF called Main-Task-Flow - This is the starting URL invoked to run.
    TaskFlow 2: BoundedTF called Dashboard-Task-Flow - This is the default activity in the Main-Task-Flow
    Both of these does not use page fragments.
    Dashboard-Task-Flow has a page, let's call this Dashboard.jspx which registers a contextEventMap. This map basically utilizes a NavigationHandler to navigate to a TaskFlowReturn activity.
    Return activity is registered in the Main-Task-Flow to navigate to different taskflows.
    I noticed, that only when i call this navigation case using contextEvent, i am getting an invalid view port. Which starts with these:
    <UNMATCHED_STATE_ON_STACK><v5hztfeem_0> v5hztfeem_15
    <RegistrationConfigurator><handleError> Server Exception during PPR, #1
    javax.servlet.ServletException: ADFC-14000: View port ID 'v5hztfeem_15' is invalid.
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    etc...
    Caused by: oracle.adf.controller.internal.InvalidViewPortIdException: ADFC-14000: View port ID 'v5hztfeem_15' is invalid.
         at oracle.adfinternal.controller.state.ControllerState.setCurrentViewPort(ControllerState.java:1245)
         at oracle.adfinternal.controller.ControllerContextImpl.setCurrentViewPort(ControllerContextImpl.java:133)
         at oracle.adfinternal.controller.ControllerContextImpl.setCurrentViewPort(ControllerContextImpl.java:52)
    etc....
    I've been trying to figure if it was coding wise, but i simply use the NavigationHandler being triggered by a button then it works.
    So i tried something else, i placed the Dashboard.jspx directly in Main-Task-Flow and this issue is gone. I tried debugging the currentView and it all prints correct that i'm in Dashboard.jspx.
    I wonder if i'm doing something wrong here. I tried searching for this exception and i barely find any information about it.

    Thanks for the reply,
    I am currently using the 2nd mechanism for accessing the bean which contains the bindings of the page components (e.g panelTabbed).
    What I want is to do it in the same bean, without the need of resolving expressions (now I can resolve the expression ${beanName.panelTabbed}) - I think there should be a cleaner way.
    There's got to be a way to consume the contextual event in the same binding context!

  • Programmatic Contextual Events - binded components are null

    Dear ADF/Webcenter gurus,
    I am publishing and consuming a contextual event programatically in separate taskflows and managed beans.
    The wiring of consumer and publisher is established runtime via WebCenter composer (my taskflows are published as jar, but I think this does not regard the problem below).
    Problem is, in the consumer method of the bean, I cannot access any binded coponents.
    I suppose this is because when the bean receives the contextual event it doesn't know in which binding context the page is.
    For now, my solution is: create seperate bean for consuming the event, get the page bean by createValueExpression(#{beanName}); and call the desired beanName.method to go on.
    It works, but I want to be able to consume the event and acces binded components in the same bean.
    I have the same issue when programatically firing event (binded components == null).
    Waiting your ideas, Todor

    Thanks for the reply,
    I am currently using the 2nd mechanism for accessing the bean which contains the bindings of the page components (e.g panelTabbed).
    What I want is to do it in the same bean, without the need of resolving expressions (now I can resolve the expression ${beanName.panelTabbed}) - I think there should be a cleaner way.
    There's got to be a way to consume the contextual event in the same binding context!

  • Contextual Event - "Currency Change Event" not raised?

    Hey,
    I am trying to raise contextual event on a table when I click on a row. The event type for a table is eventType="Currency Change Event" But is not working.
    Here is the event in the PageDef file.
    <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
    <event name="paramValueChangedEvent"
    customPayLoad="${bindings.PolicyId.inputValue}"
    eventType="Currency Change Event"/>
    </events>
    After that I want to raise custom method:
    <methodAction id="testEvent" InstanceName="myBean.dataProvider"
    DataControl="myBean" RequiresUpdateModel="true"
    Action="invokeMethod" MethodName="testEvent"
    IsViewObjectMethod="false"/>
    Here is the event map:
    <eventMap xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
    <event name="paramValueChangedEvent">
    <producer region="*">
    <consumer region="" handler="testEvent" handleCondition=""/>
    </producer>
    </event>
    </eventMap>
    When I raise the event programmatically, then the event is raised and my function is called.
    Here is the code. I call this function on a custom selection listener of the table.
    public void riseCurrencyChangeEvent(String treeID, String nodeID,
    String attributeValuedPassedName) {
    DCBindingContainer bc = ADFFacesUtils.getDCBindingContainer();
    FacesCtrlHierBinding tbl =
    (FacesCtrlHierBinding)bc.findCtrlBinding(treeID);
    FacesCtrlHierNodeBinding node =
    (FacesCtrlHierNodeBinding)bc.findCtrlBinding(nodeID);
    EventDispatcher dispatcher = bc.getEventDispatcher();
    node = (FacesCtrlHierNodeBinding)tbl.getRootNodeBinding();
    dispatcher.queueEvent(node.getEventProducer(),
    node.getCurrentRow().getAttribute(attributeValuedPassedName));
    bc.getEventDispatcher().processContextualEvents();
    My idea is not to call custom method after clicking on a table row, but I want to raise declaratively the event because I will need so generics.

    Hi,
    there is a bug 10045872 filed for this. The bug is scheduled for fixing in PS4 (11.1.1.5) I'll work on a manual - though code centric - alternative for the time being and publish it on ADF Code Corner when done.
    Frank

  • Need a Small & Simple example to demo Contextual Event Framework

    Hi,
    As I'm tired of trying to understand Contextual Event Framework from Dev Guide & various sites in NET.
    So finally came here to find an answer from a good developer.
    My goal is to know Contextual Event Framework, with a very simple (or Simplest) example possible.
    Scenario# I have a Producer.jsff page that has an InputTextBox.
    I want to give an input into this Box say "Welcome To CEF" & using CEF I want to Display this value in consumer.jsff page.
    Both producer.jsff & consumer.jsff are in one CEFDemoTF.xml
    And this TaskFlow is in CEFDemoPage.jspx.
    Now I want to know where should I create Event Map.. and Publish & consume event to display the text "Welcome To CEF" in consumer.jsff page.
    Thanks in Advance.

    Oracle Magazine had an article about this: http://www.oracle.com/technetwork/issue-archive/2011/11-may/o31adf-352561.html
    Timo

  • Programatic Contextual Event on Disclosure Listener - jdev 11.1.2.3

    Hello:
    I want to programatically fire a contextual event from a DisclosureListener(when a showDetailItem is disclosed in tabbed panel). When I detect the tab is opened I want to publish the Contextual Event.
    See code below
    It compiles ok, but the error I get is:
    oracle.jbo.uicli.binding.JUEventBinding cannot be cast to oracle.binding.ControlBinding
    What am I missing here???
    Thanks for the help...
    ===============================================================
    package com.xxx.dbmstr.sbe.view.beans;
    import com.xxx.ptnr.cc.uc1.common.JSFUtils;
    import javax.faces.event.ActionEvent;
    import javax.faces.event.ActionListener;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.binding.BindingContainer;
    import oracle.jbo.domain.Number;
    import oracle.jbo.uicli.binding.JUCtrlActionBinding;
    import oracle.jbo.uicli.binding.JUEventBinding;
    import org.apache.myfaces.trinidad.event.DisclosureEvent;
    public class DBMstrTabs {
    private String isOpen = "QA";
    public DBMstrTabs() {
    super();
    public void doCE(){
    SBEPayload p = (SBEPayload) JSFUtils.getManagedBeanValue("SBEPayloadBean");
    if (p == null){
    p = new SBEPayload();
    Number empKey = (Number)JSFUtils.resolveExpression("#{bindings.empKey_t.inputValue}");
    p.setEmpKey(empKey);
    JSFUtils.setManagedBeanValue("SBEPayloadBean", p);
    DCBindingContainer bc = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
    JUCtrlActionBinding actionBnd = (JUCtrlActionBinding) bc.getControlBinding("eventBinding");
    ((DCBindingContainer)bc).getEventDispatcher().queueEvent(actionBnd.getEventProducer(),p);
    ((DCBindingContainer)bc).getEventDispatcher().processContextualEvents();
    public void checkQA(DisclosureEvent disclosureEvent) {
    if (disclosureEvent.isExpanded()){
    setIsOpen("QA");
    doCE();
    public void checkSTANDARDS(DisclosureEvent disclosureEvent) {
    if (disclosureEvent.isExpanded()){
    setIsOpen("STANDARDS");
    doCE();
    }

    Here is a small work around that might help until an ideal solution is discovered. Since the CE ActionEvent can be easily created declaratively, you can fake an producer event by programatically queuing an ActionEvent on a button binding from the disclosurelistener.
    fragment code:
    <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:panelAccordion id="pa1">
        <af:showDetailItem text="showDetailItem 1" id="sdi1" disclosureListener="#{TesterBean.tabdisclosed}"/>
        <af:showDetailItem text="showDetailItem 2" id="sdi2"/>
      </af:panelAccordion>
      <af:commandButton text="commandButton 1" id="cb1" binding="#{TesterBean.buttonbinding}"
                        actionListener="#{bindings.eventBinding.listener.processAction}" visible="false"/>
    </ui:composition>Backing Bean code:
    public class TesterBean {
        private RichCommandButton buttonbinding;
        private String helloStr;
        public void tabdisclosed(DisclosureEvent disclosureEvent) {
            ActionEvent actionEvent = new ActionEvent(buttonbinding);
            actionEvent.queue();
        public String getHelloStr() {
            return helloStr; //invoked when the CE is fired
    ...pageDef code:
    <eventBinding id="eventBinding" Listener="javax.faces.event.ActionListener">
          <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
            <event name="buttonCE" customPayLoad="#{TesterBean.helloStr}" eventType="Action Event"/>
          </events>
        </eventBinding>
      </bindings>
      <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
        <event name="buttonCE" customPayLoad="#{TesterBean.helloStr}" eventType="Action Event"/>
      </events>
    ...good luck

  • Multiple parameters in Contextual Event

    Hi All ,
    I am using JDev 11.1.1.6 and WLS 10.3.6
    I want to pass two parameters as customPayLoad in the contextual Event.
    I am accessing the payload in the subscriber through ${payLoad}
    Lets say I have employees table and on rowSelection I want to pass deptId as well as EmpId in the payLoad.
    How to achieve this?

    Hi,
    Please check Forum
    Passing multiple parameters through contextual events
    Navaneetha's comment.
    http://one-size-doesnt-fit-all.blogspot.com/2010/08/jdev-11g-programmatic-contextual-events.html
    Thanks,
    Jit

  • Capture Return Value from Contextual Events Subscriber Method

    Hi
    I was wondering if anyone knew whether you could capture the return value from a method exposed as  a subscriber for a contextual event?
    Requirement: We have 2 bounded task flows (parent-child) with the child task flow embedded as a region in a view activity in the parent task flow.  Based on an action in the parent task flow we raise a contextual event which calls an application module method exposed as a data control within the child task flow.  We need to be able to capture the return value from the method on the managed bean.
    Example method within child task flow application module:
    public String contextualEventSub(){
      Return "Y";
    So here we would like to capture String value when the event is raised by the event producer (parent task flow action).
    Within the Event Map on the page definition of the parent task flow view activity it is possible to set parameters to pass to the subscriber but it’s not obvious where you can capture the return value.
    Many thanks!
    Technology:
    ADF 11.1.1.7 – ADFbc with ADF task flows and page fragments

    Check this URL it may help you
    One size doesn't fit all: JDev 11g: Programmatic Contextual Events

  • Calling a method on backing bean in response to contextual event

    Hi
    I am using Jdeveloper 11.1.1.6.0 and using ADF contextual events..
    I have a drop down list and i am rasiing a contextual event on changing the current selection. In response to that event i want to call a backing bean method with parameters.. But when i click on the subscriber section for the contextual event, i can see only some bindings of the page.. How can i call a method on backing bean as a subscriber..
    Thanks
    Raghu

    Hi,
    this article has a use case for the POJO approach: http://www.oracle.com/technetwork/issue-archive/2011/11-may/o31adf-352561.html
    Another is to define a method binding in the receiving PageDef file and configure it as explained here
    http://java.net/projects/smuenchadf/pages/ADFSamplesBindings/revisions/3#SMU164
    Frank

  • Can I publish an event to more than one shared calendar in iCal?

    I have shared calendars (called "home") with my wife & kids and (called "Work") with my secretary at work so that my family can add home events and my secretary can add work things .
    I've done this as I don't want my secretary seeing when my kids have an appointment to see the doctor or my kids to see when I have appointments with clients at work etc.
    However some things (like when I've booked leave from work) need to be on both calendars.
    QUESTION: Can I publish one event (using OS X Yosemite or iOS8.2) to multiple calendars  ("home" & "work") in iCal?

    i generally hate toolbars because it makes the browser look cluttered and hogs memory. but u should ask an expert on this if it possible its not too easy, addons will probably help you, for example if you have the stumbleupon toolbar, there are addons that will create an extra button for you to put anywhare for quick access. this solution probably may not work with other less known addons.

  • Triggering Validation in a Region Through a Contextual Event

    I am using JDeveloper 11.1.1.6.0.
    I am trying to find out how to trigger the built in validation that occurs normally when a "submit" action occurs, but have the submit action occur outside of a region, and the validation also occur in the region itself.
    I have a page that contains a dynamic region in it. I will refer to the containing page as the parent and the region as the child. The parent region and child region both have different business objects bound to them, though they are part of the same application module. The parent page contains a submit button that needs commit the user entered data in both the parent and child pages. This action must not proceed if there are any validation errors in the parent or the child. The validation should trigger on the parent page without any work from me because of how ADF handles the situation. The child page is notified of the submit action via contextual events. I currently have it where this event can trigger the "commit" action successfully, but I have no idea how to go about ensuring that it triggers a validation check as well.
    The overall flow that I think will happen in the final version is likely:
    1: submit button pressed.
    2: parent page validation is checked (if success, proceed)
    3: contextual event is fired
    4: contextual event is received by the child.
    5: the child triggers its own validation (if success, proceed, else stop)
    6: the child triggers a commit action
    7: the child sends a response contextual event (signalling that it was successful)
    8: the parent receives the response contextual event
    9: the parent performs a "commit" action.
    I do not know how to cause step 5 to occur, and I do not know if steps 7 through 9 are needed yet (I haven't tested to see if causing the commit in either the parent or the child ends up causing all modified entity objects to be committed). Any help would be greatly appreciated.
    Thank you

    Hi,
    you can access a command button on the page fragment and queue its action event. For this you access a managed bean (backingBean Scope) that contains a handler to the command button and queue the event (this then will perform validation as if the user clicked it. The command button can also be hidden on the fragment.
    Have a look here for how you can integrate the managed bean as the contextual event handler
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/regionpayloadcallbackpattern-1865094.pdf
    Frank

  • Dynamic TaskFlow Gets Refreshed on Catching a Contextual Event

    Hi,
    I am using Contextual events in my application. I have 2 task flows in my parent page. One TF is raising an event and the other is catching it. As my catching TF is a dynamic TF, I have specified the event map in it only.
    Everything is working as intended only that my dynamic TF gets refreshed when it catches the event! I do not want that. I want to explicitly refresh any UI component that requires to be refreshed, not the whole TF.
    So is there any specific property of task flows that make it to refresh itself when ever it catches any contextual event?
    Also I have tried 'Refresh="ifNeeded"' and 'RefreshCondition="#{false}"' in my dynamic taskflow specification in the parent page but it does not make any difference.
    Regards,
    Rahul Saxena

    Rahul,
    there is no setting for this. If however the managed bean you setup for handling the dynamic region is in backing bean scope (or request scope) then chances are that the region is refreshed because the bean restes after the request (just assuming here). Yournot giving us much to chew on (no JDeveloper version, no implementation details etc. ) So its hard to provide further ideas. As a last resort, if you have a support contract, you can contact customer support with a test case
    Frank

  • Task Flow Exit Using contextual Events ??

    I am using Jdeveloper 11.1.1.5.
    My application has a page which has two regions in it.
    First region has a bounded task flow with just one fragment in it(Just with a button)
    and Second region has a BTF which has five fragments in it(which is a kind of train process).
    On clicking the button in the first region I want to exit and reenter the bounded Taskflow in the second region.I am trying to do this using contextual events but the exit and reentry doesn’t happen as expected.
    For example - if the user is in the third fragment of the second region and clicks the button in the first region, then the task flow should exit and the control should go to the first fragment in the second region.
    In the consumer method I am returning the “action” string which will call the “TaskFlow Return call” activity but the “TaskFlow return call is not being called.
    Could some one help me resolve this issue.
    Thanks in advance.
    - Pani

    I am using Jdeveloper 11.1.1.5.
    My application has a page which has two regions in it.
    First region has a bounded task flow with just one fragment in it(Just with a button)
    and Second region has a BTF which has five fragments in it(which is a kind of train process).
    On clicking the button in the first region I want to exit and reenter the bounded Taskflow in the second region.I am trying to do this using contextual events but the exit and reentry doesn’t happen as expected.
    For example - if the user is in the third fragment of the second region and clicks the button in the first region, then the task flow should exit and the control should go to the first fragment in the second region.
    In the consumer method I am returning the “action” string which will call the “TaskFlow Return call” activity but the “TaskFlow return call is not being called.
    Could some one help me resolve this issue.
    Thanks in advance.
    - Pani

Maybe you are looking for