RichTextArea without header

I am using vaadin 8.

I want to show a mulitline HTML-Text in a Component.

It works with RichTextArea very good.

But is here a possibility, that:

  1. only the HTML-Text is shown and not the header?

  2. make it read only. Editing is not possible?

If you are not needing a field component for editing, but just want to display text, I recommend to use Label. You can set the content mode to HTML. If user can input the content somewhere else, I would sanitize the input there with Jsoup, since otherwise you may have Javascript injection security vulnerability. If the text has br’s for line breaking, you will see text on multiple lines. If you need to wrap text automatically, you can set “white-space: normal” style with CSS to you label.

Thanks for your answer.

Without Jsoup it works perfect.

I have a probem with Jsoup.

	private Label area;
	area = new Label()
	area.setContentMode(ContentMode.HTML);
	area.setStyleName("v-emailMessage-label");
	public void setMessageContent(String messageText) {
		area.setValue(Jsoup.parse(messageText).text());
	}
@mixin emailMessage {
	.v-emailMessage-label {
		white-space: normal
   	}
 }

Have you any idea why the br’s for line are not working?

No, I think it is working just right. You are using Jsoup.parse(..).text() which is too strict in your case, because it strips HTML completely and your line breaks.

I recommend to use Jsoup.clean(messageText, whiteList) instead.

public void setMessageContent(String messageText) {
   Whitelist whiteList = Whitelist.relaxed()
   area.setValue(Jsoup.clean(messageText, whiteList));
}

Even Whitelist.relaxed() is sometimes strict, so you can use whiteList.addTags(..) and whiteList.addAttributes(..) to what is allowed to pass sanitization.

Thanks!!
now it works!!