aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2016-10-14 11:41:06 +0300
committerVaadin Code Review <review@vaadin.com>2016-10-24 07:55:31 +0000
commit2cdb3b39329232dcefee2ae61ded92f2c3fe54b0 (patch)
treee1bcdcab7065ae5b5723e8400580d50055aae77f /server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
parent02ed73dc9ea247b13fbef63007af6c3c53ad9423 (diff)
downloadvaadin-framework-2cdb3b39329232dcefee2ae61ded92f2c3fe54b0.tar.gz
vaadin-framework-2cdb3b39329232dcefee2ae61ded92f2c3fe54b0.zip
Add utility for outputting the full declarative syntax of components
Change-Id: I4bc740154ffb5a30892b1859a7550a7aeff94fb3
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java')
-rw-r--r--server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
index a70ab256e1..4290620051 100644
--- a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
+++ b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
@@ -60,6 +60,21 @@ public class DesignAttributeHandler implements Serializable {
// translates string <-> object
private static DesignFormatter FORMATTER = new DesignFormatter();
+ private static boolean writeDefaultValues = false;
+
+ /**
+ * Set whether default attribute values should be written by the
+ * {@code DesignAttributeHandler#writeAttribute(String, Attributes, Object, Object, Class)}
+ * method. Default is {@code false}.
+ *
+ * @param value
+ * {@code true} to write default values of attributes,
+ * {@code false} to disable writing of default values
+ */
+ public static void setWriteDefaultValues(boolean value) {
+ writeDefaultValues = value;
+ }
+
/**
* Returns the currently used formatter. All primitive types and all types
* needed by Vaadin components are handled by that formatter.
@@ -238,7 +253,7 @@ public class DesignAttributeHandler implements Serializable {
throw new IllegalArgumentException(
"input type: " + inputType.getName() + " not supported");
}
- if (!SharedUtil.equals(value, defaultValue)) {
+ if (writeDefaultValues || !SharedUtil.equals(value, defaultValue)) {
String attributeValue = toAttributeValue(inputType, value);
if ("".equals(attributeValue) && (inputType == boolean.class
|| inputType == Boolean.class)) {