PUBLIC - Liferay Faces
  1. PUBLIC - Liferay Faces
  2. FACES-1465

Events IPC does not properly execute bridgeEventHandler when portlets are on different portal pages

    Details

    • Similar Issues:
      Show 5 results 

      Description

      This issue was first reported in the forums here:
      http://www.liferay.com/community/forums/-/message_boards/view_message/18873590#_19_message_18875576

      Note that the summary field of this issue reflects what "seems" to be wrong at first glance, but actually the problem is a little more subtle...

      Steps to Reproduce

      1) Add the following to portal-ext.properties:

      portlet.event.distribution=layout-set
      layout.default.p_l_reset=false
      tags.compiler.enabled=false
      

      2) For the jsf2-ipc-events-customers-portlet, add the following code to the end of the selectionListener(ActionEvent) method:

      try {
      	externalContext.redirect("http://localhost:8080/web/guest/events-bookings");
      } catch (IOException e) {
      	e.printStackTrace();
      }
      

      3) Rebuild the jsf2-ipc-events-customers-portlet and deploy it to Liferay Portal

      4) Create a portal page named "Customers" in the Guest community and add the "JSF2 IPC (Events) - Customers" portlet to the page

      5) Deploy the jsf2-ipc-events-bookings-portlet to Liferay Portal

      6) Create a portal page named "Bookings" in the Guest community and add the "JSF2 IPC (Events) - Bookings" portlet to the page

      7) Click on one of the customers on the "Customers" page

      If the bug still exists, then the Bookings page will be displayed, but the bookings portlet will not show the noCustomerSelected.xhtml view

      If the bug is fixed, then the Bookings page will be displayed and the bookings portlet will show the bookings.xhtml view

      Detailed description of what is happening

      1) On Page "Customers", clicking on a customer in the Customers portlet causes the browser to submit an HTTP POST request
      2) The ACTION_PHASE of the portlet lifecycle executes for Page "Customers"
      3) The CustomersBackingBean.selectionListener(ActionEvent) method executes
      3a) The event is created queued in order to facilitate IPC
      3b) Calling ExternalContext.redirect(String redirectURL) simply sets a reminder for Liferay Portal to redirect to Page "Bookings"
      4) The EVENT_PHASE of the portlet lifecycle executes for Page "Customers"
      4a) Liferay Faces Bridge executes the CustomerSelectedEventHandler since it is registered in WEB-INF/portlet.xml
      4b) Liferay Faces Bridge triggers the navigation rule with the outcome of the handleEvent(FacesContext, Event) method
      4c) Liferay Faces Bridge remembers the new viewId that happened as a result of the navigation-rule
      5) Liferay Faces Bridge sets a bridgeRequestScopeId render parameter for Page "Customers", so that the BridgeRequestScope can be restored during the RENDER_PHASE
      6) Liferay Portal calls HttpServletRequest.sendRedirect(String) which returns HTTP status 302 back to the browser with the redirectURL from step #3
      7) The browser issues an HTTP GET request for the redirect URL
      8) The RENDER_PHASE of the portlet lifecycle executes for Page "Bookings"
      9) Liferay Faces Bridge attempts to retrieve the bridgeRequestScopeId render parameter for Page "Bookings", but doesn't find one, since step #5 set the render parameter for Page "Customers"

      Because step #9 fails, Liferay Faces Bridge does not realize that it needs to show the viewId from step #4c.

        Activity

        Hide
        Neil Griffin added a comment -

        This issue is fixed in the bridge, but in order for Events+Redirect to function properly, there is a little bit of extra work that the developer will have to do...

        In order to demonstrate this extra work, we enhanced the jsf2-ipc-events-customers-portlet and jsf2-ipc-events-bookings-portlet source code.

        Here is a screenshot of what the Customers portlet now looks like (when running under Liferay Portal):

        The user clicks on the "Redirect" checkbox and then select a page from the dropdown list.

        The CustomersBackingBean.selectionListener(ActionEvent) method has been modified so that when a redirect is specified, the Event "payload" is wrapped with a new EventPayloadWrapper:

        eventPayload = new EventPayloadWrapper(customer, true);

        The second argument (true) indicates that a redirect is taking place. When the event is published, Liferay Faces Bridge will detect the redirect and restore the bridge request scope accordingly.

        Similarly, the CustomerSelectedEventHandler.selectionListener(ActionEvent) method now checks to see if the payload has been wrapped.

        Show
        Neil Griffin added a comment - This issue is fixed in the bridge, but in order for Events+Redirect to function properly, there is a little bit of extra work that the developer will have to do... In order to demonstrate this extra work, we enhanced the jsf2-ipc-events-customers-portlet and jsf2-ipc-events-bookings-portlet source code. Here is a screenshot of what the Customers portlet now looks like (when running under Liferay Portal): The user clicks on the "Redirect" checkbox and then select a page from the dropdown list. The CustomersBackingBean.selectionListener(ActionEvent) method has been modified so that when a redirect is specified, the Event "payload" is wrapped with a new EventPayloadWrapper: eventPayload = new EventPayloadWrapper(customer, true ); The second argument (true) indicates that a redirect is taking place. When the event is published, Liferay Faces Bridge will detect the redirect and restore the bridge request scope accordingly. Similarly, the CustomerSelectedEventHandler.selectionListener(ActionEvent) method now checks to see if the payload has been wrapped.

          People

          • Assignee:
            Neil Griffin
            Reporter:
            Neil Griffin
            Participants of an Issue:
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development

                Structure Helper Panel