click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r933254 - in /click/trunk/click: documentation/xdocs/src/docbook/click/chapter-introduction.xml examples/src/org/apache/click/examples/page/introduction/SimpleTablePage.java
Date Mon, 12 Apr 2010 14:22:47 GMT
Author: sabob
Date: Mon Apr 12 14:22:46 2010
New Revision: 933254

URL: http://svn.apache.org/viewvc?rev=933254&view=rev
Log:
doco

Modified:
    click/trunk/click/documentation/xdocs/src/docbook/click/chapter-introduction.xml
    click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleTablePage.java

Modified: click/trunk/click/documentation/xdocs/src/docbook/click/chapter-introduction.xml
URL: http://svn.apache.org/viewvc/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-introduction.xml?rev=933254&r1=933253&r2=933254&view=diff
==============================================================================
--- click/trunk/click/documentation/xdocs/src/docbook/click/chapter-introduction.xml (original)
+++ click/trunk/click/documentation/xdocs/src/docbook/click/chapter-introduction.xml Mon Apr
12 14:22:46 2010
@@ -481,6 +481,15 @@ public HelloWorld extends Page {
         column.setDecorator(new LinkDecorator(table, links, "id"));
         column.setSortable(false);
         table.addColumn(column);
+
+        // Table rowList will be populated through a DataProvider which loads
+        // data on demand.
+        table.setDataProvider(new DataProvider() {
+
+            public List getData() {
+                return getCustomerService().getCustomers();
+            }
+        });
     }
     
     // ---------------------------------- Event Handlers
@@ -493,15 +502,6 @@ public HelloWorld extends Page {
         getCustomerService().deleteCustomer(id);
         return true;
     }
-    
-    /**
-     * @see Page#onRender()
-     */
-    @Override
-    public void onRender() {
-        List list = getCustomerService().getCustomersByName();
-        table.setRowList(list);
-    }
 }</programlisting>
 
     <calloutlist>
@@ -517,15 +517,17 @@ public HelloWorld extends Page {
 
     <para>In this Page code example a Table control is declared and a number of
     <ulink url="../../click-api/org/apache/click/control/Column.html">Column</ulink>
-    objects are added. An editLink
-    <ulink url="../../click-api/org/apache/click/control/PageLink.html">PageLink</ulink>
+    objects are added. We set the Table's
+    <ulink url="../../click-api/org/apache/click/dataprovider/DataProvider.html">DataProvider</ulink>
+    instance which provides data on demand to the table. Data retrieved from the
+    dataProvider will be used to populate the Table rowList before it is rendered.
+    An editLink <ulink url="../../click-api/org/apache/click/control/PageLink.html">PageLink</ulink>
     control is used as decorator for the "Action" column. This control navigates
     to the <classname>EditCustomer</classname> page. A deleteLink
     <ulink url="../../click-api/org/apache/click/control/ActionLink.html">ActionLink</ulink>
     control is also used as a decorator for the "Action" column. This control will
     invoke the Page <methodname>onDeleteClick()</methodname> method when it is
-    clicked. Finally we have the Page <methodname>onRender()</methodname> method
-    which is used to populate the Table control with rows before it is rendered.
+    clicked.
     </para>
 
     <para>In our Page template we simply reference the <varname>$table</varname>

Modified: click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleTablePage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleTablePage.java?rev=933254&r1=933253&r2=933254&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleTablePage.java
(original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleTablePage.java
Mon Apr 12 14:22:46 2010
@@ -41,10 +41,12 @@ public class SimpleTablePage extends Bor
     @Resource(name="customerService")
     private CustomerService customerService;
 
+    private Table table;
+
     // Constructor ------------------------------------------------------------
 
     public SimpleTablePage() {
-        Table table = new Table("table");
+        table = new Table("table");
 
         table.setClass(Table.CLASS_ITS);
 
@@ -53,13 +55,15 @@ public class SimpleTablePage extends Bor
         table.addColumn(new Column("email"));
         table.addColumn(new Column("investments"));
 
-        table.setDataProvider(new DataProvider<Customer>() {
-            public List<Customer> getData() {
-                return customerService.getCustomersSortedByName(10);
-            }
-        });
-
         addControl(table);
     }
 
+    /**
+     * @see Page#onRender()
+     */
+    @Override
+    public void onRender() {
+        List list = customerService.getCustomersSortedByName(10);
+        table.setRowList(list);
+    }
 }



Mime
View raw message