aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2007-11-29 09:02:35 +0000
committerMarc Englund <marc.englund@itmill.com>2007-11-29 09:02:35 +0000
commit350b6b063eb86122787ee6582d9a0bc92fde80d6 (patch)
tree917e87a85ee8d64c3cfdccadad9bcf8d4a5c40d8 /src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java
parent1c63d43f7cab7f0307e132fb14f3f15415aec9b5 (diff)
downloadvaadin-framework-350b6b063eb86122787ee6582d9a0bc92fde80d6.tar.gz
vaadin-framework-350b6b063eb86122787ee6582d9a0bc92fde80d6.zip
Pre-refactor commit.
svn changeset:3033/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java')
-rw-r--r--src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java
new file mode 100644
index 0000000000..235fe9c466
--- /dev/null
+++ b/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java
@@ -0,0 +1,66 @@
+package com.itmill.toolkit.demo.featurebrowser;
+
+import com.itmill.toolkit.terminal.PaintException;
+import com.itmill.toolkit.terminal.PaintTarget;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Layout;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.TabSheet;
+
+/**
+ * This example is a (simple) demonstration of client-side caching. The content
+ * in one tab is intentionally made very slow to produce server-side. When the
+ * user changes to this tab for the first time, there will be a 3 second wait
+ * before the content shows up, but the second time it shows up immediately
+ * since the content has not changed and is cached client-side.
+ *
+ * @author IT Mill Ltd.
+ */
+public class ClientCachingExample extends CustomComponent {
+
+ private static final String msg = "This example is a (simple) demonstration of client-side caching."
+ + " The content in one tab is intentionally made very slow to"
+ + " 'produce' server-side. When you changes to this tab for the"
+ + " first time, there will be a 3 second wait before the content"
+ + " shows up, but the second time it shows up immediately since the"
+ + " content has not changed and is cached client-side.";
+
+ public ClientCachingExample() {
+
+ OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ main.addComponent(new Label(msg));
+
+ TabSheet ts = new TabSheet();
+ main.addComponent(ts);
+
+ Layout layout = new OrderedLayout();
+ layout.setMargin(true);
+ Label l = new Label("This is a normal label, quick to render.");
+ l.setCaption("A normal label");
+ layout.addComponent(l);
+
+ ts.addTab(layout, "Normal", null);
+
+ layout = new OrderedLayout();
+ layout.setMargin(true);
+ l = new Label("Slow label - until cached client side.") {
+ public void paintContent(PaintTarget target) throws PaintException {
+ try {
+ Thread.sleep(3000);
+ } catch (Exception e) {
+ // IGNORED
+ }
+ super.paintContent(target);
+ }
+
+ };
+ l.setCaption("A slow label");
+ layout.addComponent(l);
+ ts.addTab(layout, "Slow", null);
+
+ }
+}