javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-80

LifecycleImple.reload() not sufficient for all cases

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform:

    • Issuezilla Id:
      80

      Description

      >>>>> On Wed, 15 Dec 2004 10:49:45 -0800, Adam Winer <adam.winer@ORACLE.COM> said:

      AW> In the current RI, there is already a method in LifecycleImpl -
      AW> LifecycleImpl.reload() that attempts to detect the difference
      AW> between an initial render of a page and a postback request. (For
      AW> an initial render, it forces a call to renderResponse() to skip
      AW> most lifecycle phases.) The code considers all "POST" requests
      AW> and "GET" requests with query parameters to be postbacks.
      AW> Manfred has quite accurately pointed out that this rule is simply
      AW> inadequate to deal with all scenarios, and that some applications
      AW> may need finer control.

        Activity

        Hide
        jayashri added a comment -

        Here is the fix:

        Index: src/com/sun/faces/lifecycle/LifecycleImpl.java
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/lifecycle/LifecycleImpl.java,v
        retrieving revision 1.47
        diff -u -r1.47 LifecycleImpl.java
        — src/com/sun/faces/lifecycle/LifecycleImpl.java 3 Feb 2005 22:51:57
        -0000 1.47
        +++ src/com/sun/faces/lifecycle/LifecycleImpl.java 8 Apr 2005 20:31:43 -0000
        @@ -260,27 +260,12 @@
        HttpServletRequest))

        { return (false); }
        • HttpServletRequest request = (HttpServletRequest)
        • context.getExternalContext().getRequest();
        • String method = request.getMethod();
          -
        • // Is this a GET request with query parameters?
        • if ("GET".equals(method)) {
        • Iterator names = context.getExternalContext().
        • getRequestParameterNames();
        • if (names.hasNext()) { - return (false); - }
        • }
          -
        • // Is this a POST or PUT request?
        • if ("POST".equals(method) || "PUT".equals(method)) { - return (false); - }

          -

        • // Assume this is a reload
        • return (true);
          -
          + String renderkitId =
          + context.getApplication().getViewHandler().
          + calculateRenderKitId(context);
          + ResponseStateManager rsm = Util.getResponseStateManager(context,
          + renderkitId);
          + return (rsm.isPostback(context));
          }
        Show
        jayashri added a comment - Here is the fix: Index: src/com/sun/faces/lifecycle/LifecycleImpl.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/lifecycle/LifecycleImpl.java,v retrieving revision 1.47 diff -u -r1.47 LifecycleImpl.java — src/com/sun/faces/lifecycle/LifecycleImpl.java 3 Feb 2005 22:51:57 -0000 1.47 +++ src/com/sun/faces/lifecycle/LifecycleImpl.java 8 Apr 2005 20:31:43 -0000 @@ -260,27 +260,12 @@ HttpServletRequest)) { return (false); } HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); String method = request.getMethod(); - // Is this a GET request with query parameters? if ("GET".equals(method)) { Iterator names = context.getExternalContext(). getRequestParameterNames(); if (names.hasNext()) { - return (false); - } } - // Is this a POST or PUT request? if ("POST".equals(method) || "PUT".equals(method)) { - return (false); - } - // Assume this is a reload return (true); - + String renderkitId = + context.getApplication().getViewHandler(). + calculateRenderKitId(context); + ResponseStateManager rsm = Util.getResponseStateManager(context, + renderkitId); + return (rsm.isPostback(context)); }
        Hide
        jayashri added a comment -

        Please ignore the previous diff. Here is the correct one.

        Index: src/com/sun/faces/lifecycle/LifecycleImpl.java
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/lifecycle/LifecycleImpl.java,v
        retrieving revision 1.47
        diff -u -r1.47 LifecycleImpl.java
        — src/com/sun/faces/lifecycle/LifecycleImpl.java 3 Feb 2005 22:51:57
        -0000 1.47
        +++ src/com/sun/faces/lifecycle/LifecycleImpl.java 8 Apr 2005 21:02:40 -0000
        @@ -20,6 +20,7 @@
        import javax.faces.event.PhaseListener;
        import javax.faces.lifecycle.Lifecycle;
        import javax.servlet.http.HttpServletRequest;
        +import javax.faces.render.ResponseStateManager;

        import java.util.ArrayList;
        import java.util.Iterator;
        @@ -260,27 +261,17 @@
        HttpServletRequest))

        { return (false); }
        • HttpServletRequest request = (HttpServletRequest)
        • context.getExternalContext().getRequest();
        • String method = request.getMethod();
          -
        • // Is this a GET request with query parameters?
        • if ("GET".equals(method)) {
        • Iterator names = context.getExternalContext().
        • getRequestParameterNames();
        • if (names.hasNext()) { - return (false); - }
        • }
          -
        • // Is this a POST or PUT request?
        • if ("POST".equals(method) || "PUT".equals(method)) {
        • return (false);
          + String renderkitId =
          + context.getApplication().getViewHandler().
          + calculateRenderKitId(context);
          + ResponseStateManager rsm = Util.getResponseStateManager(context,
          + renderkitId);
          + boolean postback = rsm.isPostback(context);
          + if (postback) { + return false; }

          -

        • // Assume this is a reload
        • return (true);
          -
          + // assume it is reload.
          + return true;
          }
        Show
        jayashri added a comment - Please ignore the previous diff. Here is the correct one. Index: src/com/sun/faces/lifecycle/LifecycleImpl.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/lifecycle/LifecycleImpl.java,v retrieving revision 1.47 diff -u -r1.47 LifecycleImpl.java — src/com/sun/faces/lifecycle/LifecycleImpl.java 3 Feb 2005 22:51:57 -0000 1.47 +++ src/com/sun/faces/lifecycle/LifecycleImpl.java 8 Apr 2005 21:02:40 -0000 @@ -20,6 +20,7 @@ import javax.faces.event.PhaseListener; import javax.faces.lifecycle.Lifecycle; import javax.servlet.http.HttpServletRequest; +import javax.faces.render.ResponseStateManager; import java.util.ArrayList; import java.util.Iterator; @@ -260,27 +261,17 @@ HttpServletRequest)) { return (false); } HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); String method = request.getMethod(); - // Is this a GET request with query parameters? if ("GET".equals(method)) { Iterator names = context.getExternalContext(). getRequestParameterNames(); if (names.hasNext()) { - return (false); - } } - // Is this a POST or PUT request? if ("POST".equals(method) || "PUT".equals(method)) { return (false); + String renderkitId = + context.getApplication().getViewHandler(). + calculateRenderKitId(context); + ResponseStateManager rsm = Util.getResponseStateManager(context, + renderkitId); + boolean postback = rsm.isPostback(context); + if (postback) { + return false; } - // Assume this is a reload return (true); - + // assume it is reload. + return true; }
        Hide
        Ed Burns added a comment -

        Actually, you need to tweak calculateRenderKitId(). The spec for this method
        changed as a result of jsf-spec-public 47. The real implementation can't be
        done until we have 50 implemented. For now, you can just make it so that it
        never returns null. I'd like to see another change-bundle.

        Ed

        Show
        Ed Burns added a comment - Actually, you need to tweak calculateRenderKitId(). The spec for this method changed as a result of jsf-spec-public 47. The real implementation can't be done until we have 50 implemented. For now, you can just make it so that it never returns null. I'd like to see another change-bundle. Ed
        Hide
        jayashri added a comment -

        Roger has implemented the changes for 50 in a separate branch. As far as I can
        see, calculateRenderKitId() (in the trunk) will never return null (it will
        default to HTML_RENDERKIT). So I am not sure what you mean here. can you please
        clarify ?
        Thanks

        Show
        jayashri added a comment - Roger has implemented the changes for 50 in a separate branch. As far as I can see, calculateRenderKitId() (in the trunk) will never return null (it will default to HTML_RENDERKIT). So I am not sure what you mean here. can you please clarify ? Thanks
        Hide
        Ed Burns added a comment -

        As long as you can guarantee that ViewHandlerImpl.calculateRenderKitId() will
        never return null, I'm happy.

        Show
        Ed Burns added a comment - As long as you can guarantee that ViewHandlerImpl.calculateRenderKitId() will never return null, I'm happy.
        Hide
        jayashri added a comment -

        Fix checked in.

        Show
        jayashri added a comment - Fix checked in.
        Hide
        jayashri added a comment -

        Fix checked in

        Show
        jayashri added a comment - Fix checked in
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            jayashri
            Reporter:
            Ed Burns
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: