aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/demo/featurebrowser/ClientCachingExample.java
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
committerHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
commitadc8c0ad3573272c236040c3a76005b9e73a5737 (patch)
treea3860704dbd5b82dc6af38684b80f8ef79a32722 /src/com/vaadin/demo/featurebrowser/ClientCachingExample.java
parent5abc870dda584d0c2fc47fd5eec4ae3de3fa240e (diff)
downloadvaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.tar.gz
vaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.zip
#2904: initial bulk rename "com.itmill.toolkit" -> "com.vaadin"
- com.itmill.toolkit.external not yet fully renamed svn changeset:7715/svn branch:6.0
Diffstat (limited to 'src/com/vaadin/demo/featurebrowser/ClientCachingExample.java')
-rw-r--r--src/com/vaadin/demo/featurebrowser/ClientCachingExample.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/com/vaadin/demo/featurebrowser/ClientCachingExample.java b/src/com/vaadin/demo/featurebrowser/ClientCachingExample.java
new file mode 100644
index 0000000000..4f8cad2448
--- /dev/null
+++ b/src/com/vaadin/demo/featurebrowser/ClientCachingExample.java
@@ -0,0 +1,71 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.demo.featurebrowser;
+
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * 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() {
+
+ final VerticalLayout main = new VerticalLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ main.addComponent(new Label(msg));
+
+ final TabSheet ts = new TabSheet();
+ main.addComponent(ts);
+
+ Layout layout = new VerticalLayout();
+ 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 VerticalLayout();
+ layout.setMargin(true);
+ l = new Label("Slow label - until cached client side.") {
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ try {
+ Thread.sleep(3000);
+ } catch (final Exception e) {
+ // IGNORED
+ }
+ super.paintContent(target);
+ }
+
+ };
+ l.setCaption("A slow label");
+ layout.addComponent(l);
+ ts.addTab(layout, "Slow", null);
+
+ }
+}