From 9107b8d8c520bd297ed7685d7a8482d1078604e9 Mon Sep 17 00:00:00 2001 From: Teemu Pöntelin Date: Thu, 4 Dec 2014 20:09:42 +0200 Subject: Fix CustomLayout child rendering when template is missing (#8696) Change-Id: I8ce4fbc566f030bf22c555f68b97beb781b19805 --- .../ui/customlayout/CustomLayoutConnector.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/ui/customlayout/CustomLayoutConnector.java b/client/src/com/vaadin/client/ui/customlayout/CustomLayoutConnector.java index a37ce9af38..80979587b9 100644 --- a/client/src/com/vaadin/client/ui/customlayout/CustomLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/customlayout/CustomLayoutConnector.java @@ -34,6 +34,8 @@ import com.vaadin.ui.CustomLayout; public class CustomLayoutConnector extends AbstractLayoutConnector implements SimpleManagedLayout, Paintable { + private boolean templateUpdated; + @Override public CustomLayoutState getState() { return (CustomLayoutState) super.getState(); @@ -62,7 +64,7 @@ public class CustomLayoutConnector extends AbstractLayoutConnector implements } private void updateHtmlTemplate() { - if (getWidget().hasTemplate()) { + if (templateUpdated) { // We (currently) only do this once. You can't change the template // later on. return; @@ -76,14 +78,23 @@ public class CustomLayoutConnector extends AbstractLayoutConnector implements templateContents = getConnection().getResource( "layouts/" + templateName + ".html"); if (templateContents == null) { - templateContents = "Layout file layouts/" - + templateName - + ".html is missing. Components will be drawn for debug purposes."; + // Template missing -> show debug notice and render components + // in order. + getWidget() + .getElement() + .setInnerHTML( + "Layout file layouts/" + + templateName + + ".html is missing. Components will be drawn for debug purposes."); } } - getWidget().initializeHTML(templateContents, - getConnection().getThemeUri()); + if (templateContents != null) { + // Template ok -> initialize. + getWidget().initializeHTML(templateContents, + getConnection().getThemeUri()); + } + templateUpdated = true; } @Override -- cgit v1.2.3