ICEfaces
  1. ICEfaces
  2. ICE-5974

Portlet allow Servlet JSF processing

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Beta1
    • Fix Version/s: 2.0-Beta2, 2.0.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      ICEfaces 2.0, PortletFaces bridge

      Description


      When a resource URL such as /icefaces/resource/MjAyNjQwNTE1MA==/icefaces.jpg

      is obtained via the call

      facesContext.getApplication().getViewHandler().getResourceURL(context, path)

      the resulting URL:

      http://localhost:8080/component-showcase-portlet/icefaces/resource/MjAyNjQwNTE1MA==/icefaces.jpg

      Cannot be fetched from the Faces Servlet (in the example mapped to /icefaces/*):

      java.lang.ClassCastException: org.apache.catalina.core.ApplicationContextFacade cannot be cast to javax.portlet.PortletContext
      org.portletfaces.bridge.context.ExternalContextFactoryImpl.getExternalContext(ExternalContextFactoryImpl.java:32)
      com.sun.faces.context.FacesContextFactoryImpl.getFacesContext(FacesContextFactoryImpl.java:89)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:298)

        Activity

        Hide
        Ted Goddard added a comment -

        It should be possible for the PortletFaces Bridge to detect that it is serving a non-Portlet request and delegate to the JSF factory chain for this request.

        Show
        Ted Goddard added a comment - It should be possible for the PortletFaces Bridge to detect that it is serving a non-Portlet request and delegate to the JSF factory chain for this request.
        Hide
        Ted Goddard added a comment -

        Addition of the Servlet path to the PortletFaces bridge is expected to fix resource dispatching issues for outputResource, chart, and richText.

        Show
        Ted Goddard added a comment - Addition of the Servlet path to the PortletFaces bridge is expected to fix resource dispatching issues for outputResource, chart, and richText.
        Hide
        Neil Griffin added a comment -

        Is there a reason why we can't let the portlet RESOURCE_PHASE handle the resource requests, like we do for jsf.js?

        Show
        Neil Griffin added a comment - Is there a reason why we can't let the portlet RESOURCE_PHASE handle the resource requests, like we do for jsf.js?
        Hide
        Ted Goddard added a comment -

        This would require modifying the URLs to be compatible with the Portlet URLs – this is to handle legacy code in ICEfaces 2.0 compat where it is difficult to change how the URLs are generated.

        Show
        Ted Goddard added a comment - This would require modifying the URLs to be compatible with the Portlet URLs – this is to handle legacy code in ICEfaces 2.0 compat where it is difficult to change how the URLs are generated.
        Hide
        Neil Griffin added a comment -

        Would it be possible to have /javax.faces.resource/icefaces in the resource URL instead of /icefaces/resource? That would invoke the standard resource handling found in BridgeImpl.doFacesRequest(ResourceRequest, ResourceResponse) and delegate to the ICEfaces 2.0 ResourceHandler via the chain-of-responsibility pattern.

        http://svn.portletfaces.org/svn/portletfaces/bridge/org.portletfaces.bridge.impl/trunk/src/main/java/org/portletfaces/bridge/BridgeImpl.java

        Show
        Neil Griffin added a comment - Would it be possible to have /javax.faces.resource/icefaces in the resource URL instead of /icefaces/resource? That would invoke the standard resource handling found in BridgeImpl.doFacesRequest(ResourceRequest, ResourceResponse) and delegate to the ICEfaces 2.0 ResourceHandler via the chain-of-responsibility pattern. http://svn.portletfaces.org/svn/portletfaces/bridge/org.portletfaces.bridge.impl/trunk/src/main/java/org/portletfaces/bridge/BridgeImpl.java
        Hide
        Ted Goddard added a comment -

        Would that actually work? From the BridgeImpl code it looks like a PortletRequest is expected for all the methods. The problem we're having is that a Servlet request is being handled by FacesServlet so org.portletfaces.bridge.context.ExternalContextFactoryImpl.getExternalContext() should delegate to the parent factory.

        It should have access to that parent factory as part of the getWrapped() implementation:

        http://download.oracle.com/javaee/6/api/javax/faces/context/ExternalContextFactory.html

        Show
        Ted Goddard added a comment - Would that actually work? From the BridgeImpl code it looks like a PortletRequest is expected for all the methods. The problem we're having is that a Servlet request is being handled by FacesServlet so org.portletfaces.bridge.context.ExternalContextFactoryImpl.getExternalContext() should delegate to the parent factory. It should have access to that parent factory as part of the getWrapped() implementation: http://download.oracle.com/javaee/6/api/javax/faces/context/ExternalContextFactory.html
        Hide
        Neil Griffin added a comment -

        After talking with Ted, I came to understand that requests to the FacesServlet can occur in a portlet environment if a compatibility component has dependencies on relative URLs for resources. He recommended that I take advantage of the decorator pattern of ExternalContextFactory and delegate if the incoming request is not an instanceof PortletRequest.

        Commit: Committed revision 81 (1 entry) BETA1-SNAPSHOT
        http://svn.portletfaces.org/svn/portletfaces/bridge/org.portletfaces.bridge.impl/trunk/src/main/java/org/portletfaces/bridge/context/ExternalContextFactoryImpl.java

        Show
        Neil Griffin added a comment - After talking with Ted, I came to understand that requests to the FacesServlet can occur in a portlet environment if a compatibility component has dependencies on relative URLs for resources. He recommended that I take advantage of the decorator pattern of ExternalContextFactory and delegate if the incoming request is not an instanceof PortletRequest. Commit: Committed revision 81 (1 entry) BETA1-SNAPSHOT http://svn.portletfaces.org/svn/portletfaces/bridge/org.portletfaces.bridge.impl/trunk/src/main/java/org/portletfaces/bridge/context/ExternalContextFactoryImpl.java
        Hide
        Ted Goddard added a comment -

        Assigning to Deryk to verify if this allows additional component-showcase portlets to work.

        Show
        Ted Goddard added a comment - Assigning to Deryk to verify if this allows additional component-showcase portlets to work.
        Hide
        Deryk Sinotte added a comment -

        Resolving this as fixed. In running the Rich Input Text example as a portlet, there are a couple of script resources that are downloaded dynamically with URL's that look like this:

        http://localhost:8080/component-showcase-portlet/icefaces/resource/LTc4NTk0MDYzMQ==/

        The result is that they are properly retrieved:

        Request URL:http://localhost:8080/component-showcase-portlet/icefaces/resource/LTc4NTk0MDYzMQ==/
        Request Method:GET
        Status Code:200 OK

        These script resources are successfully retrieved and the portlet is functional.

        Show
        Deryk Sinotte added a comment - Resolving this as fixed. In running the Rich Input Text example as a portlet, there are a couple of script resources that are downloaded dynamically with URL's that look like this: http://localhost:8080/component-showcase-portlet/icefaces/resource/LTc4NTk0MDYzMQ==/ The result is that they are properly retrieved: Request URL: http://localhost:8080/component-showcase-portlet/icefaces/resource/LTc4NTk0MDYzMQ==/ Request Method:GET Status Code:200 OK These script resources are successfully retrieved and the portlet is functional.

          People

          • Assignee:
            Deryk Sinotte
            Reporter:
            Ted Goddard
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: