Author: nbelaevski
Date: 2009-03-27 15:41:21 -0400 (Fri, 27 Mar 2009)
New Revision: 13273
Modified:
trunk/ui/datascroller/src/main/config/component/datascroller.xml
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
Log:
https://jira.jboss.org/jira/browse/RF-6637
Modified: trunk/ui/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- trunk/ui/datascroller/src/main/config/component/datascroller.xml 2009-03-27 18:46:19
UTC (rev 13272)
+++ trunk/ui/datascroller/src/main/config/component/datascroller.xml 2009-03-27 19:41:21
UTC (rev 13273)
@@ -321,6 +321,12 @@
<description>HTML: script expression; a page is changed</description>
</property>
+ <property>
+ <name>showShortLastPage</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
+
<property hidden="true" existintag="false"
exist="false" >
<name>firstRow</name>
<classname>int</classname>
Modified: trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
===================================================================
---
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2009-03-27
18:46:19 UTC (rev 13272)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2009-03-27
19:41:21 UTC (rev 13273)
@@ -206,6 +206,10 @@
public abstract void setInactiveStyleClass(String inactiveStyleClass);
public abstract void setInactiveStyle(String inactiveStyle);
+
+ public abstract boolean isShowShortLastPage();
+ public abstract void setShowShortLastPage(boolean showShortLastPage);
+
/**
* Finds the dataTable which id is mapped to the "for" property
*
@@ -325,7 +329,10 @@
public int getPageCount(UIData data) {
int rowCount = getRowCount(data);
int rows = getRows(data);
-
+ return getPageCount(data, rowCount, rows);
+ }
+
+ public int getPageCount(UIData data, int rowCount, int rows) {
int pageCount;
if (rows > 0) {
pageCount = rows <= 0 ? 1 : rowCount / rows;
@@ -438,7 +445,10 @@
public void setupFirstRowValue() {
UIData dataTable = getDataTable();
if (isRendered()) {
- Integer pageCount = getPageCount(dataTable);
+ int rowCount = getRowCount(dataTable);
+ int rows = getRows(dataTable);
+
+ Integer pageCount = getPageCount(dataTable, rowCount, rows);
int page = getPage();
int newPage = -1;
@@ -461,7 +471,18 @@
}
if (isRendered(dataTable)) {
- dataTable.setFirst((page - 1) * getRows(dataTable));
+ int first;
+
+ if (page != pageCount || isShowShortLastPage()) {
+ first = (page - 1) * rows;
+ } else {
+ first = rowCount - rows;
+ if (first < 0) {
+ first = 0;
+ }
+ }
+
+ dataTable.setFirst(first);
}
}
}