diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-09-18 16:54:46 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-10-02 12:53:02 +0000 |
commit | 1d538feb45ab223ac763bc3b414523697904a80f (patch) | |
tree | d5d3eed6d6449295d764d70913b0e752c5a91dd8 /server | |
parent | 904ae72ed3ca7f9477d59bd7fd284bb254895f8b (diff) | |
download | vaadin-framework-1d538feb45ab223ac763bc3b414523697904a80f.tar.gz vaadin-framework-1d538feb45ab223ac763bc3b414523697904a80f.zip |
Add Tree.htmlContentsAllowed (#7717)
Change-Id: I5c773da806b8358ee203c9c12fd2e2b6fec1970f
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/ui/Tree.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index aac827e5b5..b41139275b 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -616,6 +616,10 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, target.addAttribute("dragMode", dragMode.ordinal()); } + if (isHtmlContentAllowed()) { + target.addAttribute(TreeConstants.ATTRIBUTE_HTML_ALLOWED, true); + } + } // Initialize variables @@ -1310,6 +1314,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, private DropHandler dropHandler; + private boolean htmlContentAllowed; + @Override public void addItemClickListener(ItemClickListener listener) { addListener(TreeConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, @@ -1896,4 +1902,34 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, return element; } + + /** + * Sets whether html is allowed in the item captions. If set to + * <code>true</code>, the captions are passed to the browser as html and the + * developer is responsible for ensuring no harmful html is used. If set to + * <code>false</code>, the content is passed to the browser as plain text. + * The default setting is <code>false</code> + * + * @since + * @param htmlContentAllowed + * <code>true</code> if the captions are used as html, + * <code>false</code> if used as plain text + */ + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + markAsDirty(); + } + + /** + * Checks whether captions are interpreted as html or plain text. + * + * @since + * @return <code>true</code> if the captions are displayed as html, + * <code>false</code> if displayed as plain text + * @see #setHtmlContentAllowed(boolean) + */ + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } + } |