myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r930075 - in /myfaces: core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/ shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/
Date Thu, 01 Apr 2010 20:25:29 GMT
Author: jakobk
Date: Thu Apr  1 20:25:28 2010
New Revision: 930075

URL: http://svn.apache.org/viewvc?rev=930075&view=rev
Log:
MYFACES-2624 Automatically add h:messages if ProjectStage is Development

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EndElementInstruction.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EndElementInstruction.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EndElementInstruction.java?rev=930075&r1=930074&r2=930075&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EndElementInstruction.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EndElementInstruction.java
Thu Apr  1 20:25:28 2010
@@ -22,8 +22,12 @@ import java.io.IOException;
 
 import javax.el.ELContext;
 import javax.el.ExpressionFactory;
+import javax.faces.application.ProjectStage;
 import javax.faces.context.FacesContext;
 
+import org.apache.myfaces.shared_impl.renderkit.html.HTML;
+import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils;
+
 final class EndElementInstruction implements Instruction
 {
     private final String element;
@@ -35,6 +39,15 @@ final class EndElementInstruction implem
 
     public void write(FacesContext context) throws IOException
     {
+        if (HTML.BODY_ELEM.equalsIgnoreCase(this.element))
+        {
+            // render all unhandled FacesMessages when ProjectStage is Development
+            if (context.isProjectStage(ProjectStage.Development))
+            {
+                HtmlRendererUtils.renderUnhandledFacesMessages(context);
+            }
+        }
+        
         context.getResponseWriter().endElement(this.element);
     }
 

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java?rev=930075&r1=930074&r2=930075&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
Thu Apr  1 20:25:28 2010
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
+import javax.faces.application.ProjectStage;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
 import javax.faces.component.behavior.ClientBehavior;
@@ -84,6 +85,13 @@ public class HtmlBodyRendererBase extend
         {
             child.encodeAll(facesContext);
         }
+        
+        // render all unhandled FacesMessages when ProjectStage is Development
+        if (facesContext.isProjectStage(ProjectStage.Development))
+        {
+            HtmlRendererUtils.renderUnhandledFacesMessages(facesContext);
+        }
+        
         writer.endElement(HTML.BODY_ELEM);
     }
 }

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?rev=930075&r1=930074&r2=930075&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
Thu Apr  1 20:25:28 2010
@@ -52,6 +52,7 @@ import javax.faces.component.behavior.Cl
 import javax.faces.component.behavior.ClientBehaviorHint;
 import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.component.html.HtmlDataTable;
+import javax.faces.component.html.HtmlMessages;
 import javax.faces.component.html.HtmlPanelGrid;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
@@ -2579,6 +2580,24 @@ public final class HtmlRendererUtils {
     }
     
     /**
+     * Renders all FacesMessages which have not been rendered yet with 
+     * the help of a HtmlMessages component. 
+     * @param facesContext
+     */
+    public static void renderUnhandledFacesMessages(FacesContext facesContext) throws IOException
+    {
+        // create and configure HtmlMessages component
+        HtmlMessages messages = (HtmlMessages) facesContext.getApplication()
+                                    .createComponent(HtmlMessages.COMPONENT_TYPE);
+        messages.setId("javax_faces_developmentstage_messages");
+        messages.setTitle("Project Stage[Development]: Unhandled Messages");
+        messages.setRedisplay(false);
+        
+        // render the component
+        messages.encodeAll(facesContext);
+    }
+    
+    /**
      * The ScriptContext offers methods and fields
      * to help with rendering out a script and keeping a
      * proper formatting.



Mime
View raw message