Binder"

From Documentation
m
m ((via JWB))
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{ZKDevelopersReferencePageHeader}}
 
{{ZKDevelopersReferencePageHeader}}
 
+
{{Deprecated | url=[http://books.zkoss.org/zk-mvvm-book/8.0/data_binding/binder.html zk-mvvm-book/8.0/data_binding/binder]|}}
  
  
Line 9: Line 9:
 
Typically ViewModel is just a POJO. As it has no knowledge about others, a ViewModel can only communicate with another one by binder. The binder is like a broker and uses ViewModel's meta data(annotation) and methods to help it communicate with others. '''By default a binder subscribes to a desktop-scoped event queue''', thus event queue is a common communication mechanism among binders. There are 2 features: [[ZK Developer's Reference/MVVM/DataBinding/Global Command Binding| global command binding]] and [[ZK Developer's Reference/MVVM/ViewModel/Notification| dynamic change notification]] that operate based on this mechanism.  
 
Typically ViewModel is just a POJO. As it has no knowledge about others, a ViewModel can only communicate with another one by binder. The binder is like a broker and uses ViewModel's meta data(annotation) and methods to help it communicate with others. '''By default a binder subscribes to a desktop-scoped event queue''', thus event queue is a common communication mechanism among binders. There are 2 features: [[ZK Developer's Reference/MVVM/DataBinding/Global Command Binding| global command binding]] and [[ZK Developer's Reference/MVVM/ViewModel/Notification| dynamic change notification]] that operate based on this mechanism.  
  
[[File:Mvvm-binder.png]]
+
[[File:Mvvm-binder.png | center]]
  
 
ZK also allows you to change default queue name and scope that a binder subscribes. You can separate binders into different groups by changing queue's name and scope upon your requirement.The syntax is as follows:  
 
ZK also allows you to change default queue name and scope that a binder subscribes. You can separate binders into different groups by changing queue's name and scope upon your requirement.The syntax is as follows:  
Line 29: Line 29:
  
 
=Version History=
 
=Version History=
{{LastUpdated}}
+
 
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-

Latest revision as of 07:35, 8 July 2022

Stop.png This article is out of date, please refer to zk-mvvm-book/8.0/data_binding/binder for more up to date information.


The Binder is the key in the whole data binding mechanism. When we apply a BindComposer on a component, it will create a binder and pass component's and ViewModel's object reference to the binder.

Binder parses ZK bind annotations on ZULs to establish data binding relationship between components and ViewModel. It also synchronizes data between ZUL(View) and ViewModel based on the binding relationship and forwards events to ViewModel's command method.

Typically ViewModel is just a POJO. As it has no knowledge about others, a ViewModel can only communicate with another one by binder. The binder is like a broker and uses ViewModel's meta data(annotation) and methods to help it communicate with others. By default a binder subscribes to a desktop-scoped event queue, thus event queue is a common communication mechanism among binders. There are 2 features: global command binding and dynamic change notification that operate based on this mechanism.

Mvvm-binder.png

ZK also allows you to change default queue name and scope that a binder subscribes. You can separate binders into different groups by changing queue's name and scope upon your requirement.The syntax is as follows:

<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('foo.MyViewModel')"
	binder="@init(queueName='myqueue')">


<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('foo.MyViewModel')"
	binder="@init(value='xxx.MyBinder', queueScope='session')">

For available scopes, please refer ZK Developer's Reference/Event Handling/Event Queues.

For binder class customization(This feature is reserved for framework architect, NOT recommended for app developer!), your implementation must extends AnnotateBinder


Version History

Version Date Content
6.0.0 February 2012 The MVVM was introduced.




Last Update : 2022/07/08

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.