1 2 Previous Next 16 Replies Latest reply: May 1, 2012 7:55 PM by 924424 RSS

    IPC Between Two ADF Portlets on Same Page using Events Failure

    924424
      Considering that a full page submit is required for the passing of parameters to work properly, I am trying to use IPC Events to pass a parameter from one ADF Portlet to another. There are no good examples out there, but I am trying to use what is out there in many different generic forms to make this happen with no success.

      One portlet contains an ADF Table with a select column, I have a BackingBean to process the choosing of a row and that value is being retrieved and I am calling the set event.

      public void selectPatient(ActionEvent e) {
      FacesCtrlHierNodeBinding node = (FacesCtrlHierNodeBinding) tblPatients.getSelectedRowData();
      String username = node.getAttribute(0).toString();
      System.out.println("Selected Patient: " + username);

      ActionResponse response = (ActionResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
      response.setEvent("selectPatientResult", username);
      }

      I then have a second portlet that is supposed to retrieve the value being passed from within the portlet class and then the second ADF portlet is supposed to display. I will eventually do more work with the value, but I am just trying to get the events to work properly first. Here is the code within the receiving portlet class:

      public class drugallergies extends ADFBridgePortlet {

      @ProcessEvent(name="selectPatientResult")
      public void processSelectPatientEvent(EventRequest request, EventResponse eventresponse) throws PortletException, IOException {
      Event event = request.getEvent();
      String username = (String)event.getValue();
      System.out.println("Selected Patient: " + username);
      eventresponse.setRenderParameter("patient", username);
      }
      }

      I have also made sure that I have put the following within my web.xml file for the application so that the events are being passed as portlet events and not faces events. I am still fairly new to ADF, but not to portals or portlets, which is why I am going this route.

      <context-param>
      <description>Allows for fired events to go to the portlet and not to the faces layer</description>
      <param-name>javax.portlet.faces.autoDispatchEvents</param-name>
      <param-value>false</param-value>
      </context-param>

      I am never seeing the receiving event get processed, meaning that I never see the println get processed with the receiving value. Please help because there are no examples out in the world for going this route. There are examples, but they require you to create an ADF application first and then convert the application to a portlet. I am using the Portlet Creation wizard within JDeveloper but creating ADF based pages for the Views modes.
        • 1. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
          Yannick Ongena
          I believe you are mixing the two techniques together.
          In your precessEvent method you are trying to set the renderParameter which is the method used to pass parameters from one portlet to another WITHOUT using events.

          In your case you want to add the parameter to the payload of the event.

          I have not yet written an example like this on my blog but it is on top of my list so you will probably get an example in the upcoming days...
          • 2. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
            924424
            According to the example within Portlets in Action, this is the way to make the payload available to the second portlet.

            Going back to the code the backing bean of Portlet A fires off the event and sets the payload to be a string, specifically a selected username.

            The processSelectPatientEvent method is then what is supposed to receive the event and it is within Portlet B's portlet class which extends AdfBridgePortlet. I am then setting a Render Parameter, which the ADF component inside of Portlet B is bound to through its backing bean. If there is a better way to make the payload available for use in Portlet B, I would certainly welcome the suggestion.

            That being said, it really doesn't matter, because the annotated processSelectPatientEvent method never gets fired by the setEvent method in Portlet A and that is where I am having problems. Why would the processing portlet never handle the event once it is fired, assuming that I have done everything correctly?
            • 3. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
              Yannick Ongena
              I believe this is the reason why your event is not fired:
              @ProcessEvent(name="selectPatientResult")

              WebCenter currently does not support annotations so it doesn't understand this...
              • 4. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                924424
                So where and how do I configure Portlet B to receive the fired event?
                • 5. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                  Yannick Ongena
                  This needs to be in your portlet class:
                  public void processEvent(EventRequest request,EventResponse response)
                  {    
                        Event event = request.getEvent();    
                        if(event.getName().equals(“changeCustomer”))      
                        {
                                //Do something
                         }
                  }
                  • 6. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                    924424
                    So for clarification sake, because WebCenter doesn't support the Annotations that the JSFPortletBridge requires for the use of events, it instead requires a processEvent function to be available and then you process each event within that function based on its name?
                    • 7. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                      Yannick Ongena
                      It's not just WebCenter. WebCenter is compliant against the JSR 286 standard. That standard does not say anything about annotation. It however specifies how to use the processEvent method to capture the event.

                      I guess that the annotation part comes in by using JSF 2.0 instead of using JSF 1.x as webCenter does.
                      JSF 2 comes also with annotations for managed beans and methods while in JSF 1.x you have to register them with the faces-config.xml.

                      So it's not really a WebCenter issue, it's just that webCenter currently does not support JSF 2.0.

                      If you deploy the portlets to a JSF 2.0 enabled portlet container, it might work with the annotations but when you deploy them to WebLogic 11g it will not work because it is not JSF 2.0 enabled...

                      Hope this clarifies.
                      • 8. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                        924424
                        Unfortunately, this didn't help the situation. Here is the code for the portlet class that is supposed to be processing the event:

                        public class drugallergies extends ADFBridgePortlet {

                        public void processEvent(EventRequest request, EventResponse eventresponse) throws PortletException, IOException {
                        System.out.println("Entered Process Event Function");
                        Event event = request.getEvent();
                        if(event.getName().equals("selectPatientEvent")){
                        String username = (String)event.getValue();
                        System.out.println("Selected Patient: " + username);
                        eventresponse.setRenderParameter("patient", username);
                        }
                        }
                        }

                        After I set the event in the code I provided at the top of this post and pass the payload, I am expecting that my portlet class will do something and I never see the processEvent function getting called. Any ideas?
                        • 9. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                          Yannick Ongena
                          You probably need to wire the events together which can be done in the contextual events section of the page bindings. Did you do that?
                          • 10. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                            924424
                            Why is this stuff not documented anywhere? Sorry, I am really frustrated with this. I have been working in portal software for 15 years and it has never been this hard to make portlets work together with either Plumtree or WLP.

                            I didn't think that you had to wire events together at the page level unless you were using Faces Events rather than Portlet Events.

                            I did not do that. I will try and find documentation that tells me how to do it, but could you point me in the right direction as well?
                            • 11. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                              924424
                              OK, so this isn't possible either because you can't wire portlet events on the page that they are being displayed. The Event Map Editor doesn't even work without some item on the page either having a contextual parameter or event assigned to it.

                              JSR286 combined with JSR301 and 329 are supposed to allow for Portlet events which are wired through the portlet.xml file only and then all of the transmission is done through the portlet layers, but I cannot find an example for this anywhere with respect to WebCenter. I am going to try and go the Contextual Event and Parameter route, but this is not following the standard and I am not finding any examples for this either.
                              • 12. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                                Yannick Ongena
                                It is working. I already wired portlets together that are events over the portlet bridge.
                                You are right about the documentation though... I already had a few discussions with people from Oracle saying the documentation is in many ways not optimal which can be frustrating, I know.

                                My days should really be longer than 24 hours. I want to write a post about this topic for so long but didn't managed to write one.
                                I already made a post about IPC based upon parameters (not events): http://yonaweb.be/inter_portlet_communication_jsr_286_and_webcenter_11g_ps3
                                Maybe this can help you?
                                • 13. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                                  924424
                                  Yannick,

                                  I very much appreciate all the help that you have given me so far. I did actually try your parameter passing post first, but it requires a full submit of the page and that isn't possible, when you are selecting a row from a table and passing one of the cells as the value. In addition, it doesn't demo well and this portal is strictly for demo purposes, so it really has to look good.

                                  Is there any way that you could send me some example code of two portlets that you have wired together with events, whether it was with portlet or contextual events? I am trying to piece together what I need from three or four different sources, but the writing is not very good and the versions are different, so some of the screens aren't right. Any help that you can provide, would be greatly appreciated.

                                  Brian Harrison
                                  bharrison@consultems.com
                                  • 14. Re: IPC Between Two ADF Portlets on Same Page using Events Failure
                                    Yannick Ongena
                                    Wait... You have to make a distinct difference between portlet events and contextual events in ADF.
                                    Contextual events in ADF can be converted to portlet events.

                                    If the full refresh of a portlet is an issue for you then even contextual events will not solve your problem.
                                    Regardless the use of parameters or events, portlets do not support partial page rendering or ajax. In order for a parameter to pass or an event to be triggered, it need to have a reference to the ActionResponse or RequestResponse. If they don't have the proper reference they will not be able to trigger the event.

                                    In the case you are talking about, the selection of a record, this won't be able to trigger an event because the selectionModel will be triggered by a partial submit.
                                    The only work around for this problem is by adding a "select" button that will do a full submit.

                                    This is not a limitation of ADF, it is a limitation of the portlet standar because the standard itself does not have anything that supports partial page rendering or ajax...
                                    1 2 Previous Next