click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r965022 - /click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelTableExportPage.java
Date Sat, 17 Jul 2010 06:54:53 GMT
Author: sabob
Date: Sat Jul 17 06:54:53 2010
New Revision: 965022

URL: http://svn.apache.org/viewvc?rev=965022&view=rev
Log:
switched example to a DataProvider

Modified:
    click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelTableExportPage.java

Modified: click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelTableExportPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelTableExportPage.java?rev=965022&r1=965021&r2=965022&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelTableExportPage.java
(original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelTableExportPage.java
Sat Jul 17 06:54:53 2010
@@ -22,11 +22,11 @@ import java.util.List;
 
 import javax.annotation.Resource;
 
-import org.apache.click.Page;
 import org.apache.click.control.AbstractLink;
 import org.apache.click.control.Column;
 import org.apache.click.control.PageLink;
 import org.apache.click.control.Table;
+import org.apache.click.dataprovider.DataProvider;
 import org.apache.click.examples.control.exporter.ExcelTableExporter;
 import org.apache.click.examples.control.exporter.ExportTable;
 import org.apache.click.examples.domain.Customer;
@@ -73,23 +73,27 @@ public class ExcelTableExportPage extend
         setupExporter(table3);
         table3.setExportAttachment(ExportTable.EXPORTER_INLINE);
 
+        // A simple caching dataProvider that only retrieves customers once
+        DataProvider dataProvider = new DataProvider() {
+
+            List<Customer> customers;
+
+            public List<Customer> getData() {
+                if (customers == null) {
+                    customers = customerService.getCustomersSortedByName(10);
+                }
+                return customers;
+            }
+        };
+
         addControl(table1);
+        table1.setDataProvider(dataProvider);
         addControl(table2);
+        table2.setDataProvider(dataProvider);
         addControl(table3);
-        addControl(editLink);
-    }
-
-    // Event Handlers ---------------------------------------------------------
+        table3.setDataProvider(dataProvider);
 
-    /**
-     * @see Page#onRender()
-     */
-    @Override
-    public void onRender() {
-        List<Customer> customers = customerService.getCustomersSortedByName(10);
-        table1.setRowList(customers);
-        table2.setRowList(customers);
-        table3.setRowList(customers);
+        addControl(editLink);
     }
 
     //  Private Methods --------------------------------------------------------



Mime
View raw message