Helping ordinary people create extraordinary websites!

Have Your People Call My People: Binding

By Andres Almiray, Danno Ferrin, and Geertjan Wielenga
2009-12-28

What is a binding?

It's nice that we can create changes in Groovy objects that can be observed by an interested party, but that is only half the story. Really, we want to do some cool stuff with these changes, and what would be really magical is if we could do some of these things automatically. In this segment, you'll do just that when you learn how to bind one value to some other value.

What is a binding? In Griffon a binding has three constituent parts: a trigger, a read, and a write. The trigger tells the binding that it needs to update, the read tells the binding what the new value is, and the write takes the new value and does something with it.

This article is based on Griffon In Action, published November, 2009. It is being reproduced here by permission from Manning Publications. Manning early access books and ebooks are sold exclusively through Manning. Visit the book's page for more information.

Developer Tutorial readers can get 30% off any version (ebook or print book) of Griffon In Action. Simply use the code "devtut30" at checkout.

JavaBeans bound properties provide the simplest manifestation of a binding (table 1).

Table 1: A binding from a JavaBean's point of view

Binding Part Description
Trigger The property getting changed
Read The source is reading the value of the property
Write The target is storing the new property value in the variable

However, we can make any of the three pieces of a binding as complex as we need to make them. In fact, as you write a Griffon application you are probably using some rather complex binding mojo without even knowing it. That's the point.




Tutorial pages:
 3 Votes

You might also want to check these out:


Leave a Comment on "Have Your People Call My People: Binding"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS