Label not updated (bound to BeanItem)

I have a form that is editing values of a Bean.
Additional to this form I’m displaying some of these Bean-values on top of the screen using com.vaadin.ui.Label
When I enter new values in the form and click save, I want the labels to be updated automatically.

I tried the following:

BeanItem<MyBeanType> beanItem= new BeanItem<MyBeanType>(bean); label.setPropertyDataSource(beanItem.getItemProperty("propertyName")); The values are displayed correctly initially but are not updated when the values inside my bean change. I thought this is possible. What am I missing?

As a workaround I manually call setPropertyDataSource again after saving to update the label-values. That works fine.


how do you update the properties in your bean? If you access the bean directly, there is no way to know that the property has changed. You should instead go through the BeanItem API, e.g. beanItem.getItemProperty(“propertyName”).setValue(newValue).


This was actually the problem. I was setting my Bean directly as datasource for the BeanFieldGroup.
Now I’m using the same BeanItem as datasource for the form and for the labels and it works perfectly.

Thanks alot!

I have a follow up question:
Ist it possible somehow to combine two properties into one Label (e.g. firstname + " " + lastname) and still have it updated automatically if the properties change?