diff options
author | Tatu Lund <tatu@vaadin.com> | 2021-11-03 14:01:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-03 14:01:48 +0200 |
commit | b62869bfb112317fd2f5cdeaff954241b03b8191 (patch) | |
tree | 57683851a9c94c32349276761e706dc5874ea0b6 /server | |
parent | ce9b77a43f76251727b28c9429c540a5d60ccf23 (diff) | |
download | vaadin-framework-b62869bfb112317fd2f5cdeaff954241b03b8191.tar.gz vaadin-framework-b62869bfb112317fd2f5cdeaff954241b03b8191.zip |
feat: Add better API to configure maximum allowed rows (#12466)
* feat: Add better API to configure maximum allowed rows
* Add unit test
Co-authored-by: Olli Tietäväinen <ollit@vaadin.com>
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/data/provider/DataCommunicator.java | 18 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java | 8 |
2 files changed, 22 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java index 8d974c85d3..097cef622d 100644 --- a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java +++ b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java @@ -60,7 +60,7 @@ import elemental.json.JsonObject; public class DataCommunicator<T> extends AbstractExtension { private Registration dataProviderUpdateRegistration; - private static final int MAXIMUM_ALLOWED_ROWS = 500; + private int maximumAllowedRows = 500; /** * Simple implementation of collection data provider communication. All data @@ -316,14 +316,24 @@ public class DataCommunicator<T> extends AbstractExtension { } /** - * Set the maximum allowed rows to be fetched in one query. + * Get the maximum allowed rows to be fetched in one query. * * @return Maximum allowed rows for one query. * @since 8.14.1 */ protected int getMaximumAllowedRows() { - return MAXIMUM_ALLOWED_ROWS; - } + return maximumAllowedRows; + } + + /** + * Set the maximum allowed rows to be fetched in one query. + * + * @param maximumAllowedRows Maximum allowed rows for one query. + * @since + */ + public void setMaximumAllowedRows(int maximumAllowedRows) { + this.maximumAllowedRows = maximumAllowedRows; + } /** * Triggered when rows have been dropped from the client side cache. diff --git a/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java b/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java index ed681f298d..fda867eeef 100644 --- a/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java +++ b/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java @@ -322,4 +322,12 @@ public class DataCommunicatorTest { communicator.onRequestRows(0, communicator.getMaximumAllowedRows() + 10, 0, 0); } + + @Test + public void requestTooMuchRowsOverride() { + TestDataCommunicator communicator = new TestDataCommunicator(); + int maxRows = communicator.getMaximumAllowedRows(); + communicator.setMaximumAllowedRows(maxRows + 100); + communicator.onRequestRows(0, maxRows + 10, 0, 0); + } } |