myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1054627 - in /myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl: listener/request/FacesMessageObserver.java util/ConversationUtils.java
Date Mon, 03 Jan 2011 14:21:53 GMT
Author: gpetracek
Date: Mon Jan  3 14:21:52 2011
New Revision: 1054627

URL: http://svn.apache.org/viewvc?rev=1054627&view=rev
Log:
EXTCDI-116 workaround for owb issue

Removed:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/listener/request/FacesMessageObserver.java
Modified:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java?rev=1054627&r1=1054626&r2=1054627&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java
Mon Jan  3 14:21:52 2011
@@ -25,10 +25,13 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager;
 
 import org.apache.myfaces.extensions.cdi.core.impl.util.CodiUtils;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.JsfModuleConfig;
+import org.apache.myfaces.extensions.cdi.jsf.impl.listener.request.FacesMessageEntry;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.WindowContextIdHolderComponent;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.WindowHandler;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContextManager;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContext;
+import org.apache.myfaces.extensions.cdi.message.api.Message;
 
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -45,6 +48,7 @@ import java.util.Set;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * internal! utils
@@ -313,7 +317,11 @@ public class ConversationUtils
         storeCurrentViewIdAsOldViewId(FacesContext.getCurrentInstance());
 
         RequestCache.resetCache();
-        
+
+        //don't use @AfterFacesRequest event
+        //there might be an issue if the ServletRequestListener e.g. of OWB gets called earlier
+        saveFacesMessages(externalContext);
+
         if(windowHandler != null)
         {
             windowHandler.sendRedirect(externalContext, url, false);
@@ -325,6 +333,27 @@ public class ConversationUtils
         }
     }
 
+    private static void saveFacesMessages(ExternalContext externalContext)
+    {
+        JsfModuleConfig jsfModuleConfig = CodiUtils.getContextualReferenceByClass(JsfModuleConfig.class);
+
+        if(jsfModuleConfig != null && jsfModuleConfig.isAlwaysKeepMessages())
+        {
+            Map<String, Object> requestMap = externalContext.getRequestMap();
+
+            @SuppressWarnings({"unchecked"})
+            List<FacesMessageEntry> facesMessageEntryList =
+                    (List<FacesMessageEntry>)requestMap.get(Message.class.getName());
+
+            if(facesMessageEntryList == null)
+            {
+                facesMessageEntryList = new CopyOnWriteArrayList<FacesMessageEntry>();
+            }
+            getWindowContextManager().getCurrentWindowContext()
+                    .setAttribute(Message.class.getName(), facesMessageEntryList, true);
+        }
+    }
+
     private static boolean isMultipleRedirectDetected(ExternalContext externalContext)
     {
         return externalContext.getRequestMap().containsKey(REDIRECT_PERFORMED_KEY);



Mime
View raw message