ICEfaces
  1. ICEfaces
  2. ICE-4826

DataExporter uses API that is not functional in portlets

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.1
    • Fix Version/s: 1.8.2-RC1, 1.8.2
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      portlets dataexporter

      Description

      In the DataExporter.createFile method, the following logic is used:

              ServletContext context = ((HttpSession) FacesContext
                      .getCurrentInstance().getExternalContext().getSession(false))
                      .getServletContext();

      Casting to an HttpSession and attempting to retrieve the ServletContext will not work in portlets. In this case, the context is used to access the getRealPath() API to determine the location in the filesystem for storing/reading documents. The Portlet API also makes this available via the PortletContext. The code would need to look something like this:

              PortletContext pContext = ((PortletSession) FacesContext
                      .getCurrentInstance().getExternalContext().getSession(false))
                      .getPortletContext();

      There is no JSF way to do this that will work in both environments unfortunately so we'll need to ensure that this is done in a way that doesn't require a runtime dependency on the portlet.jar as it will not be available in plain web-apps.

        Issue Links

          Activity

          Hide
          Ken Fyten added a comment -

          Please correct, you'll need to implement using reflection to avoid runtime dependencies on portlet APIs in a none-portlet environment.

          Show
          Ken Fyten added a comment - Please correct, you'll need to implement using reflection to avoid runtime dependencies on portlet APIs in a none-portlet environment.
          Hide
          Mark Collette added a comment -

          Perhaps the core should provide the half-dozen or so methods, common to ServletContext and PortletContext, that ICEfaces may use, as an API, that would hide this detail.

          Show
          Mark Collette added a comment - Perhaps the core should provide the half-dozen or so methods, common to ServletContext and PortletContext, that ICEfaces may use, as an API, that would hide this detail.
          Hide
          Adnan Durrani added a comment -

          Fixed:
          Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporter.java
          Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\core\src\com\icesoft\faces\util\CoreUtils.java
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\core\src\com\icesoft\faces\util\CoreUtils.java
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporter.java
          Completed: At revision: 19188

          Show
          Adnan Durrani added a comment - Fixed: Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporter.java Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\core\src\com\icesoft\faces\util\CoreUtils.java Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\core\src\com\icesoft\faces\util\CoreUtils.java Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporter.java Completed: At revision: 19188
          Hide
          Adnan Durrani added a comment -

          Following static method added to the CoreUtils. It uses reflection to invoke getRealPath either on ServletContext or PorletContext based on the environment.

          com.icesoft.faces.util.CoreUtils.getRealPath(FacesContext facesContext, String path);

          Show
          Adnan Durrani added a comment - Following static method added to the CoreUtils. It uses reflection to invoke getRealPath either on ServletContext or PorletContext based on the environment. com.icesoft.faces.util.CoreUtils.getRealPath(FacesContext facesContext, String path);
          Hide
          Joanne Bai added a comment -

          Adnan, has dataExporter example been included in component showcase portlets version (ossrepo\icefaces\trunk\icefaces\samples\component-showcase\portlets)? I added it to the portlet.xml file in the conf directory, but still cannot see it showing as an available portlet on Liferay-tomcat6 and Jboss Portal 2.7.1. What else can we use for testing dataExporter portlet if not using component showcase? Thanks

          Show
          Joanne Bai added a comment - Adnan, has dataExporter example been included in component showcase portlets version (ossrepo\icefaces\trunk\icefaces\samples\component-showcase\portlets)? I added it to the portlet.xml file in the conf directory, but still cannot see it showing as an available portlet on Liferay-tomcat6 and Jboss Portal 2.7.1. What else can we use for testing dataExporter portlet if not using component showcase? Thanks

            People

            • Assignee:
              Adnan Durrani
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: