summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2016-01-04 14:42:05 +0200
committerVaadin Code Review <review@vaadin.com>2016-01-05 11:48:19 +0000
commit47b7f536b28305914d40812e2a97eb99ec836eef (patch)
treea45a6129eceb65dd9301539945ef0ddfc171f224 /server/src/com/vaadin
parent9e359afb598beefd18ac8ea67262ef19a290c8e0 (diff)
downloadvaadin-framework-47b7f536b28305914d40812e2a97eb99ec836eef.tar.gz
vaadin-framework-47b7f536b28305914d40812e2a97eb99ec836eef.zip
Fix NPE in Label.writeDesign with NULL values #19434
Change-Id: If3628bc655d6cd58ab51b7400af808bdbca3dc91
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/ui/Label.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index 2b96d51fa5..1498246ec5 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -625,12 +625,31 @@ public class Label extends AbstractComponent implements Property<String>,
super.writeDesign(design, designContext);
String content = getValue();
if (content != null) {
- design.html(getValue());
- }
- // plain-text (default is html)
- if (getContentMode() == ContentMode.TEXT) {
- design.attr(DESIGN_ATTR_PLAIN_TEXT, true);
- design.html(DesignFormatter.encodeForTextNode(getValue()));
+ switch (getContentMode()) {
+ case TEXT:
+ case PREFORMATTED:
+ case XML:
+ case RAW: {
+ // FIXME This attribute is not enough to be able to restore the
+ // content mode in readDesign. The content mode should instead
+ // be written directly in the attribute and restored in
+ // readDesign. See ticket #19435
+ design.attr(DESIGN_ATTR_PLAIN_TEXT, true);
+ String encodeForTextNode = DesignFormatter
+ .encodeForTextNode(content);
+ if (encodeForTextNode != null) {
+ design.html(encodeForTextNode);
+ }
+ }
+ break;
+ case HTML:
+ design.html(content);
+ break;
+ default:
+ throw new IllegalStateException(
+ "ContentMode " + getContentMode()
+ + " is not supported by writeDesign");
+ }
}
}
}