Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Updating after data binding does not update content in UI

Francisco Serrano
7 years ago Aug 28, 2015 3:40pm
Marko Grönroos
7 years ago Aug 28, 2015 5:02pm

If you modify beans directly, the bound Vaadin fields will not know about the modifications. You need to modify them through the item/container interface with setValue().

Well, you could also notify the Vaadin fields about the modifications, but the notification mechanism is rather a lot extra to do. There's an example here. However, I don't really know if such mechanism is often or ever needed in real applications.

Francisco Serrano
7 years ago Aug 28, 2015 6:38pm
Marko Grönroos
7 years ago Aug 28, 2015 7:41pm

That's a good question. I don't really know what the best practice would be, other than enumeration (with constants) as you suggested, as there isn't any really good way to have property identifiers in Java. Using constants would at least encapsulate the identifiers in the beans itself, so you wouldn't need to use strings in other code. And it's simple to do.

If you use CDI or Spring to manage the beans, you could perhaps use their notification or other mechanisms to notify Vaadin about changes to the beans. That would obviously be restricted to managed beans, and perhaps be more complex than what you're looking for.

I started thinking if you could use method references in Java 8 to do some tricks, like the following:

SomeDataUtil.setValue(beanItem, MyBean::setText, "Hello World!");

However, apparently that's not quite possible, even though there could be some really tricky way to do it.

Francisco Serrano
7 years ago Jan 26, 2016 10:10am
Charles Anthony
7 years ago Jan 26, 2016 11:07am
Matti Tahvonen
7 years ago Feb 03, 2016 6:07pm