Refreshing TextField

Hi,

I have a TextField and a Button on on VerticalLayout.

The textField is bind like this in the constructor :

textField = new TextField(this.personItem.getItemProperty("firstName"));

When I click on my button I want to update the textField with a new BeanItem, so I do the following in the button listener :

textField.setPropertyDataSource(personItem.getItemProperty("firstName"));

When tested, my TextField is not updated at all.

am I missing something to update the UI ?

Thanks

Éric

Hi,

It should work like that. Rebinding a field to another source should cause it to update to the value of the new source accordingly. Perhaps the problem is with something else? Showing a bit more of the code might be useful.

Thanks for your quick answer.

I resolve the issue this morning.

I was passing the same data on the click listener :frowning:

My bad.

Sorry

Only a observation: Why you are doing mannually data binding?
In this case, is hard to use a form, that will do that for you?

Theres a new addon that can help you to do this bindings, without boylerplate code:


PreCreatedFieldsHelper

Changing the datasource of the form, will refresh all fields in it!
Hope that it helps!

Att,
Frazão