Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template model List<> items are not updated on server side when changed on client side. #4091

Closed
stefanuebe opened this issue May 8, 2018 · 8 comments
Assignees
Milestone

Comments

@stefanuebe
Copy link
Contributor

stefanuebe commented May 8, 2018

I have a simple TemplateModel with a getter and setter for a List of items. These items are displayed with a polymer dom-repeat and can be edited by vaadin-text-fields. Expectation here is, that changed made on client side are transported back to server side to be handled in an event handler.

Currently the items are unchanged. This reflects also back to direct calls of items in the handling method by @EventData("event.model.item") (or @ModelItem in short).

Java

public class TodoListDetailView extends PolymerTemplate<TodoListDetailView.Model> implements HasComponents, HasUrlParameter<Long> {
    @EventHandler
    private void handle() {
        // update repository
        System.out.println(getModel().getTodos());
    }

    public interface Model extends TemplateModel {
        @Encode(value = LongToStringEncoder.class, path = "id")
        @Encode(value = LongToStringEncoder.class, path = "list.id")
        void setTodos(List<Todo> list);

        List<Todo> getTodos();
    }
}

Polymer

<template>
        <template is="dom-repeat" items="{{todos}}">
            <vaadin-text-field on-change="handle" class="todo-name" value="{{item.name}}"></vaadin-text-field>
        </template>
</template>

Also see: #4086

@denis-anisimov
Copy link
Contributor

As discussed in #4086: I don't see reasons why it doesn't work with items in the list.
The item is represented by the StateNode and any update done on the client side should be sent in the same way as for any other bean to the server side.

So I would say this is a bug (and not an enhancement) .

@heruan
Copy link
Member

heruan commented May 8, 2018

Possibly related: #3399

@Legioth
Copy link
Member

Legioth commented May 8, 2018

Might also be related to #4080

@pleku pleku added this to the 1.0 Maintenance milestone May 9, 2018
@pleku
Copy link
Contributor

pleku commented May 9, 2018

As a workaround, you should be able to use a @ClientCallable public void update(Todo item) {...} method and pass the updated item to that one.

@pleku pleku modified the milestones: 1.0 Maintenance, Before 1.0 RC May 15, 2018
@pekam pekam assigned pekam and unassigned pekam May 17, 2018
@denis-anisimov denis-anisimov self-assigned this May 18, 2018
@denis-anisimov
Copy link
Contributor

I'm able to reproduce a bug.
I have an IT test which shows it.

@denis-anisimov
Copy link
Contributor

Apparently this has never be implemented.
So it's kind of may be considered as a known limitation.
We are overriding _propertiesChanged polymer element method.
This method is never called when property is updated inside an item in the list.
I will try to see what we can do here.....

@denis-anisimov
Copy link
Contributor

Additional info: on the client side two way databinding works as expected for arrays.

@denis-anisimov
Copy link
Contributor

denis-anisimov commented May 22, 2018

_propertiesChanged is called but it's called on the dom-repeat element instead of element itself.
It causes some calls on the element itself (like _flushProperties()) but there is no info about changed item+property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants