HOWTO integrate custom BeansBindingTypeHandler

12 views
Skip to first unread message

wwagner4

unread,
Mar 30, 2009, 4:43:00 AM3/30/09
to JavaBuilders
Hi.
I have developed my own beansbinding and wanted to exchange it with
the integrated binding.
Therefoere I wrote my own BeansBindingTypeHandler.
I succeeded but I had to change your the original code.

public SwingJavaBuilderConfig() {
super(SwingBackgroundProcessingHandler.getInstance(),
getBeansBindingTypeHandler(), SwingValidationMessageHandler
.getInstance(), new ConfirmCommand());

// define aliases for AWT types
addType(Applet.class, Button.class, Canvas.class, Checkbox.class,

In the first line of the constructor I exchanged the original
BeansBindingTypeHandler getInstance() by the method
getBeansBindingTypeHandler() that returns any TypeHandler that was
configured.

What is the correct way to integrate ynother beans binding?

Jacek Furmankiewicz

unread,
Mar 30, 2009, 8:00:07 AM3/30/09
to JavaBuilders
Well, if you look at the BuilderConfig constructor, all it really does
is:

if (bindingTypeHandler != null) {
addTypeHandler(bindingTypeHandler);
}

So, theoretically if you do

SwingJavaBuilder.getConfig().addTypeHandler(your binding handler) it
*should* override the default implementation. Let me know if it
doesn't. The important part is that in your implementation the
getApplicableClass() method should return the same type as in the
default implementation.

Can you give me some idea as to how your implementation differs from
the base one and what sort of improvements you have done?
I'd be more than happy to roll some of them into the base version if
it's worthwhile.

Cheers, Jacek

wwagner4

unread,
Mar 30, 2009, 2:01:15 PM3/30/09
to JavaBuilders
I have tried it out and it worked. Thanks.

Anyway I would suggest to remove the compiltime dependency of any type
handler from the builder config. Of course there mut be a default
builder that gets initialized if no other one is defined, but you
could initialze it using ...newInsatnce().
Another issue is, that the TypeHandler should be lazy initialized.
At the moment the BeansBindingTypeHandler is instantiated on every
startup and removed later. I have to have it in my classpath although
I don't need it.

The bindig framewor I'am using is jacobin. http://entelijan.net/jacobin.
I will drop a note if my first integration example with javabuilders
is working.



Jacek Furmankiewicz

unread,
Mar 30, 2009, 2:33:48 PM3/30/09
to JavaBuilders
Thanks, that would be great. I will see what I can do to make
BeansBinding an optional dependency. Probably a quick Class.forName()
check to see if it's the classpath should suffice

Jacek Furmankiewicz

unread,
Mar 30, 2009, 10:16:51 PM3/30/09
to JavaBuilders
Could you do me a favor and enter a defect/issue for this on the
google code website? It helps me to keep track of things while I am
working on the next release.

thanks

Jacek Furmankiewicz

unread,
Mar 30, 2009, 10:55:25 PM3/30/09
to JavaBuilders
Forget about it, no need...I create issue #29 for it and fixed it for
you in the new 1.0.DEV build. Let me know if it helps.

wwagner4

unread,
Mar 31, 2009, 3:44:13 PM3/31/09
to JavaBuilders
I tried it out and it worked. I could start my sample application
without beansbinding in the classpath.
In stdout I get
31.03.2009 21:41:52 org.javabuilders.swing.SwingJavaBuilderConfig
<init>
INFO: Beans Binding (JSR 295) not found in path, default
BeansBindingTypeHandler not initialized.
That is what you expected.

wwagner4

unread,
Mar 31, 2009, 3:45:54 PM3/31/09
to JavaBuilders
I tried it out and it worked. I could start my sample application
without beansbinding in the classpath.
In stdout I get
31.03.2009 21:41:52 org.javabuilders.swing.SwingJavaBuilderConfig
<init>
INFO: Beans Binding (JSR 295) not found in path, default
BeansBindingTypeHandler not initialized.
I think that is what you expected.

Jacek Furmankiewicz

unread,
Mar 31, 2009, 3:48:00 PM3/31/09
to JavaBuilders
Yes, correct. I want to input the INFO msg at least once, in case
someone forgot to add it to the classpath by mistake.

Pls keep us posted on your progress...I am definitely interested in
finding a binding solution that would be better than the moribund
Beans Binding....
Reply all
Reply to author
Forward
0 new messages