Author: ivaynberg Date: Sun May 20 12:46:03 2007 New Revision: 539923 URL: http://svn.apache.org/viewvc?view=rev&rev=539923 Log: add support for dataview in nav label
Modified: incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigatorLabel.java Modified: incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigatorLabel.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigatorLabel.java?view=diff&rev=539923&r1=539922&r2=539923 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigatorLabel.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/NavigatorLabel.java Sun May 20 12:46:03 2007 @@ -18,6 +18,7 @@ import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.model.AbstractReadOnlyModel; @@ -31,6 +32,25 @@ { private static final long serialVersionUID = 1L; + // TODO Factor this interface out and let dataview/datatable implement it + private static interface PageableComponent + { + /** + * @return total number of rows across all pages + */ + int getRowCount(); + + /** + * @return current page + */ + int getCurrentPage(); + + /** + * @return rows per page + */ + int getRowsPerPage(); + } + /** * @param id * component id @@ -39,6 +59,60 @@ */ public NavigatorLabel(final String id, final DataTable table) { + this(id, new PageableComponent() + { + + public int getCurrentPage() + { + return table.getCurrentPage(); + } + + public int getRowCount() + { + return table.getRowCount(); + } + + public int getRowsPerPage() + { + return table.getRowsPerPage(); + } + + }); + + } + + /** + * @param id + * component id + * @param table + * pageable view + */ + public NavigatorLabel(final String id, final DataView table) + { + this(id, new PageableComponent() + { + + public int getCurrentPage() + { + return table.getCurrentPage(); + } + + public int getRowCount() + { + return table.getRowCount(); + } + + public int getRowsPerPage() + { + return table.getItemsPerPage(); + } + + }); + + } + + private NavigatorLabel(final String id, final PageableComponent table) + { super(id, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @@ -61,4 +135,5 @@ } }); } + }