You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/06/20 17:03:26 UTC

svn commit: r956369 - in /click/trunk/click: extras/src/org/apache/click/extras/control/AbstractContainerField.java framework/src/org/apache/click/control/AbstractControl.java framework/src/org/apache/click/control/Field.java

Author: sabob
Date: Sun Jun 20 15:03:25 2010
New Revision: 956369

URL: http://svn.apache.org/viewvc?rev=956369&view=rev
Log:
AbstractControl should not render the name attribute. Only Fields should render a name. CLK-699

Modified:
    click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
    click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java
    click/trunk/click/framework/src/org/apache/click/control/Field.java

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java?rev=956369&r1=956368&r2=956369&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java Sun Jun 20 15:03:25 2010
@@ -409,6 +409,32 @@ public abstract class AbstractContainerF
     // Protected Methods ------------------------------------------------------
 
     /**
+     * Render the Container tag and common attributes including {@link #getId() id},
+     * <tt>class</tt> and <tt>style</tt>. The {@link #getName() name} attribute
+     * is <em>not</em> rendered by this container.
+     *
+     * @see org.apache.click.control.AbstractControl#renderTagBegin(java.lang.String, org.apache.click.util.HtmlStringBuffer)
+     *
+     * @param tagName the name of the tag to render
+     * @param buffer the buffer to append the output to
+     */
+    @Override
+    protected void renderTagBegin(String tagName, HtmlStringBuffer buffer) {
+        if (tagName == null) {
+            throw new IllegalStateException("Tag cannot be null");
+        }
+
+        buffer.elementStart(tagName);
+
+        String id = getId();
+        if (id != null) {
+            buffer.appendAttribute("id", id);
+        }
+
+        appendAttributes(buffer);
+    }
+
+    /**
      * @see org.apache.click.control.AbstractControl#renderTagEnd(java.lang.String, org.apache.click.util.HtmlStringBuffer)
      *
      * @param tagName the name of the tag to close

Modified: click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java?rev=956369&r1=956368&r2=956369&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java Sun Jun 20 15:03:25 2010
@@ -956,22 +956,28 @@ public abstract class AbstractControl im
     }
 
     /**
-     * Render the tag and common attributes.
+     * Render the tag and common attributes including {@link #getId() id},
+     * <tt>class</tt> and <tt>style</tt>. The {@link #getName() name} attribute
+     * is <em>not</em> rendered by this control. It is up to subclasses
+     * whether to render the name attribute or not. Generally only
+     * {@link org.apache.click.control.Field} controls render the name attribute.
      * <p/>
      * <b>Please note:</b> the tag will not be closed by this method. This
      * enables callers of this method to append extra attributes as needed.
      * <p/>
-     * For example the result of calling:
+     * For example the following example:
+     *
      * <pre class="prettyprint">
      * Field field = new TextField("mytext");
      * HtmlStringBuffer buffer = new HtmlStringBuffer();
-     * field.renderTagBegin("div", buffer);
-     * </pre>
-     * will be:
+     * field.renderTagBegin("input", buffer); </pre>
+     *
+     * will render:
+     *
      * <pre class="prettyprint">
-     * &lt;div name="mytext" id="mytext"
-     * </pre>
-     * <b>Note</b> that the tag is not closed, so subclasses can easily add more
+     * &lt;input name="mytext" id="mytext" </pre>
+     *
+     * <b>Note</b> that the tag is not closed, so subclasses can render extra
      * attributes.
      *
      * @param tagName the name of the tag to render
@@ -985,10 +991,6 @@ public abstract class AbstractControl im
 
         buffer.elementStart(tagName);
 
-        String controlName = getName();
-        if (controlName != null) {
-            buffer.appendAttribute("name", controlName);
-        }
         String id = getId();
         if (id != null) {
             buffer.appendAttribute("id", id);

Modified: click/trunk/click/framework/src/org/apache/click/control/Field.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Field.java?rev=956369&r1=956368&r2=956369&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Field.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Field.java Sun Jun 20 15:03:25 2010
@@ -1183,4 +1183,34 @@ public abstract class Field extends Abst
             return "";
         }
     }
+
+    /**
+     * Render the Field tag and common attributes including {@link #getName() name},
+     * {@link #getId() id}, <tt>class</tt> and <tt>style</tt>.
+     *
+     * @see org.apache.click.control.AbstractControl#renderTagBegin(java.lang.String, org.apache.click.util.HtmlStringBuffer)
+     *
+     * @param tagName the name of the tag to render
+     * @param buffer the buffer to append the output to
+     */
+    @Override
+    protected void renderTagBegin(String tagName, HtmlStringBuffer buffer) {
+        if (tagName == null) {
+            throw new IllegalStateException("Tag cannot be null");
+        }
+
+        buffer.elementStart(tagName);
+
+        String controlName = getName();
+        if (controlName != null) {
+            buffer.appendAttribute("name", controlName);
+        }
+
+        String id = getId();
+        if (id != null) {
+            buffer.appendAttribute("id", id);
+        }
+
+        appendAttributes(buffer);
+    }
 }