You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/09/22 23:05:13 UTC

svn commit: r817840 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: application/ApplicationImpl.java lifecycle/RestoreViewExecutor.java view/facelets/DefaultFaceletsStateManagementStrategy.java

Author: lu4242
Date: Tue Sep 22 21:05:12 2009
New Revision: 817840

URL: http://svn.apache.org/viewvc?rev=817840&view=rev
Log:
MYFACES-2367 FacesContext.isProcessingEvents should be called from Application.publishEvent

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=817840&r1=817839&r2=817840&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Tue Sep 22 21:05:12 2009
@@ -446,7 +446,13 @@
     {
         checkNull(systemEventClass, "systemEventClass");
         checkNull(source, "source");
-
+        
+        //Call events only if event processing is enabled.
+        if (!facesContext.isProcessingEvents())
+        {
+            return;
+        }
+        
         try
         {
             SystemEvent event = null;

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java?rev=817840&r1=817839&r2=817840&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java Tue Sep 22 21:05:12 2009
@@ -89,24 +89,32 @@
             if (log.isTraceEnabled())
                 log.trace("Request is a postback");
 
-            // call ViewHandler.restoreView(), passing the FacesContext instance for the current request and the 
-            // view identifier, and returning a UIViewRoot for the restored view.
-            viewRoot = viewHandler.restoreView(facesContext, viewId);
-            if (viewRoot == null)
+            try
             {
-                // If the return from ViewHandler.restoreView() is null, throw a ViewExpiredException with an 
-                // appropriate error message.
-                throw new ViewExpiredException("No saved view state could be found for the view identifier: " + viewId,
-                    viewId);
+                facesContext.setProcessingEvents(false);
+                // call ViewHandler.restoreView(), passing the FacesContext instance for the current request and the 
+                // view identifier, and returning a UIViewRoot for the restored view.
+                viewRoot = viewHandler.restoreView(facesContext, viewId);
+                if (viewRoot == null)
+                {
+                    // If the return from ViewHandler.restoreView() is null, throw a ViewExpiredException with an 
+                    // appropriate error message.
+                    throw new ViewExpiredException("No saved view state could be found for the view identifier: " + viewId,
+                        viewId);
+                }
+                
+                // Restore binding
+                // This code was already called on UIViewRoot.processRestoreState, or if a StateManagementStrategy
+                // is used, it is called from there.
+                //restoreViewSupport.processComponentBinding(facesContext, viewRoot);
+                
+                // Store the restored UIViewRoot in the FacesContext.
+                facesContext.setViewRoot(viewRoot);
+            }
+            finally
+            {
+                facesContext.setProcessingEvents(true);
             }
-            
-            // Restore binding
-            // This code was already called on UIViewRoot.processRestoreState, or if a StateManagementStrategy
-            // is used, it is called from there.
-            //restoreViewSupport.processComponentBinding(facesContext, viewRoot);
-            
-            // Store the restored UIViewRoot in the FacesContext.
-            facesContext.setViewRoot(viewRoot);
         }
         else
         { // If the request is a non-postback

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java?rev=817840&r1=817839&r2=817840&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java Tue Sep 22 21:05:12 2009
@@ -131,12 +131,22 @@
             
             context.setViewRoot (view); 
             
-            //TODO: Why is necessary disable event processing?
-            context.setProcessingEvents (true);
-            vdl.buildView (context, view);
-            context.setProcessingEvents (false);
+            // TODO: Why is necessary enable event processing?
+            // ANS: On RestoreViewExecutor, setProcessingEvents is called first to false
+            // and then to true when postback. Since we need listeners registered to PostAddToViewEvent
+            // event to be handled, we should enable it again. We are waiting a response from EG about
+            // the behavior of those listeners, because for partial state saving we need this listeners
+            // be called from here and relocate components properly, but for now we have to let this code as is.
+            try 
+            {
+                context.setProcessingEvents (true);
+                vdl.buildView (context, view);
+            }
+            finally
+            {
+                context.setProcessingEvents (false);
+            }
         }
-        
         catch (Throwable e) {
             throw new FacesException ("unable to create view \"" + viewId + "\"", e);
         }