简体   繁体   中英

Vaadin 10 is not using templates in Spring-Boot

I am trying to use templates with Vaadin 10 in a Spring-Boot application.

The problem is, that the template is not used when the page is displayed. No components of the template are appearing on the page.

My template PersonForm.html is stored in src/main/resources/META-INF/resources/frontend/src .

The class which is trying to bind them is:

@Route
@Tag("person-form")
@HtmlImport("frontend://src/PersonForm.html")
public class PersonView extends VerticalLayout implements HasUrlParameter<String> {  

    public PersonView() {}

    @Override
    public void setParameter(BeforeEvent event, String parameter) {}
}

It's right to put the templates in src/main/resources/META-INF/resources/frontend . For Spring-Boot at least this is the default folder.

The Problem is, that your class which is using the template, must extend PolymerTemplate<TemplateModel> .

Instead of TemplateModel you can use your own model.

This will work:

@Tag("person-form")
@HtmlImport("frontend://src/PersonForm.html")
public class PersonView extends PolymerTemplate<TemplateModel> implements HasUrlParameter<String> {

Documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM