diff options
author | Leif Åstrand <leif@vaadin.com> | 2011-08-10 07:04:37 +0000 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2011-08-10 07:04:37 +0000 |
commit | 35887c66f84f0ca4f0b5d5803f24bbcc32cca15a (patch) | |
tree | 7cb57050db06a9e5e709bfa000a5bde783e2c829 /src/com/vaadin/ui/MenuBar.java | |
parent | a41fbd0e685cc8f63b79805a5171777b2153807f (diff) | |
download | vaadin-framework-35887c66f84f0ca4f0b5d5803f24bbcc32cca15a.tar.gz vaadin-framework-35887c66f84f0ca4f0b5d5803f24bbcc32cca15a.zip |
#7187 Allow HTML content in an MenuItem
svn changeset:20245/svn branch:6.7
Diffstat (limited to 'src/com/vaadin/ui/MenuBar.java')
-rw-r--r-- | src/com/vaadin/ui/MenuBar.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java index f8fbf91712..4aae9b2621 100644 --- a/src/com/vaadin/ui/MenuBar.java +++ b/src/com/vaadin/ui/MenuBar.java @@ -51,6 +51,8 @@ public class MenuBar extends AbstractComponent { private boolean openRootOnHover; + private boolean htmlContentAllowed; + /** Paint (serialise) the component for the client. */ @Override public void paintContent(PaintTarget target) throws PaintException { @@ -60,6 +62,10 @@ public class MenuBar extends AbstractComponent { target.addAttribute(VMenuBar.OPEN_ROOT_MENU_ON_HOWER, openRootOnHover); + if (isHtmlContentAllowed()) { + target.addAttribute(VMenuBar.HTML_CONTENT_ALLOWED, true); + } + target.startTag("options"); if (submenuIcon != null) { @@ -411,6 +417,32 @@ public class MenuBar extends AbstractComponent { } /** + * Sets whether html is allowed in the item captions. If set to true, the + * captions are passed to the browser as html and the developer is + * responsible for ensuring no harmful html is used. If set to false, the + * content is passed to the browser as plain text. + * + * @param htmlContentAllowed + * true if the captions are used as html, false if used as plain + * text + */ + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + requestRepaint(); + } + + /** + * Checks whether item captions are interpreted as html or plain text. + * + * @return true if the captions are used as html, false if used as plain + * text + * @see #setHtmlContentAllowed(boolean) + */ + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } + + /** * This interface contains the layer for menu commands of the * {@link com.vaadin.ui.MenuBar} class. It's method will fire when the user * clicks on the containing {@link com.vaadin.ui.MenuBar.MenuItem}. The |