myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r930098 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java
Date Thu, 01 Apr 2010 21:09:44 GMT
Author: jakobk
Date: Thu Apr  1 21:09:43 2010
New Revision: 930098

URL: http://svn.apache.org/viewvc?rev=930098&view=rev
Log:
MYFACES-2624 Automatically add h:messages if ProjectStage is Development (additionally log
all unhandled FacesMessages when not in Development mode)

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java?rev=930098&r1=930097&r2=930098&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java
Thu Apr  1 21:09:43 2010
@@ -19,9 +19,12 @@
 package org.apache.myfaces.lifecycle;
 
 import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.faces.FacesException;
 import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
@@ -41,6 +44,9 @@ import org.apache.myfaces.util.ExternalC
  */
 class RenderResponseExecutor implements PhaseExecutor
 {
+    
+    private static final Logger log = Logger.getLogger(RenderResponseExecutor.class.getName());
+    
     public boolean execute(FacesContext facesContext)
     {
         Application application = facesContext.getApplication();
@@ -105,6 +111,29 @@ class RenderResponseExecutor implements 
                     || (newViewId != null && !newViewId.equals(viewId)));
             
             viewHandler.renderView(facesContext, root);
+            
+            // log all unhandled FacesMessages, don't swallow them
+            if (!facesContext.getMessageList().isEmpty())
+            {
+                StringBuilder builder = new StringBuilder();
+                boolean shouldLog = false;
+                for (FacesMessage message : facesContext.getMessageList())
+                {
+                    if (!message.isRendered())
+                    {
+                        builder.append("\n- ");
+                        builder.append(message.getDetail());
+                        
+                        shouldLog = true;
+                    }
+                }
+                if (shouldLog)
+                {
+                    log.log(Level.WARNING, "There are some unhandled FacesMessages, " +
+                            "this means not every FacesMessage had a chance to be rendered.\n"
+
+                            "These unhandled FacesMessages are: " + builder.toString());
+                }
+            }
         }
         catch (IOException e)
         {



Mime
View raw message