Skip to main content

Multiple models wrapped around the same bean. Propagating changes

No replies
Joined: 2003-06-29

One of the problem of wrapper style data models (wrapped around actual data bean for the sake of firing change event) is that if you have two views hooked to the same business object (read bean) but via two separate data models no events will be propagated from first model to second view and vs.vs

There could be several solutions and none of them are perfect or 100% complete. One approach we found is a good balance of completenes and performance is to internalize our wrapper data models based on underlying business object identity (assuming your business objects have durable (non java) identity like in our case JDO do)
When a data model is created we check if there were any other data models created for the same business object and if yes we make them all propagate changes to each other (via common observable). As result regardless how many data models are hooked up to a business object events fired by one model will be propagated to all views attached to all other data models. Weak map is used for associatingdata models with its data object