How to bind data with an external service provider?

I have just completed a toy application in Vaadin (and it’s a great framework, thank you). My biggest hurdle was comprehending the
paradigm. I had started the application by devising the data model using the sorts of practices I am used to. In this case the toy application was a Quiz. My model had a Quiz data object containing Question objects. Ignoring the purest practices of keeping a DTO just containing data, I went ahead and put some helper methods inside the DTO to return derived data like how many questions had been answered and how many were correct. These were derived from values in the
field. Furthermore, I had a variety of time taken/time left statistics inside that Quiz object all computing their answer from the system clock.

I learned along the way that this jars (sorry about the pun) with the Vaadin data binding architecture. Or least… this is my question to you.

I ended up wrapping my Quiz & Question objects with BeanItem, and in quite a few cases I needed to remove the functionality from the data object into some kind of controller (ahem, maybe that is where it should have been in the first place?) which update the model
via the Property interface
rather than changing my data model directly. In the case of the timer statistics, when I wanted to mark all the timing related fields as being changed I had to iterate over the
properties (
) and then cast each
to be a
so that I had access to
. In this case I knew it was safe to cast to
(because I was using BeanItem), but in other Property implementations there is no fireValueChange() exposed method and I notice that MethodProperty.fireValueChange() carries a warning about its exposure likely to be reduced in future versions.

So this all feels awkward - as if I am missing a different programming style.

My next more serious application would acquire data from a remote Service. This would be programmed using REST or RPC where my Vaadin app will need to ask the service provider to give me a DTO. How do you recommend I proceed?

Imagine then an application that looks up details of a product. Application would have this object lifecycle:

  1. create dummy DTO1
  2. create BeanItem on the DTO1
  3. create UI components, bind to the BeanItem
  4. take user request to look up product 100
  5. call the external service to look up product 100, receive a DTO2
  6. Copy, field by field, data from DTO2 into DTO1 via the Vaadin Property wrapper, this triggers…
  7. Data update to the frontend
  8. repeat from (4)

It is step (6) that feels wrong - how can I provide to the
hierarchy a fresh object (graph) in one simple go; possible invalidating the whole tree?