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

Similar Messages

  • Programatically raise Contextual Event from a ClientEvent

    Hi,
    JDev v11.1.2.0.0.
    Earlier I had a event raised on the value change of my inputText component. But due to certain requirement, I had to discard the valueChange and had to do that same logic using clientListener and serverListener. But the problem now is, the contextual event is not getting raised and I'm looking for a way to raise the specific event on the ClientEvent method that is bound to the serverListener on my fragment.
    I've checked lot of blogs but most of it are talking about raising the event programatically on ValueChange or ActionEvent. Any thoughts? Appreciate any help on this. Thanks !
    Edited by: 119413 on Mar 14, 2013 10:29 AM

    Ok. Finally, I ended up invoking a hidden button click action in my client listener and raised the event from the ActionEvent bound to that button. Let me know if anyone could think of better options.. Thanks !
    Edited by: 119413 on Mar 15, 2013 10:40 AM
    Edited by: 119413 on Mar 15, 2013 10:41 AM

  • [SOLVED] Triggering a contextual event programatically

    Hi,
    Is it possible to raise a contextual event from within a managed bean code, without transforming that bean into a data control and defining a methodAction?
    Thanks,
    ~ Simon

    Hi again,
    I found it myself (thanks to decompilation), the required code is
    BindingContainer.getEventDispatcher().queueEvent(EventProducer producer, Object payload);Well I still need to figure out the exact semantic of the value returned by EventProducer.getEventDefinitionsList(), but hopefully I'm going to find that soon.
    Regards,
    ~ Simon

  • Contextual Event refresh/redraw issue between 2 regions (taskflow w/ jsffs)

    Working on JDev 11.1.1.2.0
    I have one jspx
    which contains 2 regions - bounded taskflow with jsffs
    Now, I want to communicate between region1 and region2
    so, producer is : region2pageDef and consumer is: region1pageDef, and Handler is pointing to a Java Bean Data Control , listening for ActionEvent
    Contextual events works fine as expected , but when region1 listenes the contextual event , at that time entire jsff gets refreshed / redrawn, why?
    How contextual event works from the ADF side ,and what causes it to redraw the page fragment
    Thanks

    When I have 3 dynamic regions on a jspx page, where every region loads taskFlow with jsff page.
    One of the pages produces the contextual event, the other receives the contextual event and the 3rd one does nothing.
    Then 3rd region is not refreshed. It works correctly.
    But when I place eventMap in the pageDef of the jspx page, then all regions are refreshed no matter if they receive the contextual event.
    This is not the right way. Why is that? Do you have an idea?
    I am using JDev 11.1.1.3.0
    Edited by: Nikolay Minchev on Dec 22, 2010 2:44 AM

  • 11g: Contextual Events - How do I fire them on currency change?

    Hi!
    After posting a question here: 11g: Bounded task flows, need help and advice!
    I read the article at http://technology.amis.nl/blog/3365/adf-11g-how-events-in-one-region-cause-other-regions-to-refresh because I need to refresh region B when the user selects in region A.
    Now, the comments in that article suggest that Contextual Events are the built-in mechanism for that use case. So I tried that first. The online help suggests that this is what I need.
    I read the online help and created an event and defined a producer and consumer in the event map in the parent page's page def. Now the help shows how to fire the event when a methodAction binding is executed. But I need to fire the event when the user selects a row in region A's table.
    1. How do I do that? Where do I put the event? The help says it's possible, but does not show how. Add a selection listener to the backing bean and call the event-enabled methodAction binding from there? Or is there a better way?
    2. I get the impression, that - when I use the event to call the consumer's binding ExecuteWithParams method - just the query of the consumer's VO is executed. That's great. But how do I reset the flow to the initial action? Just refreshing the VO is not enough. I need to reset the flow to the initial action (showing a view).
    I read http://www.oracle.com/technology/products/jdev/tips/fnimphius/taskflow_in_popup/taskflow_in_popup.html and now I am completely confused. Use input parameters or use events? If I use events, how do I reset (refresh) the task flows?
    Thanks,
    Sascha
    Edited by: Sascha Herrmann on Oct 19, 2008 3:33 PM

    Sascha,
    are region A and B share the same transaction ? If yes and the content in region B is a dependency of the VO used in A then you don't need contextual events at all. So if i assume that region A contains a list of departments and region B the employee table (where DepartmentsVO is the parent of EmployeeVO) then you can do as follows
    - navigate to the region definition of region B in the pageDef file
    - use the right mouse context menu to add parameters, and then a parameter (e.g. changeIndicator)
    - wire the changeIndicator parameter to the DepartmentsVOIter current row key str (its a method exposed directly on the iterator)
    - set the region binding refresh to ifNeeded
    - set a partial trigger on the regionB to point to the departmentTable so the region is refreshed whenever the table row currency changes
    The parameter that you added just does nothing except that it indicates to the region binding that the region must refresh. You point it to the row row key of the department iterator because it provides the changed value.
    If VO in regionB is not dependent on the DepartmentVO, then you need to create a parameter on the bounded taskflow, which takes the value of changeIndicator to write it to pageFlowScope.currRowKey. Then create a set currentRowWithKey method as a default activity and wire it up to pageFlowScope.currRowKey
    Frank

  • Contextual Event on row selection in the table

    Hi,
    My taskflow has just a view activity which queries a view object and displays results as a table. This taskflow is inserted in the main page as a region. I have set up a selection listener on the table, to map to a method in a managed bean. I have made this method binding a producer of my contextual event. and another method binding on the main page as a consumer. I have mapped producer and the consumer on a event map on the main page.
    My problem is when a row is selected in the table, I see the method (in the selection listener) is called but the event is not fired and the consumer method is not called. I don't know, if it is because the producer method (selection listener) takes SelectionEvent as a parameter?.
    I added just to test, a button on my view activity and mapped the action listener to another method(with out parameters) on the same managed bean and made this a producer. In this situation the event got fired and the consumer method got called.
    Why is the selection listener method not firing the event?
    Thanks in advance.

    Hi,
    the two events that are supported for ADF Faces component events are ActionEvent and ValueChangeEvent. So if you have a selection event, you need to take this infromation and create an ActionEvent from it.
    http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/faces/event/ActionEvent.html
    Frank

  • Contextual event in reverse direction ( from child TF to parent view )

    Hi ,
    It seems all example of Contextual events talk about mirroring input value from Parent page to Child TF running in a region and there are numerous examples out there.
    What I wanted to accomplish was that an lov in a child TF triggers a contextual event and the parent TF takes the selected list of values. It needs to conduct a search based on these values and than mark the rows in a (tree)table.
    What has succeeded is almost all aspects of this. I can fire the event and receive it successfully. But the problem is the the backingBean class that I create via EL is not binded to my parent pages components. The treetable component returns null.
    My handler code (the handler code from the bean which you use to create the data control to listen to the cntxtual event) is almost 1:1 to as the code from the book "Oracle Fusion Developer Guide: Building Rich Internet Applications with Oracle ADF Business Components and Oracle ADF Faces", Chapter 6, page 210.
    public void receiveEvent(
    DCBindingContainerValueChangeEvent incomingPayload){
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    Application app = fctx.getApplication();
    ExpressionFactory exprFactory = app.getExpressionFactory();
    ValueExpression valExpr = exprFactory.createValueExpression(
    elctx,
    //reference the managed bean that holds the mirror value
    //property displayed in the input text field
    "#{backingBeanScope.ConsumerBackingBean}",
    Object.class);
    ConsumerBackingBean consumer = null;
    consumer = (ConsumerBackingBean)valExpr.getValue(elctx);
    //get the changed attribute value from the contextual event
    //payload
    String newValue = (String)incomingPayload.getNewValue();
    //set the new value to the backing bean property that is
    //referenced by the input text field in View 3
    consumer.setMirrorValue(newValue);
    AdfFacesContext adffacesContext = null;
    adffacesContext = AdfFacesContext.getCurrentInstance();
    //partially update the text field to display the new value
    adffacesContext.addPartialTarget(consumer.getMirrorTxt());
    The #{backingBeanScope.ConsumerBackingBean} evaluates in my case to fine. But every component I should see as binding in the bean is null.
    Since the handler is declared in the pageDef of this parent page Fragment, i assumed the last bit about it being able to get to the backing bean and hence to my components should also be possible.
    If I cant refresh my components than I dont see the use of the contextual frameworks for me.

    You should find this post useful: http://flexponential.com/2010/12/05/saving-scroll-position-between-views-in-a-mobile-flex- application/
    It demonstrates one way of saving and restoring data when pushing and popping a view.

  • Contextual event on table not triggered

    Using Jdev PS4.
    Concider following example: http://www.yonaweb.be/ContextualEvent.zip
    (I know following example can be simplified by using master-detail relation in the data control but it's to illustrate the example)
    I have two taskflows: EmployeeTF and departmentTf.
    The idea is to trigger an event when I select a new record in the department table.
    This is the tree binding:
    <tree IterBinding="DepartmentsIterator" id="Departments">
          <nodeDefinition DefName="model.views.DepartmentsView" Name="Departments0">
            <AttrNames>
              <Item Value="DepartmentId"/>
              <Item Value="DepartmentName"/>
              <Item Value="ManagerId"/>
              <Item Value="LocationId"/>
            </AttrNames>
            <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
              <event name="changeTheDept"
                     customPayLoad="${bindings.DepartmentId.inputValue}"
                     eventType="Currency Change Event"/>
            </events>
          </nodeDefinition>
        </tree> I have created a custom java class to use as a data control to find out when the event is triggered. This is my code:
        public void handleEvent(Object payload){
            System.out.println("Event handler");
            System.out.println(payload);
        }When I select a record in the table, the event does not get fired.
    So as a test I added my own custom method to see if contextual events are working properly so I added this method to my DC:
        public void triggerEvent(){
            System.out.println("triggering event");
        }and added it on a commandLink to the DepartmentTF. I also added an event on it:
    <methodAction id="triggerEvent" RequiresUpdateModel="true"
                      Action="invokeMethod" MethodName="triggerEvent"
                      IsViewObjectMethod="false" DataControl="EmpBean"
                      InstanceName="EmpBean.dataProvider">
          <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
            <event name="triggerEvent"
                   customPayLoad="#{bindings.DepartmentId.inputValue}"/>
          </events>
        </methodAction>When I trigger this event, my event handler does get called on the employee taskflow.
    So, my question is:
    1) Is this normal behavior that the change row event is not triggered?
    2) if yes, how do I trigger it or what is the purpose of this event?
    Edited by: Yannick Ongena on May 28, 2012 9:03 PM

    I have a similar circumstance: I have a page with two regions, each region contains a table. The two tables share some information so when I update one of them
    I also want the change to be reflected in the other table. I tried to use contextual events to send an event that causes one of the tables to refresh (I do not pass any payload)
    but so far I have not had any success with making this work. I am wondering if the bug you mentioned here would also prevent such a setup to work? I am using Jdev 11g R1 11.1.1.6.2.

  • 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

  • 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});

  • Contextual event - handler called before producer bean's setter

    I am trying a simple contextual events usecase:
    Page A.jsff has an input text field whose value is directly stored in a bean variable (bean is in pageFlowScope). Contextual event is defined on value change event for this input field. A.jsff has taskflow B_btf as an embedded region.This B_btf will simply display the value entered in the A.jsff. So, when contextual event is raised, the handler sets the value in a local variable of B_btf bean. The problem is that the handler method is getting called before the setter for the attribute of the bean of A.jsff. This is resulting in the B_btf displaying the last-but-one value entered in the input field of A.jsff instead of the current/latest value. Any tips?
    Thanks,
    Amitabh

    The issue was with the (lack of) understanding of the JSF lifecycle. The value change listener is called during the Process Validation phase, whereas the managed bean (Model) values will be set in the Update Model phase which lies next-in-line after Process Validation phase. Hence, if the value change listener is to be used, then the handler code should have used the default payload and not the custom payload. For a value change event the default payLoad will be a DCBindingContainerValueChangeEvent, and one can invoke getNewValue() to get the value entered in the text field (For details watch Frank Nimphius' video here: ADF Region Interaction - Contextual Events - YouTube). For my case, I added a command button to the page, and moved the contextual event to that button.

  • Question about the Contextual Event from task flow to portlet

    Hello, experts,
    I am studying the webcenter portlet and 11g Task flow. in fact i have tested on the Jdev TP4 about the portlet communication.
    As we know, in 11g ADF task flow, can communicate via contextual events. My issue is if I use the bridge to convert task flows to portlets, How can I still make the contextual event communication works in portlets.. If not what is the best way to keep these converted portlets communicated? (I test it on TP4 but failed.)
    Or I can not do this by task flow way, i need to rebuild my portlet in webcenter and use the portlet parameters in web center to let portlets communicate? Is there way can transfer the inter-taskflow communication to the portlets communication after they are converted to portles via bridge? Can new version 11g webcenter support this?
    Seems very hard, I appreciate your web center development experts can enlight on this.
    Thanks
    Wayne

    Up.. Any expert can answer?

  • 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

  • Disclosure Listener for PanelTabbed

    Hi All
    <<Jdeveloper 11.1.2.3.>>
    I have a paneltabbed component with 5 tabs (show detail item). My scenario is Every-time user clicks on a tab I need to perform same set of tasks (like refreshing the VO to check for new data).
    Only If the user selects Tab3 then the logic executed is different.
    What is the best of achieving this.
    Do I need to write a disclosure listener for every single tab or I can have a same disclosure listener for 4 tabs which does same action and one other disclosure listener for Tab3.
    Kindly guide me with the correct approach.
    regards,
    bnkr

    Hi,
    Here is the sample code with only one disclosure event for all tabs with condition inside to check which tag is disclosed:
    <af:panelTabbed id="pt1">
    <af:showDetailItem text="Tab 1" id="sdi1"
         disclosureListener="#{<Bean>.tabDisclosed}">
        <af:outputText value="Tab 1 Contents" id="ot1"/>
        <af:clientAttribute name="disclosedTab" value="Tab1"/>        
    </af:showDetailItem>
    <af:showDetailItem text="Tab 2" id="sdi2"
         disclosureListener="#{<Bean>.tabDisclosed}">
        <af:outputText value="Tab 2 Contents" id="ot2"/>
        <af:clientAttribute name="disclosedTab" value="Tab2"/>        
    </af:showDetailItem>              
    <af:showDetailItem text="Tab 3" id="sdi3"
         disclosureListener="#{<Bean>.tabDisclosed}">
        <af:outputText value="Tab 3 Contents" id="ot3"/>
        <af:clientAttribute name="disclosedTab" value="Tab3"/>        
    </af:showDetailItem>
    </af:panelTabbed>
    // Bean Code
        public void tabDisclosed(DisclosureEvent disclosureEvent){
            if (disclosureEvent.isExpanded() == true) {          
                if(disclosureEvent.getComponent().getAttributes().get("disclosedTab").equals("Tab3")){
                    //TODO Code when Tab 3 is disclosed              
                }else{
                    //TODO Code for other tabs
    Note that af:clientAttribute is set for each showDetailItem where we pass the value for disclosedTab attribute to identify which tab is disclosed
    Sireesha

  • 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!

Maybe you are looking for