diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-04-27 13:04:15 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-04-27 13:04:15 +0000 |
commit | 19ad7df367dab9ba22b024f641c001fbf100d79a (patch) | |
tree | 77c29d02c1aeb7d14ae3c74257c2807e41096ed7 /src/com/itmill | |
parent | b10f50ce72de52d1a48d10375277f435b2a83574 (diff) | |
download | vaadin-framework-19ad7df367dab9ba22b024f641c001fbf100d79a.tar.gz vaadin-framework-19ad7df367dab9ba22b024f641c001fbf100d79a.zip |
Merged:
Fix for #2864 - Added server side checks for currentPageFirstItemId & currentPageFirstItemIndex validity
svn changeset:7535/svn branch:6.0
Diffstat (limited to 'src/com/itmill')
-rw-r--r-- | src/com/itmill/toolkit/ui/Table.java | 37 |
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 { |