The Source for Java Technology Collaboration
User: Password:



Evan Summers

Evan Summers's Blog

Half Baked Beans

Posted by evanx on July 20, 2007 at 03:37 AM | Comments (2)

Let's define a minimal property interface.

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

where its implementation wraps a java.bean.PropertyDescriptor.

Now baked beans...

public interface BakedBeanInfo<B> {
  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<String> username();
   Property<String> displayName();
   Property<Integer> 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<PersonInfo> tableModel = new GTableModel(PersonInfo.class);
   GForm<PersonInfo> 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) ie. a POJO/java.bean with accessors/mutators - or not eg. 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

Launch   (PirateWarez , 150k/500k, unsandboxed, Java6)

Notice how the selection works, eg. 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...



Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Draft article showing example code implementation - Gooey Beans Proxy. Right now i'm thinking this is a nice hack! Problem is when i think i've done something ubercool, the excitement seems limited to myself! ;)

    Posted by: evanx on July 21, 2007 at 01:51 PM

  • How about JPA (or another persistence library)? And where do I put my business logic? And how to combine business logic and JPA?

    Posted by: tbee on July 23, 2007 at 01:27 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds