aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2011-11-04 12:23:49 +0000
committerArtur Signell <artur.signell@itmill.com>2011-11-04 12:23:49 +0000
commit61b7d6475115a4e163069ff902cf6cc18b66bd05 (patch)
treef59de8a3312c8ad468ed231e62d58f2ab86b934f /src
parentcaa856ff3685e4cb73c1c0697fd7e543110fb226 (diff)
downloadvaadin-framework-61b7d6475115a4e163069ff902cf6cc18b66bd05.tar.gz
vaadin-framework-61b7d6475115a4e163069ff902cf6cc18b66bd05.zip
#7839 Corrected cases where pagelength=0 or where number of children > pagebuffer size
svn changeset:21910/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/ui/Table.java50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 640fd927af..5efb2545e0 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -1582,13 +1582,14 @@ public class Table extends AbstractSelect implements Action.Container,
* @param firstIndex
* The position where new rows should be inserted
* @param rows
- * The number of rows that should be inserted
+ * The maximum number of rows that should be inserted at position
+ * firstIndex. Less rows will be inserted if the page buffer is
+ * too small.
* @return
*/
private Object[][] getVisibleCellsInsertIntoCache(int firstIndex, int rows) {
- Object[][] cells = getVisibleCellsNoCache(firstIndex, rows, false);
logger.finest("Insert " + rows + " rows at index " + firstIndex
- + " to existing page buffer with " + cells.length + " items");
+ + " to existing page buffer requested");
// Page buffer must not become larger than pageLength*cacheRate before
// or after the current page
@@ -1602,6 +1603,10 @@ public class Table extends AbstractSelect implements Action.Container,
+ (int) (getPageLength() * (1 + getCacheRate()));
int maxBufferSize = maxPageBufferIndex - minPageBufferIndex;
+ if (getPageLength() == 0) {
+ // If pageLength == 0 then all rows should be rendered
+ maxBufferSize = pageBuffer[0].length + rows;
+ }
/*
* Number of rows that were previously cached. This is not necessarily
* the same as pageLength if we do not have enough rows in the
@@ -1618,6 +1623,11 @@ public class Table extends AbstractSelect implements Action.Container,
*/
int firstIndexInPageBuffer = firstIndex - pageBufferFirstIndex;
+ /* If rows > size available in page buffer */
+ if (firstIndexInPageBuffer + rows > maxBufferSize) {
+ rows = maxBufferSize - firstIndexInPageBuffer;
+ }
+
/*
* "rows" rows will be inserted at firstIndex. Find out how many old
* rows fall outside the new buffer so we can unregister components in
@@ -1657,6 +1667,9 @@ public class Table extends AbstractSelect implements Action.Container,
}
}
+ /* Paint the new rows into a separate buffer */
+ Object[][] cells = getVisibleCellsNoCache(firstIndex, rows, false);
+
/*
* Create the new cache buffer and fill it with the data from the old
* buffer as well as the inserted rows.
@@ -2745,27 +2758,19 @@ public class Table extends AbstractSelect implements Action.Container,
target.startTag("prows");
- /*
- * Caching says we should cache the current page and
- * cacheRate*pageLength rows below it (and the same above). We only add
- * rows below in this case.
- */
- int maxRows = (int) (getPageLength() * (1 + getCacheRate()));
- if (!shouldHideAddedRows() && count > maxRows) {
- count = maxRows + 1;
- // delete the rows below, since they will fall beyond the cache
- // page.
- target.addAttribute("delbelow", true);
- }
-
- target.addAttribute("firstprowix", firstIx);
- target.addAttribute("numprows", count);
-
if (!shouldHideAddedRows()) {
logger.finest("Paint rows for add. Index: " + firstIx + ", count: "
- + count + ". Max rows: " + maxRows);
+ + count + ".");
+
// Partial row additions bypass the normal caching mechanism.
Object[][] cells = getVisibleCellsInsertIntoCache(firstIx, count);
+ if (cells[0].length < count) {
+ // delete the rows below, since they will fall beyond the cache
+ // page.
+ target.addAttribute("delbelow", true);
+ count = cells[0].length;
+ }
+
for (int indexInRowbuffer = 0; indexInRowbuffer < count; indexInRowbuffer++) {
final Object itemId = cells[CELL_ITEMID][indexInRowbuffer];
if (shouldHideNullSelectionItem()) {
@@ -2779,10 +2784,13 @@ public class Table extends AbstractSelect implements Action.Container,
}
} else {
logger.finest("Paint rows for remove. Index: " + firstIx
- + ", count: " + count + ". Max rows: " + maxRows);
+ + ", count: " + count + ".");
removeRowsFromCacheAndFillBottom(firstIx, count);
target.addAttribute("hide", true);
}
+
+ target.addAttribute("firstprowix", firstIx);
+ target.addAttribute("numprows", count);
target.endTag("prows");
}