click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r931069 - in /click/trunk/click/framework/src/org/apache/click: control/ dataprovider/ util/
Date Tue, 06 Apr 2010 10:00:13 GMT
Author: sabob
Date: Tue Apr  6 10:00:12 2010
New Revision: 931069

URL: http://svn.apache.org/viewvc?rev=931069&view=rev
Log:
refactored dataprovider into own package

Added:
    click/trunk/click/framework/src/org/apache/click/dataprovider/
    click/trunk/click/framework/src/org/apache/click/dataprovider/DataProvider.java
      - copied, changed from r922549, click/trunk/click/framework/src/org/apache/click/util/DataProvider.java
    click/trunk/click/framework/src/org/apache/click/dataprovider/PagingDataProvider.java
      - copied, changed from r928332, click/trunk/click/framework/src/org/apache/click/util/PagingDataProvider.java
    click/trunk/click/framework/src/org/apache/click/dataprovider/package.html
Removed:
    click/trunk/click/framework/src/org/apache/click/util/DataProvider.java
    click/trunk/click/framework/src/org/apache/click/util/PagingDataProvider.java
Modified:
    click/trunk/click/framework/src/org/apache/click/control/Select.java
    click/trunk/click/framework/src/org/apache/click/control/Table.java

Modified: click/trunk/click/framework/src/org/apache/click/control/Select.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Select.java?rev=931069&r1=931068&r2=931069&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Select.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Select.java Tue Apr  6 10:00:12
2010
@@ -27,7 +27,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import org.apache.click.util.ClickUtils;
-import org.apache.click.util.DataProvider;
+import org.apache.click.dataprovider.DataProvider;
 
 import org.apache.click.util.HtmlStringBuffer;
 import org.apache.click.util.PropertyUtils;
