]> source.dussan.org Git - vaadin-framework.git/commitdiff
#5916 Table.ColumnGenerator should allow generation of plain text
authorArtur Signell <artur.signell@itmill.com>
Thu, 11 Aug 2011 12:48:51 +0000 (12:48 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 11 Aug 2011 12:48:51 +0000 (12:48 +0000)
svn changeset:20302/svn branch:6.7

src/com/vaadin/ui/Table.java

index 572dececc32f274ce45d17d54f6b4478c15ec7ee..1098b47e1c4268952113417615a8739f862cdbfe 100644 (file)
@@ -1559,7 +1559,12 @@ public class Table extends AbstractSelect implements Action.Container,
                             ColumnGenerator cg = columnGenerators
                                     .get(colids[j]);
                             value = cg.generateCell(this, id, colids[j]);
-
+                            if (!(value instanceof Component)
+                                    && !(value instanceof String)) {
+                                // Avoid errors if a generator returns something
+                                // other than a Component or a String
+                                value = value.toString();
+                            }
                         } else if (iscomponent[j]) {
                             value = p.getValue();
                             listenProperty(p, oldListenedProperties);
@@ -3845,9 +3850,11 @@ public class Table extends AbstractSelect implements Action.Container,
          * @param columnId
          *            the id for the generated column (as specified in
          *            addGeneratedColumn)
-         * @return
+         * @return A {@link Component} that should be rendered in the cell or a
+         *         {@link String} that should be displayed in the cell. Other
+         *         return values are not supported.
          */
-        public abstract Component generateCell(Table source, Object itemId,
+        public abstract Object generateCell(Table source, Object itemId,
                 Object columnId);
     }