myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1622110 - in /myfaces/core/trunk: impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java
Date Tue, 02 Sep 2014 20:31:23 GMT
Author: lu4242
Date: Tue Sep  2 20:31:23 2014
New Revision: 1622110

URL: http://svn.apache.org/r1622110
Log:
MYFACES-3920 HtmlPanelGroup implements ClientBehaviorHolder, but does not render it's behaviors

Modified:
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java?rev=1622110&r1=1622109&r2=1622110&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java
(original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java
Tue Sep  2 20:31:23 2014
@@ -19,11 +19,14 @@
 package org.apache.myfaces.renderkit.html;
 
 import java.io.StringWriter;
+import javax.faces.component.behavior.AjaxBehavior;
 
 import javax.faces.component.html.HtmlOutputText;
 import javax.faces.component.html.HtmlPanelGroup;
 
 import junit.framework.Test;
+import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.fail;
 import junit.framework.TestSuite;
 
 import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
@@ -74,6 +77,8 @@ public class HtmlGroupRendererTest exten
                 panelChildOutputText.getFamily(),
                 panelChildOutputText.getRendererType(),
                 new HtmlTextRenderer());
+        facesContext.getRenderKit().addClientBehaviorRenderer(
+                AjaxBehavior.BEHAVIOR_ID, new HtmlAjaxBehaviorRenderer());
         
         facesContext.getAttributes().put("org.apache.myfaces.RENDERED_JSF_JS", Boolean.TRUE);
     }
@@ -87,6 +92,18 @@ public class HtmlGroupRendererTest exten
     public void testHtmlPropertyPassTru() throws Exception
     { 
         HtmlRenderedAttr[] attrs = {
+                //_EventProperties
+                new HtmlRenderedAttr("onclick"),
+                new HtmlRenderedAttr("ondblclick"), 
+                new HtmlRenderedAttr("onkeydown"), 
+                new HtmlRenderedAttr("onkeypress"),
+                new HtmlRenderedAttr("onkeyup"), 
+                new HtmlRenderedAttr("onmousedown"), 
+                new HtmlRenderedAttr("onmousemove"), 
+                new HtmlRenderedAttr("onmouseout"),
+                new HtmlRenderedAttr("onmouseover"), 
+                new HtmlRenderedAttr("onmouseup"),
+                //_StyleProperties
                 new HtmlRenderedAttr("style"), 
                 new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\"")
                 }; 
@@ -109,4 +126,20 @@ public class HtmlGroupRendererTest exten
             fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
         }
     }
+    
+    public void testClientBehaviorHolderRendersIdAndNameOutputLink() 
+    {
+        panelGroup.addClientBehavior("keypress", new AjaxBehavior());
+        try 
+        {
+            panelGroup.encodeAll(facesContext);
+            String output = ((StringWriter) writer.getWriter()).getBuffer().toString();
+            assertTrue(output.matches(".+id=\".+\".+"));
+            assertTrue(output.matches(".+jsf.ajax.request.+"));
+        }
+        catch (Exception e)
+        {
+            fail(e.getMessage());
+        }
+    }
 }

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java?rev=1622110&r1=1622109&r2=1622110&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGroupRendererBase.java
Tue Sep  2 20:31:23 2014
@@ -26,6 +26,10 @@ import javax.faces.component.html.HtmlPa
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import javax.faces.component.behavior.ClientBehavior;
+import org.apache.myfaces.shared.renderkit.html.util.ResourceUtils;
 
 public class HtmlGroupRendererBase
         extends HtmlRenderer 
@@ -64,23 +68,51 @@ public class HtmlGroupRendererBase
         {
             layoutElement = HTML.DIV_ELEM;
         }
+        
+        Map<String, List<ClientBehavior>> behaviors = panelGroup.getClientBehaviors();
+        if (behaviors != null && !behaviors.isEmpty())
+        {
+            ResourceUtils.renderDefaultJsfJsInlineIfNecessary(context, writer);
+        }
 
-        if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
+        if( (!behaviors.isEmpty()) || 
+                (component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)))
         {
             span = true;
 
             writer.startElement(layoutElement, component);
 
-            HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
+            //HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
+            writer.writeAttribute(HTML.ID_ATTR, component.getClientId(context), null);
 
+            long commonPropertiesMarked = 0L;
             if (isCommonPropertiesOptimizationEnabled(context))
             {
-                CommonPropertyUtils.renderCommonPassthroughProperties(writer, 
+                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
+                CommonPropertyUtils.renderCommonPassthroughPropertiesWithoutEvents(writer,

                         CommonPropertyUtils.getCommonPropertiesMarked(component), component);
             }
             else
             {
-                HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+                HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.UNIVERSAL_ATTRIBUTES);
+            }
+            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(context))
+            {
+                CommonPropertyUtils.renderEventProperties(writer, 
+                        commonPropertiesMarked, component);
+            }
+            else
+            {
+                if (isCommonEventsOptimizationEnabled(context))
+                {
+                    CommonEventUtils.renderBehaviorizedEventHandlers(context, writer, 
+                           commonPropertiesMarked,
+                           CommonEventUtils.getCommonEventsMarked(component), component,
behaviors);
+                }
+                else
+                {
+                    HtmlRendererUtils.renderBehaviorizedEventHandlers(context, writer, component,
behaviors);
+                }
             }
         }
         else



Mime
View raw message