summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2016-01-04 14:42:05 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2016-01-05 14:06:50 +0200
commitbac79d3ac6936e23c8e64e07d5bc38598d56164d (patch)
tree68802fc27b96887f2004c14ab4f8e07fbc414fbf /server/src
parent9b6f92236ed4e9c119ebbef8e974657feff80afa (diff)
downloadvaadin-framework-bac79d3ac6936e23c8e64e07d5bc38598d56164d.tar.gz
vaadin-framework-bac79d3ac6936e23c8e64e07d5bc38598d56164d.zip
Fix NPE in Label.writeDesign with NULL values #19434
Change-Id: I2ada7a68177ef053ac22682bc17e90dc6ec0515a
Diffstat (limited to 'server/src')
-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");
+ }
}
}
}