oprogramowanie dla firm, tworzenie portali, offshoring programistyczny, CMS, analiza biznesowa, wyszukiwarki na zamówienie, oprogramowanie dla przedsiębiostw, outsourcing informatyczny, testowanie, zarządzanie projektami, dedykowane systemy informatyczne programiści Java, systemy informatyczne, offshoring, case study, gigaspaces start up tworzenie portali, CMS, wyszukiwarki na zamówienie, analiza biznesowa, outsourcing, testowanie oprogramowania, zarządzanie projektami programista Java - praca, praca w Warszawie, J2EE, dobrze płatna, programista, praca skontaktuj się z XPro

What Bindings are for?

Bindings provide a way to keep properties synchronized (in one, or both ways).
If the dependency is one-way, we call it 'binding' (A property is bound to another).
If the dependency is both-ways, we call it 'synchronization' (A property is synchronized with another).

 

How do I use Bindings?

1. A property of a view (such as its value or colour) might be bound to a value of a property of a model object (such as a price or an overdue flag).

 

// RWProperty is a property which can be read, written, and observed for value changes.
RWProperty viewValue = new ValueHolder(INITIAL_VIEW_VALUE);
RWProperty modelValue = new ValueHolder(INITIAL_MODEL_VALUE);

// initialize view value with model's value, and keep it bound to modelValue
Bindings.bind(modelValue, viewValue);

 

2. The value displayed in a text field might be kept synchronised with the first name of a Person object.

 

class Person {
public RWProperty name;
public RWProperty surname;
...
}
RWProperty textFieldValue = new ValueHolder(INITIAL_TEXT_FIELD_VALUE);
RWProperty personValue = new ValueHolder(INITIAL_PERSON_VALUE);

// initializes both properties with INITIAL_VALUE, and keeps them synchronized
Bindings.synchronize(textFieldValue, personValue.name, INITIAL_VALUE);

 

3. A property can observe another and calculate its value based on the current value of the observed property

 

RWProperty currentPerson = ...
// ObservableProperty can be read and observed for changes.
ObservableProperty currentPersonNameStartsWithA = new AbstractTransformProperty(currentPerson) {
@Override
protected Boolean transform(Person value) {
return value.name.get().charAt(0) == 'A';
}
};

 

4. Boolean properties can be easily combined into complex expressions

 

ObservableProperty p1 = ...
ObservableProperty p2 = ...
ObservableProperty p3 = ...
ObservableProperty p4 = ...
ObservableProperty pv = new AllTrue( new AnyTrue(p1, p2), new Not(p3), p4 );