From 3810818a86ea77f3405fa975480cb847bd4a6a13 Mon Sep 17 00:00:00 2001 From: Jani Laakso Date: Tue, 24 Apr 2007 12:38:34 +0000 Subject: [PATCH] Added selectdemo back to trunk: major issues fixed. svn changeset:1315/svn branch:trunk --- WebContent/WEB-INF/web.xml | 13 ++++ WebContent/index.html | 14 ++++ src/com/itmill/toolkit/demo/SelectDemo.java | 74 +++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 src/com/itmill/toolkit/demo/SelectDemo.java diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index a7d76dadd1..2d860167fc 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -2,6 +2,19 @@ IT Mill Toolkit + + SelectDemo + com.itmill.toolkit.terminal.web.ApplicationServlet + + application + com.itmill.toolkit.demo.SelectDemo + + + + SelectDemo + /SelectDemo/* + + BufferedComponents com.itmill.toolkit.terminal.web.ApplicationServlet diff --git a/WebContent/index.html b/WebContent/index.html index 3e3c038125..4c4a5abc5d 100644 --- a/WebContent/index.html +++ b/WebContent/index.html @@ -11,6 +11,7 @@
+

Feature Browser

@@ -179,6 +180,19 @@ TreeFilesystem.java
+
+

Select demo

+
+

+ This example shows select component with default and lazy loading functionality enabled (a.k.a Google Suggest). + Click to first select component and type few letters using your keyboard to see it in action. + Second select component has default functionality. +

+
+ Source code: + SelectDemo.java +
+

FilterSelect demo

diff --git a/src/com/itmill/toolkit/demo/SelectDemo.java b/src/com/itmill/toolkit/demo/SelectDemo.java new file mode 100644 index 0000000000..e8a76d1686 --- /dev/null +++ b/src/com/itmill/toolkit/demo/SelectDemo.java @@ -0,0 +1,74 @@ +package com.itmill.toolkit.demo; + +import java.sql.SQLException; +import com.itmill.toolkit.data.util.QueryContainer; +import com.itmill.toolkit.demo.util.SampleDatabase; +import com.itmill.toolkit.ui.*; + +/** + * This example demonstrates what is lazy loading feature on Select component. + * Demo Uses similar concepts to QueryContainerDemo. + * + * @author IT Mill Ltd. + * @since 4.0.0 + * + */ +public class SelectDemo extends com.itmill.toolkit.Application { + + // Select component where SQL rows are attached (using QueryContainer) + private Select select = new Select(); + + private Select lazySelect = new Select(); + + // Database provided with sample data + private SampleDatabase sampleDatabase; + + /** + * Initialize Application. Demo components are added to main window. + */ + public void init() { + Window main = new Window("Select demo"); + setMainWindow(main); + + // set the application to use Corporate -theme + setTheme("corporate"); + + // Main window contains heading, table, select and tree + Panel panel = new Panel("Select demo (a.k.a Google Suggests)"); + panel.addComponent(lazySelect); + panel.addComponent(new Label("
", Label.CONTENT_XHTML)); + panel.addComponent(select); + main.addComponent(panel); + + // create demo database + sampleDatabase = new SampleDatabase(); + + initSelects(); + } + + private void initSelects() { + // init select + select.setCaption("All employees default functionality."); + select.setItemCaptionPropertyId("WORKER"); + // populate Toolkit select component with test SQL table rows + try { + QueryContainer qc = new QueryContainer( + "SELECT ID, UNIT||', '||LASTNAME||' '||FIRSTNAME" + + " AS WORKER FROM employee ORDER BY WORKER", + sampleDatabase.getConnection()); + select.setContainerDataSource(qc); + } catch (SQLException e) { + e.printStackTrace(); + } + + // init lazySelect + lazySelect.setCaption("All employees with lazy loading " + + "(a.k.a Google Suggests) activated."); + lazySelect.setItemCaptionPropertyId("WORKER"); + // use lazy loading (a.k.a Google Suggest) + lazySelect.setLazyLoading(true); + // use same datasource as select object uses + lazySelect.setContainerDataSource(select.getContainerDataSource()); + } + +} -- 2.39.5