4 Replies Latest reply on Nov 9, 2012 5:06 PM by ltaraud

    Problem inter-portlet-communication

    jeromej

      hi

       

       

      I'm sending events between porlet.

      Porltet visible on the same page than the portlet publishing the event are receiving the event.

      But portlet that are not visible on the page (but still alive) don't receive the event.

      I need to update data when my event is sent into any portlet even if they are visible or not

       

       

      portlet.xml (publish) :

       

      <?xml version="1.0" encoding="UTF-8"?>

      <portlet-app ...>

      <portlet>

        ...

        <init-param>

         <name>javax.portlet.faces.autoDispatchEvents</name>

         <value>true</value>

        </init-param>

        ...

        <supported-publishing-event>

           <qname xmlns:s2eevt="urn:fr:s2e:web:front:event">s2eevt:EvtPortletMAJDonneesPerso</qname>

        </supported-publishing-event>

      </portlet>

        <event-definition>

           <qname xmlns:s2eevt="urn:fr:s2e:web:front:event">s2eevt:EvtPortletMAJDonneesPerso</qname>

           <value-type>fr.s2e.web.front.portlet.synchro.EvtPortletMAJDonneesPerso</value-type>

        </event-definition> 

      </portlet-app>

       

      portlet.xml (suscribe)

      <portlet-app ...>

      <portlet>

        ...

        <init-param>

         <name>javax.portlet.faces.bridgeEventHandler</name>

         <value>fr.s2e.web.front.portlet.synchro.MAJEvtHandler</value>

        </init-param>

        <init-param>

         <name>javax.portlet.faces.autoDispatchEvents</name>

         <value>true</value>

        </init-param>

        ...

        <supported-processing-event>

           <qname xmlns:s2eevt="urn:fr:s2e:web:front:event">s2eevt:EvtPortletMAJDonneesPerso</qname>

        </supported-processing-event>

      </portlet>

        <event-definition>

           <qname xmlns:s2eevt="urn:fr:s2e:web:front:event">s2eevt:EvtPortletMAJDonneesPerso</qname>

           <value-type>fr.s2e.web.front.portlet.synchro.EvtPortletMAJDonneesPerso</value-type>

        </event-definition> 

      </portlet-app>

       

      send the event :

             FacesContext fc = FacesContext.getCurrentInstance();

              if (fc != null) {

                  ExternalContext extCtx = fc.getExternalContext();

                  Object response = extCtx.getResponse();

                  if (StateAwareResponse.class.isAssignableFrom(response.getClass())) {

                      StateAwareResponse preponse = (StateAwareResponse)response;

                      preponse.setEvent(evt.getQname(), evt);

                  }

              }

       

      Handler

      public class MAJEvtHandler implements BridgeEventHandler {

          public EventNavigationResult handleEvent(FacesContext ctx, Event evt) {
        //event processing
              return null;
          }

      }

       

       

       

       

      Gatein 3.2.4 (eXo 3.5.3), RF4.2.3.Final, JSF 2.1.8, PB 3.1.0.Final

        • 1. Re: Problem inter-portlet-communication
          kenfinni

          Jerome,

           

          To my knowledge, GateIn scopes Events to portlets on the same visible page.

           

          If you're trying to send an Event to a portlet that is not present on the current portal page, I don't believe that will work.

           

          Ken

          • 2. Re: Problem inter-portlet-communication
            jeromej

            Hi Ken,

             

            Thanks.

             

            Oherwise, does GateIn send an event to a portlet that was not visible when it becomes visible in the page ?
            It could be used as a work around to this problem.

             

            Jerome

            • 3. Re: Problem inter-portlet-communication
              kenfinni

              Pretty sure that the Events are only propogated once, so if the portlet isn't visible when the Event was fired, I don't believe it would receive the Event if it were to become visible afterwards

              • 4. Re: Problem inter-portlet-communication
                ltaraud

                Hi,

                 

                I need to do something similar. I need to keep some data stored in different portlets (portlet scope).

                When the user make an action into one portlet, I need to ensure the tha data contained in all the portlet would be processed again (even if they are visible or not), so that all porlet would display correct data next time they would be visible in the page.

                 

                Is there a way to know, in a portlet visible in the page, that it becomes no more visible in the page ?

                Is there a way to know, in a portlet not visible in the page, that it becomes visible ?

                 

                If so, when the portlet becomes visible again, you could add a behavior allowing you to ensure that data stored in the portlet are correct.

                 

                 

                I have read in JSR 286, that portlet container could send "portlet container" events  to portlets. Is there a such event in gateIn ?

                 

                 

                Laurent