Skip to content
Advertisement

Vaadin 14 show simple HTML Page

I made some kind of internal manual for a webapp that i am developing. I am using Spring Boot and Vaadin 14. How to implement a button that shows that document? The html doc is in my resources folder. I wonder if i am stupid. Or should i write my own controller for this?

Advertisement

Answer

A Vaadin application itself is a single dynamic HTML page.

The easiest way to include HTML formatted content (not an HTML document) is to use the Html component.

Html html = new Html("<div><h3>Title</h3><p><b>Bold summary text</b></p><p>Other text</p></div>");
layout.add(html);

Note, when you use the Html component, you need to strip the <head> and <body> tags, as Html‘s purpose is not to show full HTML documents. The Html component’s content should be included inside a single root element – usually a <div> is used for this purpose.

However, based on your use case, I think the Html component will serve you well.

Advertisement