vaadin / flow

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

TemplateModel implementation resets predefined value #1950

Open alexberazouski opened 7 years ago

alexberazouski commented 7 years ago

I have the following component:

    <dom-module id="some-element">
        <template>
            <div>[[someProperty]]</div>
        </template>

        <!-- Polymer boilerplate to register the element -->
        <script>

            addEventListener('WebComponentsReady', function() {
                Polymer({
                  is: 'some-element',

                  ready: function() {
                    this.someProperty = 'Some value';
                  }
                });
              });

        </script>
    </dom-module>

The problem is when I have on server-side a TemplateModel associated with this component with declared void setSomeProperty(String someProperty) method then on client 'Some value' rapidly disappears.

denis-anisimov commented 7 years ago

This is known "issue". I'm not sure whether this is issue or not.

It's a consequence of a way that we currently use for propagating model properties from the server side to the client side: their values are set to null(every model property value is set to null from the very beginning).

It might be that this is genuine issue and we shouldn't do it.

Then we have to invent some another way to inform client about all available model properties (this is an implementation detail).

Here I can add one thing: it happens only with Model properties.

You can have any number of properties for your Element (plain properties). The properties with the names defined in the Model are the same properties. But other Element properties behaves differently:

In this specific issue the workaround is : set the same value on the server side.

But this issue has sense and I think we need to fix it later on.

denis-anisimov commented 6 years ago

This is strongly related to #2897. May be it's even duplicate of it. Though the property here is set in a different way than in the #2897.

2897 is about client-side default value. This one about a custom way of initial value set.