diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-11-01 16:27:41 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-11-01 16:27:41 +0000 |
commit | 6c66e8bd084a8e2011c50b2dac25022f26208edf (patch) | |
tree | 6ce79e18dbab7f1f9681b296c9ee18435886b31b /src | |
parent | de8f324217d07886d43c76b492c8d32fcad88db2 (diff) | |
download | vaadin-framework-6c66e8bd084a8e2011c50b2dac25022f26208edf.tar.gz vaadin-framework-6c66e8bd084a8e2011c50b2dac25022f26208edf.zip |
Added CachingDemo; a small client-side caching demo.
svn changeset:2662/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/com/itmill/toolkit/demo/CachingDemo.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/demo/CachingDemo.java b/src/com/itmill/toolkit/demo/CachingDemo.java new file mode 100644 index 0000000000..afec85424f --- /dev/null +++ b/src/com/itmill/toolkit/demo/CachingDemo.java @@ -0,0 +1,50 @@ +package com.itmill.toolkit.demo;
+
+import com.itmill.toolkit.terminal.PaintException;
+import com.itmill.toolkit.terminal.PaintTarget;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.TabSheet;
+import com.itmill.toolkit.ui.Window;
+
+/**
+ * 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 CachingDemo extends com.itmill.toolkit.Application {
+
+ public void init() {
+
+ Window main = new Window("Client-side caching example");
+ setMainWindow(main);
+
+ setTheme("example");
+
+ TabSheet ts = new TabSheet();
+ ts.setCaption("setHeigth(300)");
+ main.addComponent(ts);
+ ts.setHeight(300);
+ Label l = new Label(
+ "A normal label, quick to render. The second tab will be slow to render the first time, after that it will be as quick as this one.");
+ ts.addTab(l, "Normal", null);
+ l = new Label(
+ "The first time you change to this tab, this label is very slow to produce (server-side). However, it will seem fast the second time you change to this tab, because it has not changed and is cached client-side.") {
+ public void paintContent(PaintTarget target) throws PaintException {
+ try {
+ Thread.sleep(3000);
+ } catch (Exception e) {
+ // IGNORED
+ }
+ super.paintContent(target);
+ }
+
+ };
+ ts.addTab(l, "Slow", null);
+
+ }
+
+}
|