# :: Guide :: Domain Objects :: ## Beans The Binding is about synchronizing domain object properties with user interface components. We get values from the domain to put them into the UI component, and we set values in the domain object if the UI component changes. The Java Bean standard describes a uniform approach to get and set properties, or in other words, how to read and write values from/to domain objects. ## Observables (Bound Bean Properties) In most cases we want to update the view if a domain object property changes. Therefore we must be able to observe changes. The Java Bean standard describes a mechanism to notify observers about changes in a single or multiple bean properties. The so called bound Bean properties fire a PropertyChangeEvent if the property value changes. The Bean standard describes that a bound Bean must provide two methods to add and remove a PropertyChangeListeners. For convenience, the Binding includes the abstract class `Model` that provides everything necessary to register listeners and to fire the property change events. ## ValueHolders `ValueHolders` are an alternative to bound bean properties as described above. A ValueHolder is the minimal ValueModel implementation. It holds a single value that we can get and set, and it notifies listeners about value changes. I recommend to favor bound bean properties over ValueHolders. Bean properties are much wider known in the Java world and work well with other libraries and programming styles. A noticable difference between ValueHolders and properties is, that the ValueHolder is compile-time safe, where accessing a Bean property may fail at runtime. Anyway, I use ValueHolders only rarely and for internal observable values.
(c) 2006 JGoodies |  |