summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-06-23 23:20:59 +0300
committerHenri Sara <hesara@vaadin.com>2015-07-04 13:22:12 +0300
commite915983a31cb771d1d4cc19ec9f33e3bba7bc8f1 (patch)
tree5c0b29576ee7dac498cb8ee3138f8b2f1b60098c /server
parentf2c15fe78724cb79ec6de58605abdbbc61dd47c5 (diff)
downloadvaadin-framework-e915983a31cb771d1d4cc19ec9f33e3bba7bc8f1.tar.gz
vaadin-framework-e915983a31cb771d1d4cc19ec9f33e3bba7bc8f1.zip
Handle nested GridLayouts in declarative format correctly (#18312)
Change-Id: Ie26a6d310dbeb4dbaa8a5c91782f94677639ddca
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/GridLayout.java12
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java33
2 files changed, 41 insertions, 4 deletions
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java
index 6ccb272704..792ad72dcc 100644
--- a/server/src/com/vaadin/ui/GridLayout.java
+++ b/server/src/com/vaadin/ui/GridLayout.java
@@ -1319,11 +1319,15 @@ public class GridLayout extends AbstractLayout implements
setMargin(readMargin(design, getMargin(), designContext));
- // Prepare a 2D map for reading column contents
- Elements rowElements = design.getElementsByTag("row");
+ List<Element> rowElements = new ArrayList<Element>();
List<Map<Integer, Component>> rows = new ArrayList<Map<Integer, Component>>();
- for (int i = 0; i < rowElements.size(); ++i) {
- rows.add(new HashMap<Integer, Component>());
+ // Prepare a 2D map for reading column contents
+ for (Element e : design.children()) {
+ if (e.tagName().equalsIgnoreCase("row")) {
+ rowElements.add(e);
+ rows.add(new HashMap<Integer, Component>());
+
+ }
}
setRows(Math.max(rows.size(), 1));
diff --git a/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
index 9d3b5001da..d69fd92984 100644
--- a/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
@@ -203,4 +203,37 @@ public class GridLayoutDeclarativeTest extends
}
return result;
}
+
+ @Test
+ public void testNestedGridLayouts() {
+ String design = "<!DOCTYPE html>" + //
+ "<html>" + //
+ " <body> " + //
+ " <v-grid-layout> " + //
+ " <row> " + //
+ " <column> " + //
+ " <v-grid-layout> " + //
+ " <row> " + //
+ " <column> " + //
+ " <v-button>" + //
+ " Button " + //
+ " </v-button> " + //
+ " </column> " + //
+ " </row> " + //
+ " </v-grid-layout> " + //
+ " </column> " + //
+ " </row> " + //
+ " </v-grid-layout> " + //
+ " </body>" + //
+ "</html>";
+ GridLayout outer = new GridLayout();
+ GridLayout inner = new GridLayout();
+ Button b = new Button("Button");
+ b.setCaptionAsHtml(true);
+ inner.addComponent(b);
+ outer.addComponent(inner);
+ testRead(design, outer);
+ testWrite(design, outer);
+
+ }
}