summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/DefaultDeploymentConfiguration.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractTextField.java37
2 files changed, 48 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/main/java/com/vaadin/server/DefaultDeploymentConfiguration.java
index 1f22a9e33d..677be2e31b 100644
--- a/server/src/main/java/com/vaadin/server/DefaultDeploymentConfiguration.java
+++ b/server/src/main/java/com/vaadin/server/DefaultDeploymentConfiguration.java
@@ -21,6 +21,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.vaadin.shared.communication.PushMode;
+import com.vaadin.ui.AbstractTextField;
/**
* The default implementation of {@link DeploymentConfiguration} based on a base
@@ -97,6 +98,17 @@ public class DefaultDeploymentConfiguration extends
checkLegacyPropertyToString();
checkSyncIdCheck();
checkSendUrlsAsParameters();
+ checkNullRepresentationLegacyMode();
+ }
+
+ private void checkNullRepresentationLegacyMode() {
+ final boolean legacyMode = getApplicationOrSystemProperty(
+ "com.vaadin.nullrepresentationlegacymode",
+ Boolean.toString(false)).equals("true");
+ if (legacyMode) {
+ AbstractTextField.setNullRepresentationDefault("null");
+ }
+
}
private void checkLegacyPropertyToString() {
diff --git a/server/src/main/java/com/vaadin/ui/AbstractTextField.java b/server/src/main/java/com/vaadin/ui/AbstractTextField.java
index 5fbe60937a..ce1d6f638d 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractTextField.java
@@ -41,10 +41,13 @@ import com.vaadin.ui.declarative.DesignContext;
public abstract class AbstractTextField extends AbstractField<String> implements
BlurNotifier, FocusNotifier, TextChangeNotifier, LegacyComponent {
+ private static String nullRepresentationDefault = "";
+
/**
* Null representation.
*/
- private String nullRepresentation = "null";
+ private String nullRepresentation = nullRepresentationDefault;
+
/**
* Is setting to null from non-null value allowed by setting with null
* representation .
@@ -810,4 +813,36 @@ public abstract class AbstractTextField extends AbstractField<String> implements
getMaxLength(), def.getMaxLength(), Integer.class);
}
+ /**
+ * @since 7.6
+ * @return the default value used for nullRepresentation
+ */
+ public static String getNullRepresentationDefault() {
+ return nullRepresentationDefault;
+ }
+
+ /**
+ * A static helper to define the default value used for nullRepresentation.
+ * <p>
+ * In 7.6 the infamous default value "null" for
+ * AbstractTextField.nullRepresentation was changed to "", which may cause
+ * unexpected issues in certain applications that don't tackle null values.
+ * If there are several places in your application that depend on the old
+ * default, this method can be used to put new AbstractTextField instances
+ * into backwards compatibility mode by defining the default value as
+ * "null". The "legacy mode" can also be forced by setting system property
+ * "com.vaadin.nullrepresentationlegacymode" (before AbstractTextField class
+ * is loaded by your class loader).
+ *
+ * @since 7.6
+ * @param nullRepresentationString
+ * the value that will be used as a default for
+ * {@link AbstractTextField#getNullRepresentation()} in new
+ * instances
+ */
+ public static void setNullRepresentationDefault(
+ String nullRepresentationString) {
+ AbstractTextField.nullRepresentationDefault = nullRepresentationString;
+ }
+
}