ICEfaces
  1. ICEfaces
  2. ICE-1393

Implement 'window' custom scope

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6DR#2
    • Fix Version/s: 2.0-Alpha2, 2.0.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      all
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.), Sample App./Tutorial, Compatibility/Configuration

      Description


      ICEfaces extends the JSF Request scope into an Ajax environment via the interpretation that a "request" is defined as a full page refresh. In other words, interactions within a single window that do not cause a full page refresh reside within the same "request" scope, causing request-scope beans in ICEfaces to live longer than in standard web applications. This is useful as it allows request scope to distinguish between different windows and maintain the thread of a user's interactions with those windows, but it sacrifices the standard request scope (which is can useful for managing resources within a page).

      The ICEfaces request scope should be deprecated and a new explicit mechanism for "window flow" scope should be added. For instance, to instantiate com.mycompany.beans.WindowBean and name it myWindowBean:

      <managed-bean>
          <managed-bean-name>ScopeManager</managed-bean-name>
          <managed-bean-class>org.icefaces.application.ScopeManager</managed-bean-class>
          <managed-bean-scope>session</managed-bean-scope>
          <managed-property>
              <property-name>myWindowBean</property-name>
              <value>com.mycompany.beans.WindowBean</value>
          </managed-property>
      </managed-bean>

      This syntax, however, does not allow any interesting dependency injection or configuration of properties of beans in window flow scope. Instead, it may be preferable to define the desired beans in "none" scope (causing it to be instantiated only when it is referenced) and then register the names of those beans in a list on the ScopeManager.

      <managed-bean>
          <managed-bean-name>myWindowBean</managed-bean-name>
          <managed-bean-class> com.mycompany.beans.WindowBean </managed-bean-class>
          <managed-bean-scope>none</managed-bean-scope>
          <managed-property>
              <property-name>property1</property-name>
              <value>42</value>
          </managed-property>
      </managed-bean>

      <managed-bean>
          <managed-bean-name>ScopeManager</managed-bean-name>
          <managed-bean-class>org.icefaces.application.ScopeManager</managed-bean-class>
          <managed-bean-scope>session</managed-bean-scope>
          <managed-property>
              <property-name>WindowScopeBeans</property-name>
              <values>
                  <value>myWindowBean</value>
                  <value>myOtherWindowBean</value>
              </values>
          </managed-property>
      </managed-bean>

      It may also be necessary to implement a custom EL resolver to provide this capability.

      Oracle ADF Faces has a pageFlow scope which may have the desired properties:
      (however, beans in pageFlow scope are referred to in EL by the pageFlowScope prefix, which may not be desirable. In any case, it is possible we should adopt the "page flow" terminology)

      http://www.orablogs.com/jjacobi/archives/000481.html

      Spring Web Flow also has a number of good ideas in the same area:

      http://www.springframework.org/webflow

        Issue Links

          Activity

          Ted Goddard created issue -
          Ken Fyten made changes -
          Field Original Value New Value
          Fix Version/s 2.0 [ 10032 ]
          Affects [Documentation (User Guide, Ref. Guide, etc.), Sample App./Tutorial, Compatibility/Configuration]
          Assignee Mircea Toma [ mircea.toma ]
          Ken Fyten made changes -
          Link This issue blocks ICE-1741 [ ICE-1741 ]
          Hide
          Mark Collette added a comment -

          One approach would be to do ICE-2479.

          Show
          Mark Collette added a comment - One approach would be to do ICE-2479 .
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18987 Tue Jun 23 08:33:36 MDT 2009 mircea.toma ICE-1393 First cut at implementing "window" scope using a time based strategy to re/associate windows on reload or redirect.
          Files Changed
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/ExternalContextConfiguration.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/resources/META-INF/faces-config.xml
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/javascript/application.js
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/push/SendUpdatedViews.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/push/servlet/PushResourceHandler.java
          Commit graph DEL /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/push/UpdateNotifier.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/javascript/submit.js
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/push/DisposeWindowScope.java
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeManager.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/push/SessionBoundServer.java
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeSetup.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18995 Wed Jun 24 17:38:46 MDT 2009 mircea.toma ICE-1393 Add window scoped ELResolver.
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/resources/META-INF/faces-config.xml
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeManager.java
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/context/WindowELContext.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeSetup.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18996 Wed Jun 24 17:40:29 MDT 2009 mircea.toma ICE-1393 Rename & move class.
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/resources/META-INF/faces-config.xml
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowELResolver.java
          Commit graph DEL /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/context/WindowELContext.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19002 Fri Jun 26 07:38:39 MDT 2009 mircea.toma ICE-1393 Use thread local variable to keep the current window scope.
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowELResolver.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeManager.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19008 Mon Jun 29 14:38:22 MDT 2009 mircea.toma ICE-1393 Fire PreDestroy and PostConstruct events to be used by annotated window scoped beans.
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowELResolver.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeManager.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/samples/scopes/src/main/java/org/icefaces/demo/scopes/WindowCounter.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeSetup.java
          Hide
          Mircea Toma added a comment -

          First cut at implementing "window" scope using a time based strategy to re/associate windows on reload or redirect.

          Show
          Mircea Toma added a comment - First cut at implementing "window" scope using a time based strategy to re/associate windows on reload or redirect.
          Hide
          Mircea Toma added a comment -

          Add window scoped ELResolver.

          Show
          Mircea Toma added a comment - Add window scoped ELResolver.
          Hide
          Mircea Toma added a comment -

          Use thread local variable to keep the current window scope.

          Show
          Mircea Toma added a comment - Use thread local variable to keep the current window scope.
          Hide
          Mircea Toma added a comment -

          Fire PreDestroy and PostConstruct events to be used by annotated window scoped beans.

          Show
          Mircea Toma added a comment - Fire PreDestroy and PostConstruct events to be used by annotated window scoped beans.
          Hide
          Ted Goddard added a comment -

          Is this a ThreadLocal for the scope itself? Would it be possible to just use the FacesContext in some way? If we can avoid our own ThreadLocal, we can avoid certain types of memory leaks.

          Show
          Ted Goddard added a comment - Is this a ThreadLocal for the scope itself? Would it be possible to just use the FacesContext in some way? If we can avoid our own ThreadLocal, we can avoid certain types of memory leaks.
          Mircea Toma made changes -
          Summary Explicit scope mechanism to replace ICEfaces request scope Implement 'window' custom scope
          Salesforce Case []
          Hide
          Mircea Toma added a comment -

          Yes, the ThreadLocal holds the scope itself, although it would suffice to hold only the window ID string.

          We could put it in session or application map, but you know I'm not a fan of this approach. I actually tried this approach but the code started to become unwieldily when handling requests without window ID. When WindowScopeManager assigns a new ID WindowELResolver cannot lookup by ID the scope map because the ID is still internal to WindowScopeManager for the current thread. Only the next request would contain the window ID that can eventually be used by WindowELResolver to lookup the map.

          Also, by using the ThreadLocal lookups in session map, map of window scope maps, and request parameter map are avoided.

          Show
          Mircea Toma added a comment - Yes, the ThreadLocal holds the scope itself, although it would suffice to hold only the window ID string. We could put it in session or application map, but you know I'm not a fan of this approach. I actually tried this approach but the code started to become unwieldily when handling requests without window ID. When WindowScopeManager assigns a new ID WindowELResolver cannot lookup by ID the scope map because the ID is still internal to WindowScopeManager for the current thread. Only the next request would contain the window ID that can eventually be used by WindowELResolver to lookup the map. Also, by using the ThreadLocal lookups in session map, map of window scope maps, and request parameter map are avoided.
          Hide
          Ted Goddard added a comment -

          Window scope could be viewed as a sub-scope of session, also, it may be desirable for window-scoped values to be propagated for failover via session replication. Maybe just the windowID should be kept in the ThreadLocal?

          Show
          Ted Goddard added a comment - Window scope could be viewed as a sub-scope of session, also, it may be desirable for window-scoped values to be propagated for failover via session replication. Maybe just the windowID should be kept in the ThreadLocal?
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19029 Fri Jul 03 11:27:20 MDT 2009 ted.goddard javax.el and javax.annotation .jars required for window scope. These are intermediate build glassfish .jars and must be updated (ICE-1393)
          Files Changed
          Commit graph ADD /icefaces/scratchpads/glimmer/lib/javax.servlet.jsp.jar
          Commit graph ADD /icefaces/scratchpads/glimmer/lib/javax.annotation.jar
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19030 Fri Jul 03 11:34:58 MDT 2009 ted.goddard temporary fix to address dom diff in compat/component-showcase (ICE-1393)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeSetup.java
          Hide
          Ted Goddard added a comment -

          Checked in the following change temporarily since a different value for window.ice.window was causing a failed full-page refresh in compat/component-showcase. (The script node is a direct child of the <body>.) We should look at alternative methods for passing parameters to the bridge. A cookie will likely not be suitable in this case since this bridge parameter is window-specific (cookies were proposed as a parameter passing mechanism for other bridge configuration).

          public void encodeBegin(FacesContext context) throws IOException {
          ResponseWriter writer = context.getResponseWriter();
          writer.startElement("script", this);
          + writer.writeAttribute("id", "ice-window-init", null);
          writer.writeAttribute("type", "text/javascript", null);
          writer.writeText("window.ice.window = " + id + ";", null);
          writer.endElement("script");

          Show
          Ted Goddard added a comment - Checked in the following change temporarily since a different value for window.ice.window was causing a failed full-page refresh in compat/component-showcase. (The script node is a direct child of the <body>.) We should look at alternative methods for passing parameters to the bridge. A cookie will likely not be suitable in this case since this bridge parameter is window-specific (cookies were proposed as a parameter passing mechanism for other bridge configuration). public void encodeBegin(FacesContext context) throws IOException { ResponseWriter writer = context.getResponseWriter(); writer.startElement("script", this); + writer.writeAttribute("id", "ice-window-init", null); writer.writeAttribute("type", "text/javascript", null); writer.writeText("window.ice.window = " + id + ";", null); writer.endElement("script");
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19054 Mon Jul 13 08:28:03 MDT 2009 mircea.toma ICE-1393 Store window's ID into the the threa local instead of the window scope map to avoid memory leaks.
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeManager.java
          Hide
          Mircea Toma added a comment -

          Store window IDs into the the threa local instead of the window scope ap to avoid memory leaks.

          Show
          Mircea Toma added a comment - Store window IDs into the the threa local instead of the window scope ap to avoid memory leaks.
          Mircea Toma made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19123 Mon Jul 27 15:46:13 MDT 2009 mircea.toma ICE-1393 Propagate window ID when form is posted by Mojarra.
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/javascript/application.js
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19521 Wed Oct 28 09:36:26 MDT 2009 ted.goddard catch exceptions to proceed if WindowScope is not available (ICE-1393)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowELResolver.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeSetup.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19543 Thu Oct 29 13:04:56 MDT 2009 ted.goddard replaced stack trace with WARNING log entry (ICE-1393)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/application/WindowScopeSetup.java
          Ken Fyten made changes -
          Salesforce Case []
          Fix Version/s 2.0-Alpha2 [ 10214 ]
          Fix Version/s 2.0-Alpha3 [ 10032 ]
          Ken Fyten made changes -
          Fix Version/s 2.0.0 [ 10230 ]
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Mircea Toma
              Reporter:
              Ted Goddard
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: