summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMatti Tahvonen <matti@vaadin.com>2015-07-16 18:12:57 +0300
committerVaadin Code Review <review@vaadin.com>2016-05-02 08:38:24 +0000
commit85870ccd9f93cebd839d22d2bd63ec817bb90a3d (patch)
treea1397563807e3468429878d520874bbc8cc92d33 /server
parent29a6ed998041be42e2c4e986d9702fa2e798f1be (diff)
downloadvaadin-framework-85870ccd9f93cebd839d22d2bd63ec817bb90a3d.tar.gz
vaadin-framework-85870ccd9f93cebd839d22d2bd63ec817bb90a3d.zip
Better default for nullRepresentation (#13221, #12877)
Change-Id: Ia4662c79b20ee699b3a9741ffa24c4de6645b775
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;
+ }
+
}