-
Get a monthly update on best practices for delivering successful software.
I've been meaning to focus some more on the excellent set of 'small talks' available for the ZK framework. These have the feel of the original O'Reilly books and are great for those who learn best by having someone prod them gently into doing. For those who pine for the wonderful world of the .NET datagrid, there is a small talk by Chanwit Kaewkasi entitled Small Talk: Data-Binding Implementation. It demonstrates how to do something similar in ZK:
I use the technique called "subscribe-to-expression" (found in Borland ECO framework for .NET) with the simple Observer pattern in the current implementation. Two new properties, "bind" and "dataSource", have been introduced to the ZUL elements. The "dataSource" property is to link with a business object, and then we can set the name of property we want to display and/or edit using the "bind" property. When the "dataSource" or the "bind" property are changed, the element will subscribe itself to the "bind" expression of the "dataSource" object for update notification. The subscription process will be done through the DisplayRegistry class.
After a user making a change to the value of a ZUL element, the element will trigger an update notification to all elements that has subscribed to the same "expression." So you can see that these elements will be automatically updated.
Currently in the proof-of-concept version, I use Apache Commons JXPath as a binding expression library. It is a bit different approach comparing with the EL expression found in ZK, and might confuse the ZK users in the first time. However, other technique is welcome to improve the coding experiences.
If you like this sort of thing, it's well worth a look. As someone who has worked on plenty of Datagrid-ectomies, I can't say I like it for anything but the most simple webapps. It's one of those classic time saving constructs that depends on good developer behavior to work. In practice, data binding punches through the layered or tiered architectural pattern and couples the UI tightly to the data layer.
Still, the kids ask for it. In the words of Paul Simon, "Who am I to blow against the wind?"
Related posts:
Topics: Ajax Frameworks, ZK
“In practice, data binding punches through the layered or tiered architectural pattern and couples the UI tightly to the data layer.”
That is not how ASP.Net databinding works when done properly. Datasources can be collections of objects, a fact which frameworks like CSLA.Net leverage heavily.
There is a need for sophisticated databinding in Ajax. It is one of the most obvious shortcomings at present.
Comment by Smoov, Monday, November 6, 2006 @ 6:12 am