ICEfaces
  1. ICEfaces
  2. ICE-2245

delegateNonIface parameter does not work with Facelets

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7DR#2
    • Fix Version/s: 1.7DR#3, 1.7
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Any
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.)

      Description

      If you write an ICEfaces application using Facelets, the context parameter delegateNonIface cannot be set to true of the application will fail. The problem was described in a separate case (ICE-2503) but I will copy and quote the relevant information here:

      ----
      I did finally manage to replicate this issue. I tried the same test case with ICEfaces 1.6.0, 1.6.1, and 1.7 (from the current head of the repository). In addition to the standardRequestScope = true, I also had to have delegateNonIface = true. When these two context parameters are set as indicated, the problem occurs - even in a standard web application (i.e. it is not constrained to portlets).

      In 1.6.0, the exception is as indicated in the original report:

      java.lang.UnsupportedOperationException
              at javax.faces.context.ExternalContext.setResponse(ExternalContext.java:856)
              at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:436)
              at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:114)
              at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:150)
              
      In 1.6.1 and 1.7 from the head, the exception is slightly different:

      java.lang.ClassCastException: com.icesoft.faces.env.PortletEnvironmentRenderRequest
              at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:110)
              at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:145)
              at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:145)

      The main problem is basically the same, though, and stems from the ViewHandler delegation model. All registered ViewHandlers are put into a non-deterministic chain (a linked list of sorts with no specified order). To make this work, ViewHandlers need to be sure which views they should handle and which they should delegate. By setting delegateNonIface = true, the ICEfaces D2DViewHandler delegates responsibility to Sun's default ViewHandler implementation which, in this case, it shouldn't as we need to do the actual processing in the ICEfaces framework.

      So the quick fix is to set delegateNonIface = false. This brings up a separate issue in that the use of delegateNonIface cannot be used with Facelets in ICEfaces. This should be captured in a separate JIRA. If the submitter can verify that the setting the delegateNonIface = false works for their application, the case can be resolved.
      ---

        Activity

        Deryk Sinotte created issue -
        Hide
        Vadim Lotarev added a comment -

        I'd like to add that combination of standardRequestScope = true and delegateNonFaces = false produces the following warning:

        WARN [D2DViewHandler] Failing over to default request path

        May be this is the reason why navigation breaks down - any request ends up in the home page (1.7DR2, JBoss 4.2.1, Liferay 4.3.2, facelets)

        Show
        Vadim Lotarev added a comment - I'd like to add that combination of standardRequestScope = true and delegateNonFaces = false produces the following warning: WARN [D2DViewHandler] Failing over to default request path May be this is the reason why navigation breaks down - any request ends up in the home page (1.7DR2, JBoss 4.2.1, Liferay 4.3.2, facelets)
        Hide
        Vadim Lotarev added a comment -

        Is there any progress with this issue? Wouldn't it be possible to fix it in DR3?

        Show
        Vadim Lotarev added a comment - Is there any progress with this issue? Wouldn't it be possible to fix it in DR3?
        Hide
        Vadim Lotarev added a comment -

        Well, I did some debugging as soon as nobody in IceFaces wants to look at this issue. As for me, the reason of all these errors is that BridgeExternalContext.resetRequestMap() clears ALL request attributes at the end of rendering phase.

        Some functionality (expecially portlet support) relies on some auxiliary request attributes (like Constants.SERVLET_KEY, Constants.INC_REQUEST_URI and a lot of others). As soon as faces context is shared between asynchronous requests and request map is not updated during each call, all these parameters are lost and application fails.

        Show
        Vadim Lotarev added a comment - Well, I did some debugging as soon as nobody in IceFaces wants to look at this issue. As for me, the reason of all these errors is that BridgeExternalContext.resetRequestMap() clears ALL request attributes at the end of rendering phase. Some functionality (expecially portlet support) relies on some auxiliary request attributes (like Constants.SERVLET_KEY, Constants.INC_REQUEST_URI and a lot of others). As soon as faces context is shared between asynchronous requests and request map is not updated during each call, all these parameters are lost and application fails.
        Hide
        Vadim Lotarev added a comment -

        Well, I patched PortletExternalContext with the following code. May be this is not the right decision but it works for me.

        public void resetRequestMap() {
        if (standardScope) {

        requestMapLoop: for (Iterator iterator = requestMap.keySet().iterator(); iterator.hasNext() {
        String key = (String) iterator.next();

        for (int i = 0, l = Constants.INC_CONSTANTS.length; i < l; i++) {
        if (Constants.INC_CONSTANTS[i].equalsIgnoreCase(key))

        { continue requestMapLoop; }

        }
        if (Constants.NAMESPACE_KEY.equalsIgnoreCase(key)

        Constants.PORTLET_KEY.equalsIgnoreCase(key)
        PortletArtifactWrapper.PORTLET_ARTIFACT_KEY.equalsIgnoreCase(key)) { continue; }

        iterator.remove();
        }
        //requestMap.clear();
        }
        }

        .........

        public void update(HttpServletRequest request, HttpServletResponse response) {
        ...........
        // Copy attributes as well in case of standard request scope
        if (standardScope) {
        requestMap = new RequestAttributeMap();
        if (log.isDebugEnabled())
        log.debug("Updating request attributes:");
        Enumeration attributeNames = request.getAttributeNames();
        while (attributeNames.hasMoreElements())

        { String name = (String) attributeNames.nextElement(); Object value = request.getAttribute(name); if (log.isDebugEnabled()) log.debug(String.format("%s = %s", name, value)); requestMap.put(name, value); }

        }
        }

        Show
        Vadim Lotarev added a comment - Well, I patched PortletExternalContext with the following code. May be this is not the right decision but it works for me. public void resetRequestMap() { if (standardScope) { requestMapLoop: for (Iterator iterator = requestMap.keySet().iterator(); iterator.hasNext() { String key = (String) iterator.next(); for (int i = 0, l = Constants.INC_CONSTANTS.length; i < l; i++) { if (Constants.INC_CONSTANTS [i] .equalsIgnoreCase(key)) { continue requestMapLoop; } } if (Constants.NAMESPACE_KEY.equalsIgnoreCase(key) Constants.PORTLET_KEY.equalsIgnoreCase(key) PortletArtifactWrapper.PORTLET_ARTIFACT_KEY.equalsIgnoreCase(key)) { continue; } iterator.remove(); } //requestMap.clear(); } } ......... public void update(HttpServletRequest request, HttpServletResponse response) { ........... // Copy attributes as well in case of standard request scope if (standardScope) { requestMap = new RequestAttributeMap(); if (log.isDebugEnabled()) log.debug("Updating request attributes:"); Enumeration attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { String name = (String) attributeNames.nextElement(); Object value = request.getAttribute(name); if (log.isDebugEnabled()) log.debug(String.format("%s = %s", name, value)); requestMap.put(name, value); } } }
        Hide
        Vadim Lotarev added a comment -

        I've replaced this line:

        requestMap = new RequestAttributeMap();

        to:

        requestMap = Collections.synchronizedMap(new HashMap());

        since the first one copies attributes from previous saved RenderRequest. After this change request scope seems looking like realy "standard" for portlets.

        Show
        Vadim Lotarev added a comment - I've replaced this line: requestMap = new RequestAttributeMap(); to: requestMap = Collections.synchronizedMap(new HashMap()); since the first one copies attributes from previous saved RenderRequest. After this change request scope seems looking like realy "standard" for portlets.
        Hide
        Deryk Sinotte added a comment -

        We do want to fix the issue and thank you for the contribution. The problem you are discussing now is separate from the issue originally reported in the case so I have opened a new JIRA to track it: ICE-2369.

        Show
        Deryk Sinotte added a comment - We do want to fix the issue and thank you for the contribution. The problem you are discussing now is separate from the issue originally reported in the case so I have opened a new JIRA to track it: ICE-2369 .
        Ken Fyten made changes -
        Field Original Value New Value
        Fix Version/s 1.7DR#3 [ 10112 ]
        Assignee Mircea Toma [ mircea.toma ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #15265 Wed Nov 28 11:14:31 MST 2007 mircea.toma Always delegate if requests come in from a different servlet than MainServlet.

        ICE-2245
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/application/D2DViewHandlerDelegating.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/application/D2DViewHandler.java
        Hide
        Mircea Toma added a comment -

        Always delegate if requests come in from a different servlet than MainServlet. 'delegateNonIface' parameter is deprecated (ignored).
        The only reliable mechanism for deciding which ViewHandler should be invoked is to correctly map the servlets (MainServlet or FacesServlet) to the extensions that they're suppose to handle.

        Show
        Mircea Toma added a comment - Always delegate if requests come in from a different servlet than MainServlet. 'delegateNonIface' parameter is deprecated (ignored). The only reliable mechanism for deciding which ViewHandler should be invoked is to correctly map the servlets (MainServlet or FacesServlet) to the extensions that they're suppose to handle.
        Mircea Toma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Affects [Documentation (User Guide, Ref. Guide, etc.)]
        Resolution Fixed [ 1 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #15283 Thu Nov 29 16:33:28 MST 2007 mircea.toma Refactor.
        ICE-2245
        Files Changed
        Commit graph DEL /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/xmlhttp/PersistentFacesCommonlet.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/FacesContextFactoryImpl.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/MainServlet.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/BridgeExternalContext.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/ServletExternalContext.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/application/D2DViewHandler.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/BridgeFacesContext.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/portlet/PortletExternalContext.java
        Ken Fyten made changes -
        Fix Version/s 1.7 [ 10080 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Mircea Toma [ mircea.toma ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Deryk Sinotte
          • Votes:
            4 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: