From 90e75a20bda563f90297840f4feb5668cd524633 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 15 May 2015 12:38:01 +0300 Subject: Properly handle readonly fields when clearing FieldGroup (#17166) Change-Id: I42b9fe5d945d23e202a252a8be12976608da19bf --- server/src/com/vaadin/data/fieldgroup/FieldGroup.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java index d370c3906b..aaaae9e4f7 100644 --- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java @@ -258,7 +258,19 @@ public class FieldGroup implements Serializable { if (itemDataSource == null) { // Clear any possible existing binding to clear the field field.setPropertyDataSource(null); - field.clear(); + boolean fieldReadOnly = field.isReadOnly(); + if (!fieldReadOnly) { + field.clear(); + } else { + // Temporarily make the field read-write so we can clear the + // value. Needed because setPropertyDataSource(null) does not + // currently clear the field + // (https://dev.vaadin.com/ticket/14733) + field.setReadOnly(false); + field.clear(); + field.setReadOnly(true); + } + // Will be bound when data source is set return; } @@ -1247,4 +1259,5 @@ public class FieldGroup implements Serializable { } } -} + +} \ No newline at end of file -- cgit v1.2.3