From f3d768252903b8c184cc7d8a77b70ccddc5ef20f Mon Sep 17 00:00:00 2001 From: Artur Date: Wed, 22 Feb 2017 13:36:45 +0200 Subject: Add support for rendering HTML in ButtonRenderer (#8606) --- .../client/connectors/ButtonRendererConnector.java | 7 +++++++ .../java/com/vaadin/client/renderers/ButtonRenderer.java | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/src/main/java/com/vaadin/client/connectors/ButtonRendererConnector.java b/client/src/main/java/com/vaadin/client/connectors/ButtonRendererConnector.java index 6fbe428edc..170c32a616 100644 --- a/client/src/main/java/com/vaadin/client/connectors/ButtonRendererConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/ButtonRendererConnector.java @@ -16,6 +16,7 @@ package com.vaadin.client.connectors; import com.google.gwt.event.shared.HandlerRegistration; +import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.renderers.ButtonRenderer; import com.vaadin.client.renderers.ClickableRenderer.RendererClickHandler; import com.vaadin.shared.ui.Connect; @@ -48,4 +49,10 @@ public class ButtonRendererConnector public ButtonRendererState getState() { return (ButtonRendererState) super.getState(); } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + getRenderer().setHtmlContentAllowed(getState().htmlContentAllowed); + } } diff --git a/client/src/main/java/com/vaadin/client/renderers/ButtonRenderer.java b/client/src/main/java/com/vaadin/client/renderers/ButtonRenderer.java index 3c4560ff36..09d388dd93 100644 --- a/client/src/main/java/com/vaadin/client/renderers/ButtonRenderer.java +++ b/client/src/main/java/com/vaadin/client/renderers/ButtonRenderer.java @@ -29,6 +29,8 @@ import com.vaadin.client.widget.grid.RendererCellReference; */ public class ButtonRenderer extends ClickableRenderer { + private boolean htmlContentAllowed = false; + @Override public Button createWidget() { Button b = GWT.create(Button.class); @@ -37,8 +39,20 @@ public class ButtonRenderer extends ClickableRenderer { return b; } + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + } + + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } + @Override public void render(RendererCellReference cell, String text, Button button) { - button.setText(text); + if (htmlContentAllowed) { + button.setHTML(text); + } else { + button.setText(text); + } } } -- cgit v1.2.3