Author: rich
Date: Wed Apr 27 00:21:32 2005
New Revision: 164955

URL: http://svn.apache.org/viewcvs?rev=164955&view=rev
Log:
Fix for http://issues.apache.org/jira/browse/BEEHIVE-566 : The JSF UI 
Components values are reverting when using NavigateTo.currentPage

tests: bvt in netui, bvt.myfaces and bvt.jsf-ri in netui/test/webapps/jsf
BB: self (linux)


Modified:
    
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
    
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/FacesBackingBeanFactory.java
    
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java?rev=164955&r1=164954&r2=164955&view=diff
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
 Wed Apr 27 00:21:32 2005
@@ -20,7 +20,9 @@
 import org.apache.beehive.netui.pageflow.PageFlowUtils;
 import org.apache.beehive.netui.pageflow.PageFlowController;
 import org.apache.beehive.netui.pageflow.PreviousPageInfo;
+import org.apache.beehive.netui.pageflow.FacesBackingBean;
 import org.apache.beehive.netui.pageflow.internal.PageFlowRequestWrapper;
+import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.util.internal.FileUtils;
 
 import javax.faces.application.ViewHandler;
@@ -30,6 +32,7 @@
 import javax.servlet.http.HttpServletRequest;
 import java.util.Locale;
 import java.io.IOException;
+import java.io.Serializable;
 
 
 /**
@@ -56,6 +59,28 @@
         return _delegate.calculateRenderKitId( context );
     }
 
+    private static class PageClientState implements Serializable
+    {
+        private UIViewRoot _viewRoot;
+        private FacesBackingBean _backingBean;
+
+        public PageClientState( UIViewRoot viewRoot, FacesBackingBean 
backingBean )
+        {
+            _viewRoot = viewRoot;
+            _backingBean = backingBean;
+        }
+
+        public UIViewRoot getViewRoot()
+        {
+            return _viewRoot;
+        }
+
+        public FacesBackingBean getBackingBean()
+        {
+            return _backingBean;
+        }
+    }
+    
     public UIViewRoot createView(FacesContext context, String viewId)
     {
         Object request = context.getExternalContext().getRequest();
@@ -74,9 +99,11 @@
             {
                 Object clientState = prevPageInfo.getClientState();
                 
-                if ( clientState != null && clientState instanceof UIViewRoot )
+                if ( clientState != null && clientState instanceof 
PageClientState )
                 {
-                    return ( UIViewRoot ) clientState;
+                    PageClientState pcs = ( PageClientState ) clientState;
+                    InternalUtils.setFacesBackingBean( httpRequest, 
pcs.getBackingBean() );
+                    return pcs.getViewRoot();
                 }
             }
         }
@@ -150,7 +177,8 @@
                 if ( viewID.equals( currentForwardPath ) )
                 {
                     PreviousPageInfo prevPageInfo = 
curPageFlow.getCurrentPageInfo();
-                    prevPageInfo.setClientState( viewRoot );
+                    FacesBackingBean backingBean = 
InternalUtils.getFacesBackingBean( request );
+                    prevPageInfo.setClientState( new PageClientState( 
viewRoot, backingBean ) );
                 }
             }
         }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/FacesBackingBeanFactory.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/FacesBackingBeanFactory.java?rev=164955&r1=164954&r2=164955&view=diff
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/FacesBackingBeanFactory.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/FacesBackingBeanFactory.java
 Wed Apr 27 00:21:32 2005
@@ -133,7 +133,6 @@
             //
             HttpServletRequest unwrappedRequest = 
PageFlowUtils.unwrapMultipart( request );
             ScopedServletUtils.removeScopedSessionAttr( FACES_BACKING_ATTR, 
unwrappedRequest );
-            request.getSession().removeAttribute( FACES_BACKING_ATTR );
         }
         else if ( currentBean != null )
         {

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java?rev=164955&r1=164954&r2=164955&view=diff
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
 Wed Apr 27 00:21:32 2005
@@ -658,11 +658,28 @@
     {
         if ( request instanceof HttpServletRequest )
         {
-            HttpSession session = ( ( HttpServletRequest ) request 
).getSession( false );
-            return session != null ? ( FacesBackingBean ) 
session.getAttribute( FACES_BACKING_ATTR ) : null;
+            HttpServletRequest unwrappedRequest = 
PageFlowUtils.unwrapMultipart( ( HttpServletRequest ) request );
+            return ( FacesBackingBean ) 
ScopedServletUtils.getScopedSessionAttr( FACES_BACKING_ATTR, unwrappedRequest );
         }
         
         return null;
+    }
+    
+    public static void setFacesBackingBean( ServletRequest request, 
FacesBackingBean bean )
+    {
+        if ( request instanceof HttpServletRequest )
+        {
+            HttpServletRequest unwrappedRequest = 
PageFlowUtils.unwrapMultipart( ( HttpServletRequest ) request );
+            
+            if ( bean == null )
+            {
+                ScopedServletUtils.removeScopedSessionAttr( 
FACES_BACKING_ATTR, unwrappedRequest );
+            }
+            else
+            {
+                ScopedServletUtils.setScopedSessionAttr( FACES_BACKING_ATTR, 
bean, unwrappedRequest );
+            }
+        }
     }
     
     public static String inferModulePathFromClassName( String className )


Reply via email to