BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

JSR 295 Beans Binding Hits 1.0

by Scott Delap on Sep 24, 2007 |
Shannon Hickey of Sun recently announced 1.0 of the Beans Binding Framework. This is the reference implementation of JSR 295 that seeks to:

...define an API that greatly simplifies connecting a pair of Java Beans properties to keep them in sync. The connection will be configurable: type conversion and validation operations may be applied before updating a property.

Shannon states that work on the JSR will still continue however and may result in API changes. Version 1.0 does however represent a major re-architecture of the Beans Binding API with the following highlights:

  • The concept of a property has been factored out into an abstract Property class, with two concrete implementations of interest: BeanProperty and ELProperty.
  • Binding is now an abstract class representing a binding between two Property instances (typically associated with two objects).
  • Binding with automatic syncing is implemented by a new concrete AutoBinding subclass.
  • Bindings to complex Swing components (such as JTable, JList and JComboBox) are now handled by custom Binding subclasses.
  • The synthetic Swing properties that offer multiple possible behaviors are now exposed via multiple versions of the property. For example: "text", "text_ON_FOCUS_LOST" and "text_ON_ACTION_OR_FOCUS_LOST" for JTextField; "selectedElement" and "selectedElement_IGNORE_ADJUSTING" for JList and JTable.
  • Everything has been repackaged into org.jdesktop packages.

Basic API for the framework is as follows:

// Bind Duke's first name to the text property of a Swing JTextField
BeanProperty textP = BeanProperty.create("text");
Binding binding =
Bindings.createAutoBinding(READ_WRITE, duke, firstP, textfield, textP);
binding.bind();

// Bind Duke's mother's first name to the text property of a Swing JTextField,
// specifying that the JTextField's text property only reports change
// (thereby updating the source of the READ_WRITE binding) on focus lost
BeanProperty textP = BeanProperty.create("text_ON_FOCUS_LOST");
Binding binding =
Bindings.createAutoBinding(READ_WRITE, duke, motherFirstP, textfield, textP);
binding.bind();

Beans Binding arrives in a Swing space that has used projects such as JGoodies Binding in the past. There is also the JFace Data Binding from the Eclipse Foundation. It provides core implementations for SWT, JFace and JavaBeans. However, the framework has been written with future expansion for API's like Swing and EMF.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

KVC by Luno Hodov

yep, for ages apple's cocoa has something much better - key-value coding... too bad java is so gauche

Re: KVC by iddaa iddaa

thanks KVC
iddaa

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT