Usage of the framework

0 views
Skip to first unread message

dondragon2

unread,
Oct 6, 2009, 11:34:02 AM10/6/09
to Client-Objects User Group
I saw this framework and decised to give it a shot but I got the
following issue.

When I tried to use the following method in my own application it did
not work.

PropertyAdapter lastNameA = new PropertyAdapter(bean, "lastName",
true);
JTextField lastNameF = BasicComponentFactory.createTextField
(lastNameA, true);

I had to change to something like

BeanAdapter adapter = new BeanAdapter(bean, true);
ValueModel firstName = adapter.getValueModel("firstName");
JTextField firstNameF = new JTextfield();
Bindings.bind(firstNameF ,firstName );

Why is this the case?

Also when I try to get the data from the field in order to persist it
then the value is null? If I step through my debugger it shows that
the original object data has been updated but not the proxy. How do I
get this underlying data?

Yegor

unread,
Oct 6, 2009, 2:20:01 PM10/6/09
to Client-Objects User Group
Hi, dondragon2,

Thanks for reporting this problem. I think you found a bug. Proxy
fields are not populated by design. Getters/setters are invoked on the
original object and therefore should return data. However, when you
invoke a non-getter/setter method it is invoked on the proxy.
Consequently any method trying to access the object's private fields
will get the nulls.

I am going to introduce a patch which will redirect non-getter/setter
calls to the original POJO object. There will still be a (hopefully
acceptable) caveat. You will be able to access private fields using
_this_ instance, but trying to access private fields of another
instance may be problematic if the other instance is an enhanced
proxy. I can see how this could be problematic for the "equals"
methods. So I will create a special case for the "equals" method and
replace proxies with the originals.

Maybe the cleanest solution would be to keep field values in sync
between the proxies and the original POJOs. I am going to investigate
this possibility.

Thanks,

Yegor

Yegor

unread,
Oct 6, 2009, 2:21:09 PM10/6/09
to Client-Objects User Group

Yegor

unread,
Oct 6, 2009, 2:28:08 PM10/6/09
to Client-Objects User Group
I have committed the fix into trunk. Feel free to checkout, test and
report your experiences.

Thanks,

Yegor

dondragon2

unread,
Oct 6, 2009, 3:40:06 PM10/6/09
to Client-Objects User Group
Hi Yegor,

What is happening is this. I create a bean similar to the Customer
bean in you tutorial and the data is being displayed in the GUI as
should be the case.
I have a save button that when click it takes the information
(bean.getFirstName()) in the customer bean and do something with it.
It is at this point that the getters are returning null.

Are we on the same page here?

Regards,
Donald

Yegor

unread,
Oct 6, 2009, 4:10:58 PM10/6/09
to Client-Objects User Group
dondragon2,

I will need to see a sample code to be sure. Take a look at
CustomerForm from the form-sample. Specifically, in printBeanAction,
which is bound to the printBeanBtn, you will see calls to fullName()
and getBirthDate() of the enhanced bean. Both methods return correct
values. It may have something to do with the BeanAdapter. I will take
a look when I get a chance.

Yegor
Reply all
Reply to author
Forward
0 new messages