click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r931054 - /click/trunk/click/examples/src/org/apache/click/examples/page/table/FormTablePage.java
Date Tue, 06 Apr 2010 09:06:18 GMT
Author: sabob
Date: Tue Apr  6 09:06:18 2010
New Revision: 931054

URL: http://svn.apache.org/viewvc?rev=931054&view=rev
Log:
use dataprovider to load formtable data

Modified:
    click/trunk/click/examples/src/org/apache/click/examples/page/table/FormTablePage.java

Modified: click/trunk/click/examples/src/org/apache/click/examples/page/table/FormTablePage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/table/FormTablePage.java?rev=931054&r1=931053&r2=931054&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/table/FormTablePage.java
(original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/table/FormTablePage.java
Tue Apr  6 09:06:18 2010
@@ -39,6 +39,7 @@ import org.apache.click.extras.control.F
 import org.apache.click.extras.control.FormTable;
 import org.apache.click.extras.control.NumberField;
 import org.apache.click.util.Bindable;
+import org.apache.click.util.DataProvider;
 import org.springframework.stereotype.Component;
 
 /**
@@ -109,11 +110,7 @@ public class FormTablePage extends Borde
     public void onInit() {
         super.onInit();
 
-        // Please note the FormTable rowList MUST be populated before the
-        // control is processed, i.e. do not populate the FormTable in the
-        // Pages onRender() method.
-        List<Customer> customers = customerService.getCustomersSortedByName(NUM_ROWS);
-        table.setRowList(customers);
+        table.setDataProvider(createDataProvider());
     }
 
     public boolean onOkClick() {
@@ -140,12 +137,22 @@ public class FormTablePage extends Borde
         // the data context
         BaseContext.getThreadObjectContext().rollbackChanges();
 
-        List<Customer> customers = customerService.getCustomersSortedByName(NUM_ROWS);
+        // Refresh the FormTable rowList by setting a new DataProvider
+        table.setDataProvider(createDataProvider());
 
-        table.setRowList(customers);
+        // As form was cancelled, don't render the user submitted values
         table.setRenderSubmittedValues(false);
 
         return true;
     }
 
+    public DataProvider createDataProvider() {
+        DataProvider dp = new DataProvider() {
+            public List<Customer> getData() {
+                return customerService.getCustomersSortedByName(NUM_ROWS);
+            }
+        };
+
+        return dp;
+    }
 }



Mime
View raw message