aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/itmill/toolkit/ui/Table.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java
index 4d4fdba7fb..083b393aa8 100644
--- a/src/com/itmill/toolkit/ui/Table.java
+++ b/src/com/itmill/toolkit/ui/Table.java
@@ -822,8 +822,23 @@ public class Table extends AbstractSelect implements Action.Container,
}
}
- // If the search for item index was successfull
+ // If the search for item index was successful
if (index >= 0) {
+ /*
+ * The table is not capable of displaying an item in the container
+ * as the first if there are not enough items following the selected
+ * item so the whole table (pagelength) is filled.
+ */
+ int maxIndex = size() - pageLength;
+ if (maxIndex < 0) {
+ maxIndex = 0;
+ }
+
+ if (index > maxIndex) {
+ setCurrentPageFirstItemIndex(maxIndex);
+ return;
+ }
+
this.currentPageFirstItemId = currentPageFirstItemId;
currentPageFirstItemIndex = index;
}
@@ -1087,14 +1102,26 @@ public class Table extends AbstractSelect implements Action.Container,
private void setCurrentPageFirstItemIndex(int newIndex,
boolean needsPageBufferReset) {
- // Ensures that the new value is valid
- if (newIndex >= size()) {
- newIndex = size() - pageLength;
- }
+
if (newIndex < 0) {
newIndex = 0;
}
+ /*
+ * The table is not capable of displaying an item in the container as
+ * the first if there are not enough items following the selected item
+ * so the whole table (pagelength) is filled.
+ */
+ int maxIndex = size() - pageLength;
+ if (maxIndex < 0) {
+ maxIndex = 0;
+ }
+
+ // Ensures that the new value is valid
+ if (newIndex > maxIndex) {
+ newIndex = maxIndex;
+ }
+
// Refresh first item id
if (items instanceof Container.Indexed) {
try {