Skip to main content

Half Baked Beans

Posted by evanx on July 20, 2007 at 3:37 AM PDT

Let's define a minimal property interface.

public interface Property {
  public void set(V value);
  public V get();  
}

where its implementation wraps a java.bean.PropertyDescriptor.

Now baked beans...

public interface BakedBeanInfo {
  public Property getProperty(String propertyName);
}

where its implementation wraps a java.bean.BeanInfo, and constructs a collection of the bean's Property instances.

Now the trick is we expose our bean/properties as an interface...

public interface PersonInfo {
   Property username();
   Property displayName();
   Property age();
   ...
}

where we use dynamic proxies to create a bean, and/or bean info, without worrying about the implementation (eg. QBeanInfo presented in Gooey Bean Info et al).

   PersonInfo personBean = GBeanFactory.createObservable(PersonInfo.class);
   ...
   GTableModel tableModel = new GTableModel(PersonInfo.class);
   GForm form = new GForm(PersonInfo.class);
   ...
      logger.info(tableModel.getSelected().displayName().get());
      form.set(tableModel.getSelected());     

where we bind to a backing bean instance (eg. Person.class) i.e. a POJO/java.bean with accessors/mutators - or not e.g. just use the proxy instance as our presentation model.

Lemme repeat... For prototyping, we might not worry about creating a Person.class, but just use the bean info interface to create our observable beans (via dynamic proxy), with built-in PropertyChangeSupport.

Our Property implementation might let us specify (default) presentation properties (eg. label, display width, format et al) of that property, and attach validators, as in Gooey Bean Form.

waddaya think?!

PS. The next installment on Gooey Beans is immiment at last, about JTable's, since i got the demo working, as in the following sneak preview, woohoo! :)

divvy.png

Notice how the selection works, e.g. click on the search icon to select the pirate, and enter a blank booty barcode to select some booty! Later i'll look at a popup finder for entities, rather than switching tabs as it currently works.

Before all that, i'll implement and write an article on the above baked beans, to publish this month in Gooey Beans - and then publish the TableModel article in a coupla of weeks, before i set off on my travels to UK, Russia, Nepal, Ireland et al - Eet's nice... very very frikkin nice! Woohoo! Mmmmm.... Planet Earth...

Related Topics >>