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 2009/05/12 19:27:49 UTC

svn commit: r773991 - /incubator/click/trunk/click/extras/src/org/apache/click/extras/control/FormTable.java

Author: sabob
Date: Tue May 12 17:27:49 2009
New Revision: 773991

URL: http://svn.apache.org/viewvc?rev=773991&view=rev
Log:
added support for headElements to FormTable

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/FormTable.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/FormTable.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/FormTable.java?rev=773991&r1=773990&r2=773991&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/FormTable.java (original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/FormTable.java Tue May 12 17:27:49 2009
@@ -18,9 +18,7 @@
  */
 package org.apache.click.extras.control;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.click.Context;
 import org.apache.click.control.Button;
@@ -310,6 +308,8 @@
      * Return the HTML head element import string. This method will also include
      * the imports of the form and the contained fields.
      *
+     * @deprecated use the new {@link #getHeadElements()} instead
+     *
      * @see org.apache.click.Control#getHtmlImports()
      *
      * @return the HTML head element import string
@@ -318,6 +318,10 @@
         HtmlStringBuffer buffer = new HtmlStringBuffer(255);
 
         buffer.append(super.getHtmlImports());
+        String htmlImports = getControlLink().getHtmlImports();
+        if (htmlImports != null) {
+            buffer.append(htmlImports);
+        }
 
         int firstRow = getFirstRow();
         int lastRow = getLastRow();
@@ -330,7 +334,7 @@
                 for (int j = firstRow; j < lastRow; j++) {
                     field.setName(column.getName() + "_" + j);
 
-                    String htmlImports = field.getHtmlImports();
+                    htmlImports = field.getHtmlImports();
                     if (htmlImports != null) {
                         buffer.append(htmlImports);
                     }
@@ -342,6 +346,38 @@
     }
 
     /**
+     * Return the HEAD elements for the Control. This method will include the
+     * HEAD elements of the contained fields.
+     *
+     * @see org.apache.click.Control#getHtmlImports()
+     *
+     * @return the list of HEAD elements
+     */
+    public List getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+            headElements.addAll(getControlLink().getHeadElements());
+
+            int firstRow = getFirstRow();
+            int lastRow = getLastRow();
+
+            for (int i = 0; i < getColumnList().size(); i++) {
+                Column column = (Column) getColumnList().get(i);
+                if (column instanceof FieldColumn) {
+                    Field field = ((FieldColumn) column).getField();
+
+                    for (int j = firstRow; j < lastRow; j++) {
+                        field.setName(column.getName() + "_" + j);
+
+                        headElements.addAll(field.getHeadElements());
+                    }
+                }
+            }
+        }
+        return headElements;
+    }
+
+    /**
      * @see org.apache.click.Control#setName(String)
      *
      * @param name of the control
@@ -458,8 +494,6 @@
             List rowList = getRowList();
             List columnList = getColumnList();
 
-            Map ognlContext = new HashMap();
-
             for (int i = firstRow; i < lastRow; i++) {
                 Object row = rowList.get(i);
 
@@ -526,14 +560,16 @@
     public void render(HtmlStringBuffer buffer) {
         if (useInternalForm) {
             buffer.append(getForm().startTag());
-        }
 
-        super.render(buffer);
+            // Render the Table
+            super.render(buffer);
 
-        if (useInternalForm) {
             renderButtons(buffer);
 
             buffer.append(getForm().endTag());
+
+        } else {
+            super.render(buffer);
         }
     }