vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
620 stars 167 forks source link

Stackoverflow when extending HasElement in a TemplateModel #7311

Closed gsedlacz closed 4 years ago

gsedlacz commented 4 years ago
public interface TEST_MODEL extends TemplateModel, HasElement {
    String getValue();
    void setValue(String value);
}

If you remove HasElement and restart the server everything loads perfectly fine.

default String getSpecialValue() {
    return getElement().getProperty(":value");
}
caalador commented 4 years ago

A template model can never be an HasElement as it is used pass properties to the client-side PolymerTemplate and thus will never have an element itself.

Also the model wouldn't actually execute the default method at any point as we create a proxy of the model and try to read the value specialValue that would never be synced from the client as it doesn't exist.

If you have non-standard properties you should just have the getter/setter on the PolymerTemplate component and not the model.

gsedlacz commented 4 years ago

You are absolutely right. I have no idea why I assumed this would make sense in the first place.

Im sorry for waisting your time.