简体   繁体   English

Vaadin 10在Spring-Boot中未使用模板

[英]Vaadin 10 is not using templates in Spring-Boot

I am trying to use templates with Vaadin 10 in a Spring-Boot application. 我试图在Spring-Boot应用程序中将模板与Vaadin 10一起使用。

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 . 我的模板PersonForm.html存储在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 . 将模板放在src/main/resources/META-INF/resources/frontend For Spring-Boot at least this is the default folder. 对于Spring-Boot,至少这是默认文件夹。

The Problem is, that your class which is using the template, must extend PolymerTemplate<TemplateModel> . 问题是,正在使用模板的类必须扩展PolymerTemplate<TemplateModel>

Instead of TemplateModel you can use your own model. 您可以使用自己的模型来代替TemplateModel

This will work: 这将起作用:

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

Documentation . 文件资料

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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