Load HTML

Please what is the best way to load html in a view ?

It depends what the content of the html is

There is a Html-Component that you can use

https://vaadin.com/api/platform/23.2.8/com/vaadin/flow/component/Html.html

It is a full standalone functional html and javascript module. We don’t want to reinvent the wheel by building the all module in vaadin. we just want to load it in a view. Thinking iFrame will work. ?

Yes in that case an Iframe would be the best idea

Great! Thank you. Could you please assist with any recent resource for Iframe on vaadin 23.

We have all the files in /frontend folder because we don’t want to run two different application for the same solution

https://vaadin.com/api/platform/23.2.8/com/vaadin/flow/component/html/IFrame.html

Your app must be in

src/main/resources/static

I would recommend to create a subdirectory there

this content will be served by Spring MVC and not Vaadin

image.png

@PageTitle("Hello World")
@Route(value = "hello", layout = MainLayout.class)
@RouteAlias(value = "", layout = MainLayout.class)
public class HelloWorldView extends HorizontalLayout {

    public HelloWorldView() {
        IFrame iFrame = new IFrame("http://localhost:8080/app/index.html");
        iFrame.setSizeFull();

        add(iFrame);
    }

}

Instead of the hardcoded host a relative path should also work

Sure!