• Share this article:

Understanding JFace Data Binding

Monday, March 17, 2008 - 20:52 by Wayne Beaton

boris-frank-michael.jpgI’ve tinkered with the JFace DataBinding, but haven’t had a chance to really dig into it. So, this afternoon I attended “Understanding JFace Data Binding“, presented by Boris Bokowski (IBM Rational Software), Michael Scharf (Wind River), and Frank Gerhardt (Gerhardt Informatics). I loved the presentation style. They very likely didn’t plan for the rough edges around the presentation, but I found it effective. Boris would say things like “of course, you have to have an ObservablesManager” and Michael (who was driving the demo), would say, “what?!?”. Then they’d update the implementation and tell us about it. A very effective way of making sure that folks in the audience would remember (or maybe they did plan it).

One thing is clear: using the DataBinding framework significantly reduces the complexity of building user interfaces. That said, it’s also clear that specifying bindings can get a little weird. It’s definitely ripe for generation by a GUI designer (Instantiation’s WIndowBuilder will generate the binding code). It’s a heck of a lot easier to understand the steps you need to take if you’ve done it the hard way first. Initially, it occurred to me that—if I were to deliver this session—I’d show the hard way first. After some sober reflection, however, I figure that showing somebody the “hard way” is virtually guaranteed to melt at least a few brains. Bottom line: some parts of the DataBinding may seem weird or hard, but it’s way easier than the old-fashioned way.

One thing that I really like about the framework is the level of control that you’re given over validation, conversion, and updating. You can, for example, defer the actual updating (e.g. moving the value typed in a text field into the model object) until the user clicks “Okay”, “Finish”, or whatever. There are also several opportunities to validate the information (before conversion, after conversion, before update).

There are examples that show you how to use DataBinding in Eclipse CVS; look for org.eclipse.jface.examples.databinding. The Examples project is going to make use of this.