@@ -210,7 +210,7 @@ import org.apache.click.util.PropertyUti
  * A common issue new Click users face is which page event (onInit or onRender)
  * to populate the Select {@link #getOptionList() optionList} in. To alleviate
  * this problem you can set a
- * {@link #setDataProvider(org.apache.click.util.DataProvider) dataProvider}
+ * {@link #setDataProvider(org.apache.click.dataprovider.DataProvider) dataProvider}
  * which allows the Select to fetch data when needed. This is
  * particularly useful if retrieveing Select data is expensive e.g. loading
  * from a database.
@@ -328,7 +328,7 @@ public class Select extends Field {
     /**
      * The default option will be the first option added to the Select.
      * This property is often used when populating the Select from a
-     * {@link #setDataProvider(org.apache.click.util.DataProvider)}, where
+     * {@link #setDataProvider(org.apache.click.dataprovider.DataProvider)}, where
      * the DataProvider does not return a sensible default option e.g. an
      * empty ("") option.
      */
@@ -769,7 +769,7 @@ public class Select extends Field {
      * added to the Select {@link #getOptionList() optionList}.
      * <p/>
      * <b>Please note</b>: this property is used in conjunction with the Select
-     * {@link #setDataProvider(org.apache.click.util.DataProvider) dataProvider},
+     * {@link #setDataProvider(org.apache.click.dataprovider.DataProvider) dataProvider},
      * where the DataProvider does not return a sensible default, non-selecting
      * option. For example if the DataProvider returns a list of Authors from the
      * database, the list won't include a default empty ("") option to choose

Modified: click/trunk/click/framework/src/org/apache/click/control/Table.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Table.java?rev=931069&r1=931068&r2=931069&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Table.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Table.java Tue Apr  6 10:00:12
2010
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -34,9 +33,9 @@ import org.apache.click.element.CssImpor
 import org.apache.click.element.CssStyle;
 import org.apache.click.element.Element;
 import org.apache.click.util.ClickUtils;
-import org.apache.click.util.DataProvider;
+import org.apache.click.dataprovider.DataProvider;
 import org.apache.click.util.HtmlStringBuffer;
-import org.apache.click.util.PagingDataProvider;
+import org.apache.click.dataprovider.PagingDataProvider;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.math.NumberUtils;
 

Copied: click/trunk/click/framework/src/org/apache/click/dataprovider/DataProvider.java (from
r922549, click/trunk/click/framework/src/org/apache/click/util/DataProvider.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/dataprovider/DataProvider.java?p2=click/trunk/click/framework/src/org/apache/click/dataprovider/DataProvider.java&p1=click/trunk/click/framework/src/org/apache/click/util/DataProvider.java&r1=922549&r2=931069&rev=931069&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/DataProvider.java (original)
+++ click/trunk/click/framework/src/org/apache/click/dataprovider/DataProvider.java Tue Apr
 6 10:00:12 2010
@@ -16,12 +16,34 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.click.util;
+package org.apache.click.dataprovider;
 
 import java.io.Serializable;
 
 /**
  * An interface to provide data on demand to controls.
+ * <p/>
+ * Example usage:
+ *
+ * <pre class="prettyprint">
+ * public class MyPage extends Page {
+ *
+ *     private Table table = new Table("table");
+ *
+ *     public MyPage() {
+ *
+ *         ...
+ *
+ *         table.setDataProvider(new DataProvider<Customer>() {
+ *
+ *             // Return a list of customers
+ *             public List<Customer> getData() {
+ *
+ *                 return getCustomerService().getCustomers();
+ *             }
+ *         });
+ *     }
+ * } </pre>
  */
 public interface DataProvider<T> extends Serializable {
 

Copied: click/trunk/click/framework/src/org/apache/click/dataprovider/PagingDataProvider.java
(from r928332, click/trunk/click/framework/src/org/apache/click/util/PagingDataProvider.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/dataprovider/PagingDataProvider.java?p2=click/trunk/click/framework/src/org/apache/click/dataprovider/PagingDataProvider.java&p1=click/trunk/click/framework/src/org/apache/click/util/PagingDataProvider.java&r1=928332&r2=931069&rev=931069&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/PagingDataProvider.java (original)
+++ click/trunk/click/framework/src/org/apache/click/dataprovider/PagingDataProvider.java
Tue Apr  6 10:00:12 2010
@@ -16,10 +16,78 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.click.util;
+package org.apache.click.dataprovider;
 
 /**
- * An interface to provide paginated data to controls.
+ * An interface to provide paginated data on demand to controls. It allows
+ * specifying the total number of results represented by this DataProvider
+ * through the {@link #size()} method.
+ * <p/>
+ * Example usage:
+ *
+ * <pre class="prettyprint">
+ * public class MyPage extends Page {
+ *
+ *     private Table table = new Table("table");
+ *
+ *     public MyPage() {
+ *
+ *         ...
+ *
+ *         table.setDataProvider(new PagingDataProvider<Customer>() {
+ *
+ *             // Return a list of customers
+ *             public List<Customer> getData() {
+ *
+ *                 int start = table.getFirstRow();
+ *                 int count = table.getPageSize();
+ *
+ *                 return getCustomerService().getCustomers(start, count);
+ *             }
+ *
+ *             // Return the total number of customers to page over
+ *             public int size() {
+ *                 return getCustomerService().getNumberOfCustomers();
+ *             }
+ *         });
+ *     }
+ * } </pre>
+ *
+ * <b>Please note</b>: when providing paginated data to controls that support
+ * sorting e.g. Tables, you are responsible for sorting the data, as the Table
+ * does not have access to all the data.
+ * <p/>
+ * Here is an example demonstrating both paging and sorting:
+ *
+ * <pre class="prettyprint">
+ * public class MyPage extends Page {
+ *
+ *     private Table table = new Table("table");
+ *
+ *     public MyPage() {
+ *
+ *         ...
+ *
+ *         table.setDataProvider(new PagingDataProvider<Customer>() {
+ *
+ *             // Return a list of customers
+ *             public List<Customer> getData() {
+ *
+ *                 int start = table.getFirstRow();
+ *                 int count = table.getPageSize();
+ *                 String sortColumn = table.getSortedColumn();
+ *                 boolean ascending = table.isSortedAscending();
+ *
+ *                 return getCustomerService().getCustomers(start, count, sortColumn, ascending);
+ *             }
+ *
+ *             // Return the total number of customers to page over
+ *             public int size() {
+ *                 return getCustomerService().getNumberOfCustomers();
+ *             }
+ *         });
+ *     }
+ * } </pre>
  */
 public interface PagingDataProvider<T> extends DataProvider {
 

Added: click/trunk/click/framework/src/org/apache/click/dataprovider/package.html
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/dataprovider/package.html?rev=931069&view=auto
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/dataprovider/package.html (added)
+++ click/trunk/click/framework/src/org/apache/click/dataprovider/package.html Tue Apr  6
10:00:12 2010
@@ -0,0 +1,30 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+
+<body>
+DataProviders provide data on demand to controls.
+<p/>
+Core DataProviders are:
+<ul>
+    <li>{@link org.apache.click.dataprovider.DataProvider DataProvider}
+        - provides data on demand to controls</li>
+    <li>{@link org.apache.click.dataprovider.PagingDataProvider PagingDataProvider}
+        - provides paginated data on demand to controls</li>
+</ul>
+</body>
\ No newline at end of file



Mime
View raw message