InfoQ

News

JSR 295 Beans Binding Hits 1.0

Posted by Scott Delap on Sep 24, 2007 08:44 AM

Community
Java
Topics
Rich Client / Desktop
Tags
Swing
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.

2 comments

Reply

KVC by Luno Hodov Posted Sep 24, 2007 1:01 PM
Re: KVC by iddaa iddaa Posted Sep 25, 2007 1:23 AM
  1. Back to top

    KVC

    Sep 24, 2007 1:01 PM by Luno Hodov

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

  2. Back to top

    Re: KVC

    Sep 25, 2007 1:23 AM by iddaa iddaa

    thanks KVC iddaa

Exclusive Content

Rationalizing the Presentation Tier

Thin client paradigm characterized by web applications is a kludge that needs to be repudiated. Old compromises are no longer needed and it's time to move the presentation tier to where it belongs.

Agile Project Management: Lessons Learned at Google

In this presentation filmed during QCon 2007, Jeff Sutherland, the creator of Scrum, talks about his visit at Google to do an analysis of Google's first implementation of Scrum.

AtomServer – The Power of Publishing for Data Distribution

In this article, Bryon Jacob and Chris Berry introduce AtomServer, their implementation of a full-fledged Atom Store based on Apache Abdera, which is now available as open source.

An Introduction to Virtualization

It is easy to think that virtualization applies only to servers. In reality the recent resurgence of the concept is also being applied to networking, storage, and application infrastructure.

REST Anti-Patterns

In this article, Stefan Tilkov explains some of the most common anti-patterns found in applications that claim to follow a "RESTful" design and suggests ways to avoid them.

Choosing between Routing and Orchestration in an ESB

In this article, Adrien Louis and Marc Dutoo discuss the differences and relative merits of using orchestration vs. routing in a typical ESB setup, and discuss various implementation options.

Enterprise Batch Processing with Spring

Wayne Lund discusses batch processing, Spring Batch objectives and features, scenarios for usage, Spring Batch architecture, scaling, example code, failures and retrying, and the future roadmap.

User Story Estimation Techniques

Developer Jay Fields draws on his experiences as a ThoughtWorks consultant to describe effective user story estimation techniques.