How to force visual update of Transient fields?

So on the screen I’m building, I have a Transient field, age, which is calculated from the patient’s birthdate. The problem is, it doesn’t update visually “live.” I change the birthdate, the age field does not change. Leave the screen and come back in, and it’s fine. I need to update every time the birthdate is changed. I’ve subscribed to the birthdate field’s ValueChangeEvent, but I’m not finding a way I can use that to force update of that field.

Any advice? :slight_smile:

Hi, @jon.craig!

I can advise you to subscribe to ItemPropertyChangeEvent for the data container, and also use the discard function to update data from the data container.

Example of using:

  1. getAge() function in Customer class.
    public Integer getAge() {
        if (birthdate != null) {
            LocalDate now =;
            Period diff = Period.between(birthdate, now);
            return diff.getYears();
        return null;
  1. Make ageField field buffered in the XML descriptor so that you can use the discard function. I attach a link to the documentation for more information about discard.
  2. Subscribe to ItemPropertyChangeEvent
public class CustomerEdit extends StandardEditor<Customer> {
    private TextField<Integer> ageField;

    @Subscribe(id = "customerDc", target = Target.DATA_CONTAINER)
    public void onCustomerDcItemPropertyChange(InstanceContainer.ItemPropertyChangeEvent<Customer> event) {
        if ("birthdate".equals(event.getProperty())) {

I created a test project for Customer entity with birthdate and age fields. (339.1 KB)



Thank you for the answer, Gleb!

I did fix it in the meantime, though I used a different approach.

I did (in the PatientEdit controller):

    private TextField<Long> ageField;

    public void onDateOfBirthFieldValueChange(HasValue.ValueChangeEvent<Date> event) {

This gave me the desired behavior as well.