GWT: Putting raw HTML inside a Label

后端 未结 5 2698
情深已故
情深已故 2021-02-20 08:26

Is there a way to put raw HTML inside of a Label widget with GWT? The constructor and setText() methods automatically escape the text for HTML (so

5条回答
  •  暖寄归人
    2021-02-20 08:47

    Here's example to put a space in a widget, e.g. Label:

    public void setTextNbsp( final Widget w ) { 
        w.getElement().setInnerHTML( " " );
    }
    

    Other HTML entities could be used as well. Take care with this not to open security holes. SafeHtml, etc. might need consideration if doing something more dynamic.

提交回复
热议问题