From 0d95a362d9ee1a163affbbefb820ecdf75f21da0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 18 Apr 2012 17:07:16 +0300 Subject: [PATCH] Explicitly paint CustomLayout to send template to the client (#8688) --- src/com/vaadin/ui/CustomLayout.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/com/vaadin/ui/CustomLayout.java b/src/com/vaadin/ui/CustomLayout.java index 0d74fe9878..97cea1c49d 100644 --- a/src/com/vaadin/ui/CustomLayout.java +++ b/src/com/vaadin/ui/CustomLayout.java @@ -9,8 +9,14 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import com.vaadin.terminal.PaintException; +import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.customlayout.CustomLayoutState; +import com.vaadin.terminal.gwt.server.JsonPaintTarget; /** *

@@ -42,7 +48,7 @@ import com.vaadin.terminal.gwt.client.ui.customlayout.CustomLayoutState; * @since 3.0 */ @SuppressWarnings("serial") -public class CustomLayout extends AbstractLayout { +public class CustomLayout extends AbstractLayout implements Vaadin6Component { private static final int BUFFER_SIZE = 10000; @@ -299,4 +305,20 @@ public class CustomLayout extends AbstractLayout { "CustomLayout does not support margins."); } + public void changeVariables(Object source, Map variables) { + // Nothing to see here + } + + public void paintContent(PaintTarget target) throws PaintException { + // Workaround to make the CommunicationManager read the template file + // and send it to the client + String templateName = getState().getTemplateName(); + if (templateName != null && templateName.length() != 0) { + Set usedResources = ((JsonPaintTarget) target) + .getUsedResources(); + String resourceName = "layouts/" + templateName + ".html"; + usedResources.add(resourceName); + } + } + } -- 2.39.5