Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-1355

The incongruity tasks added to the context are not being processed.

    Details

      Description

      The incongruity tasks added to the context are not being processed.

      Three things are observed

      1) Inside com.liferay.faces.bridge.lifecycle.LifecycleIncongruityManager, the instance variable lifecycleIncongruityMap is not initialized. So, in method makeCongruous(), if there is anything in the task list, references to the variable lifecycleIncongruityMap will fail. An instance of com.liferay.faces.bridge.lifecycle.LifecycleIncongruityMap is passed to the constructor for com.liferay.faces.bridge.lifecycle.LifecycleIncongruityManager. However, it is not stored.

      2) In method preInitializeObjects() of com.liferay.faces.bridge.context.ExternalContextImpl, an instance of com.liferay.faces.bridge.lifecycle.LifecycleIncongruityManager is created. In some of the methods of ExternalContextImpl, when the instance variable portletResponse is not an instance of MimeResponse, method addCongruousTask() of instance variable lifecycleIncongruityManager is invoked, which then add tasks to the list instance variable congruousTaskList. In ExternalContextImpl, the local instance variable lifecycleIncongruityManager is declared as private with no getter for it. There is nothing in com.liferay.faces.bridge.context.ExternalContextImpl that causes the makeCongruous() method of the lifecycleIncongruityManager instance to be invoked. So, basically, nothing is done with the tasks afterwards.

      3) In the execute() method of com.liferay.faces.bridge.BridgePhaseRenderImpl, local variable lifecycleIncongruityManager is assigned a new instance of com.liferay.faces.bridge.lifecycle.LifecycleIncongruityManager. Then, right after that, the method makeCongruous() of the LifecycleIncongruityManager instance is invoked.

      The tasks that were added by com.liferay.faces.bridge.context.ExternalContextImpl are not processed and therefore any output that was to be sent to the end user is not sent the web browser.

      I discovered this while looking into whether I could find out a work-around for a problem with the Primefaces DataExporter when used in Liferay portal. That issue has been opened here https://code.google.com/p/primefaces/issues/detail?id=1109 against Primefaces. Neil Griffin, the Liferay Faces lead, has provided a patch to get around the problem. However, while the patch gets around the problem with the exception being thrown, the data created by the Primefaces DataExporter is not being returned to the web browser.

      So, for example, with the patch provided by Neil for the org.primefaces.component.export.PDFExporter, method writePDFToResponse() is as follows:

      protected void writePDFToResponse(ExternalContext externalContext, ByteArrayOutputStream baos, String fileName) throws IOException, DocumentException

      { externalContext.setResponseContentType("application/pdf"); externalContext.setResponseHeader("Expires", "0"); externalContext.setResponseHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0"); externalContext.setResponseHeader("Pragma", "public"); externalContext.setResponseHeader("Content-disposition", "attachment;filename="+ fileName + ".pdf"); externalContext.setResponseContentLength(baos.size()); externalContext.addResponseCookie(Constants.DOWNLOAD_COOKIE, "true", new HashMap<String, Object>()); OutputStream out = externalContext.getResponseOutputStream(); baos.writeTo(out); externalContext.responseFlushBuffer(); }

      When the the following statements
      OutputStream out = externalContext.getResponseOutputStream();
      and
      externalContext.responseFlushBuffer();

      are invoked, the corresponding methods inside com.liferay.faces.bridge.context.ExternalContextImpl will add a congruity task. But, after that, the method makeCongruous() for the instance of com.liferay.faces.bridge.lifecycle.LifecycleIncongruityManager created by com.liferay.faces.bridge.context.ExternalContextImpl is not invoked. So, nothing is done to get the data back to the web browser.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: