2 Replies Latest reply: Jul 9, 2009 4:17 AM by Lucas Jellema RSS

    Programmatically publishing Contextual Events

    Lucas Jellema
      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.


        • 1. Re: Programmatically publishing Contextual Events
          Frank Nimphius-Oracle

          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"
             <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
               <event name="mActionEvent"/>
          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();
          • 2. Re: Programmatically publishing Contextual Events
            Lucas Jellema
            Hi Frank,

            Thanks for your reply. I was NOT aware of this solution - at least not the eventBinding. I did know about the solutionof creating an actionBinding/methodBinding that was only meant for triggering the event.

            However, I was hoping to get by without a PageDefinition with 'fake' Data Bindings to produce an event. I have a task flow that only uses managed beans and does not currently have a page definition, data bindings etc. This solution you also propose seems very heavy handed for just publishing an event. You do not happen to know of a lighter weight approach? I am wondering why I would need a page definition and data bindings to raise an event. Any further thoughts?



            Edited by: Lucas Jellema on Jul 9, 2009 6:15 AM - note that eventBinding was new to me (I had read sloppily and only noticed the use of the PageDef with special bindings that I tried to avoid).