|
|
||||
Evan Summers's BlogHalf Baked BeansPosted 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! :)
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.
Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment
| ||||
|
|