summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-12-02 12:21:53 +0200
committerGitHub <noreply@github.com>2020-12-02 12:21:53 +0200
commit81ca93e9cee460b9033c01a59ba0aaa463f7eb49 (patch)
tree129d8c18a0e139c5e62f8c0799840b0687c141af /server/src
parent4dcf2f51123077475b323d52ec52133fcd4b9156 (diff)
downloadvaadin-framework-81ca93e9cee460b9033c01a59ba0aaa463f7eb49.tar.gz
vaadin-framework-81ca93e9cee460b9033c01a59ba0aaa463f7eb49.zip
Replace function reference with anonymous class for serialization (#12137) (#12161)
Lambdas and function references do not serialize See: https://vaadin.com/forum/thread/18462951/vaadin-8-stateful-session Authored-by: Tatu Lund <tatu@vaadin.com>
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java39
1 files changed, 20 insertions, 19 deletions
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java b/server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java
index e6f8ed2926..3912326a35 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/GridDragSource.java
@@ -85,7 +85,26 @@ public class GridDragSource<T> extends DragSourceExtension<Grid<T>> {
super(target);
// Create drag data generator
- dragDataGenerator = this::generateDragData;
+ dragDataGenerator = new DataGenerator<T>() {
+ /**
+ * Drag data generator. Appends drag data to row data json if generator
+ * function(s) are set by the user of this extension.
+ *
+ * @param item
+ * Row item for data generation.
+ * @param jsonObject
+ * Row data in json format.
+ */
+ @Override
+ public void generateData(Object item, JsonObject jsonObject) {
+ JsonObject generatedValues = Json.createObject();
+
+ generatorFunctions.forEach((type, generator) -> generatedValues
+ .put(type, generator.apply((T) item)));
+
+ jsonObject.put(GridDragSourceState.JSONKEY_DRAG_DATA, generatedValues);
+ }
+ };
// Add drag data generator to Grid
target.getDataCommunicator().addDataGenerator(dragDataGenerator);
@@ -149,24 +168,6 @@ public class GridDragSource<T> extends DragSourceExtension<Grid<T>> {
}
/**
- * Drag data generator. Appends drag data to row data json if generator
- * function(s) are set by the user of this extension.
- *
- * @param item
- * Row item for data generation.
- * @param jsonObject
- * Row data in json format.
- */
- private void generateDragData(T item, JsonObject jsonObject) {
- JsonObject generatedValues = Json.createObject();
-
- generatorFunctions.forEach((type, generator) -> generatedValues
- .put(type, generator.apply(item)));
-
- jsonObject.put(GridDragSourceState.JSONKEY_DRAG_DATA, generatedValues);
- }
-
- /**
* Sets a generator function for customizing drag data. The generated value
* will be accessible using the same {@code type} as the generator is set
* here. The function is executed for each item in the Grid during data