BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Beans Binding Update: Scott Violet on JSR 295

Beans Binding Update: Scott Violet on JSR 295

Scott Violet has written an update on the status of JSR 295 (Beans Binding). While externally, there has been little happening since last summer, the expert group has made substantial progress and he posts a small demo and some code.

Violet warns that they are not done and his example will likely change before they finish, but he posts some code showing how to bind a List of Bugs to a JTable. Here is an example of the binding code:

context = new BindingContext();

List bugs = ...;
Binding tableBinding = context.addBinding(
bugs, // Source for the binding, the List of bugs in this case.
null, // Expression, relative to the source, used in obtaining the property.
// For this example it's null, meaning use bugs as is.
bugTable, // Target of the binding, a JTable in this case.
"elements"); // The property of the target to bind to.

tableBinding.addBinding(
  "${ID}", // Expression evaluated relative to each Bug.
// In this case, it's treated as bug.getID().
null, // Target value (I'm not going to get into this parameter now)
TableColumnParameter, 0); // Specifies the binding applies to the first column

One of the features of binding which has drawn numerous questions in the comments of his post is the use of the JSP Expresion Language to specify the source of a binding. Violet describes why they chose EL:

Until java has first class support for properties, some syntax will need to be adopted. EL was created for needs similar to beans binding and is a natural fit. No point in inventing a new duplicate syntax.

Violet says he is working on making the source available, and some of the commenters hope that he will open a JSR project on java.net to get more feedback from the community.

Rate this Article

Adoption
Style

BT