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 2014/03/13 00:17:44 UTC

svn commit: r1576996 - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/view/facelets/component/ main/java/org/apache/myfaces/view/facelets/tag/jsf/ main/java/org/apache/myfaces/view/facelets/tag/jsf/html/ test/resources/org/apache/myfaces...

Author: lu4242
Date: Wed Mar 12 23:17:43 2014
New Revision: 1576996

URL: http://svn.apache.org/r1576996
Log:
MYFACES-3870 Attribute <jsf:element elementName="..."> is not working as expected

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/JsfLibrary.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java?rev=1576996&r1=1576995&r2=1576996&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java Wed Mar 12 23:17:43 2014
@@ -18,18 +18,60 @@
  */
 package org.apache.myfaces.view.facelets.component;
 
+import java.io.IOException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
 import javax.faces.render.Renderer;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
 
 /**
  *
  * @author Leonardo Uribe
  */
 @JSFRenderer(
-        renderKitId="HTML_BASIC",
-        family="javax.faces.Panel",
-        type="javax.faces.passthrough.Element")
+    renderKitId = "HTML_BASIC",
+    family = "javax.faces.Panel",
+    type = "javax.faces.passthrough.Element")
 public class JsfElementRenderer extends Renderer
 {
-    
+
+    public boolean getRendersChildren()
+    {
+        return true;
+    }
+
+    public void encodeBegin(FacesContext facesContext, UIComponent component)
+        throws IOException
+    {
+        ResponseWriter writer = facesContext.getResponseWriter();
+        String elementName = (String) 
+            component.getPassThroughAttributes().get(Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY);
+
+        if (elementName == null)
+        {
+            throw new FacesException("jsf:element with clientId"
+                + component.getClientId(facesContext) + " requires 'elementName' passthrough attribute");
+        }
+        writer.startElement(elementName, component);
+        HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
+    }
+
+    public void encodeChildren(FacesContext facesContext, UIComponent component)
+        throws IOException
+    {
+        RendererUtils.renderChildren(facesContext, component);
+    }
+
+    public void encodeEnd(FacesContext facesContext, UIComponent component)
+        throws IOException
+    {
+        ResponseWriter writer = facesContext.getResponseWriter();
+        String elementName = (String) component.getPassThroughAttributes().get(
+            Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY);
+        writer.endElement(elementName);
+    }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java?rev=1576996&r1=1576995&r2=1576996&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java Wed Mar 12 23:17:43 2014
@@ -33,7 +33,7 @@ abstract class _JsfElement extends UIPan
     _EventProperties, _FocusBlurProperties, _ChangeSelectProperties
 {
     public static final String COMPONENT_FAMILY = "javax.faces.Panel";
-    public static final String COMPONENT_TYPE = "javax.faces.Panel";
+    public static final String COMPONENT_TYPE = "oam.passthrough.Element";
     
     /**
      * HTML: Script to be invoked when the page is loaded

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/JsfLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/JsfLibrary.java?rev=1576996&r1=1576995&r2=1576996&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/JsfLibrary.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/JsfLibrary.java Wed Mar 12 23:17:43 2014
@@ -35,7 +35,7 @@ public final class JsfLibrary extends Ab
     {
         super(NAMESPACE, ALIAS_NAMESPACE);
         
-        this.addComponent("element", "javax.faces.Panel", 
+        this.addComponent("element", "oam.passthrough.Element", 
             "javax.faces.passthrough.Element", JsfElementHandler.class);
     }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java?rev=1576996&r1=1576995&r2=1576996&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java Wed Mar 12 23:17:43 2014
@@ -282,11 +282,6 @@ public class DefaultTagDecorator impleme
                 
                 convertedTagAttributes[j] = new TagAttributeImpl(tagAttribute.getLocation(), 
                     convertedNamespace, tagAttribute.getLocalName(), qname, tagAttribute.getValue());
-                
-                if (Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY.equals(tagAttribute.getLocalName()))
-                {
-                    elementNameTagAttributeSet = true;
-                }
             }
             else if (namespace == null)
             {
@@ -326,6 +321,13 @@ public class DefaultTagDecorator impleme
                 convertedTagAttributes[j] = new TagAttributeImpl(tagAttribute.getLocation(), 
                     convertedNamespace, tagAttribute.getLocalName(), qname, tagAttribute.getValue());
             }
+            
+            if (Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY.equals(convertedTagAttributes[j].getLocalName()) && (
+                PASS_THROUGH_NAMESPACE.equals(convertedTagAttributes[j].getNamespace()) || 
+                PASS_THROUGH_ALIAS_NAMESPACE.equals(convertedTagAttributes[j].getNamespace()) ) )
+            {
+                elementNameTagAttributeSet = true;
+            }
             j++;
         }
         

Modified: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml?rev=1576996&r1=1576995&r2=1576996&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml Wed Mar 12 23:17:43 2014
@@ -28,7 +28,7 @@
                placeholder="Enter text" 
                pt:data_up="Going Up"/>
         
-        <input jsf:id="box2" jsf:elementName="meter"
+        <input jsf:id="box2" pt:elementName="meter"
                jsf:value="#{test.value}" jsf:customAttr="SomeValue"
                placeholder="Enter text" 
                pt:data_up="Going Up">Hello World!</input>