|
|
|
Re: Purpose of DataBindingContext's validation realm [message #334160 is a reply to message #334151] |
Thu, 22 January 2009 17:25 |
Matthew Hall Messages: 368 Registered: July 2009 |
Senior Member |
|
|
Sebastian Paul wrote:
> But where do I know which Realm I have to use for it? Currently my calls
> run on the display thread, so everything works. But I don't know why.
You can use any realm, but it's usually easier to use the display realm
since some of our support classes aren't yet designed to cope with other
realms (WizardPageSupport for example).
> What happens when there are Bindings between SWT (needs the display
> thread) and an arbitrary model that runs in another thread?
Bindings are designed to handle this. Here is how the update pipeline
works:
Assuming the following:
Realm displayRealm = SWTObservables.getRealm(text.getDisplay());
Realm workerRealm = new WorkerRealm(workerThread); // custom realm
bindingContext.bindValue(
// displayRealm is implied for SWT and Viewer observables
SWTObservables.observeText(text, SWT.Modify),
BeansObservables.observeValue(workerRealm, company, "name"));
When a user makes changes in the text field, here is what happens:
display realm:
get new value from text observable (source)
validate value using after-get validator (see UpdateValueStrategy)
convert value if there is a convert
validate converted value using after-convert validator
validate again using before-set validator
jump to the other realm using realm.exec()
worker realm:
set the new, converted value on the bean observable (target)
This same process works in reverse if the model observable changes.
(Note that Realm.exec() is asynchronous--this is how we avoid deadlocks)
> Is it possible to mix bindings of any type, or does this depend on the
> Realm of the DBC?
Any combination of realms is allowed for the model observable, target
observable and validation realm of the DataBindingContext.
Hope this helps,
Matthew
|
|
|
|
Powered by
FUDForum. Page generated in 0.03925 seconds