]> source.dussan.org Git - vaadin-framework.git/commitdiff
Explicitly paint CustomLayout to send template to the client (#8688)
authorLeif Åstrand <leif@vaadin.com>
Wed, 18 Apr 2012 14:07:16 +0000 (17:07 +0300)
committerLeif Åstrand <leif@vaadin.com>
Wed, 18 Apr 2012 14:07:16 +0000 (17:07 +0300)
src/com/vaadin/ui/CustomLayout.java

index 0d74fe98785dfe64991b174c7f36b37d8c730c35..97cea1c49dd2a0f825c6b11af9e866bd8d41c7f0 100644 (file)
@@ -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;
 
 /**
  * <p>
@@ -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<String, Object> 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<Object> usedResources = ((JsonPaintTarget) target)
+                    .getUsedResources();
+            String resourceName = "layouts/" + templateName + ".html";
+            usedResources.add(resourceName);
+        }
+    }
+
 }