cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tomi NA" <>
Subject transient objects: NPE on a.setToB(new B())
Date Sat, 25 Nov 2006 15:44:40 GMT
I'm using (jgoodies) binding as a sync mechanism between my view and
model (cayenne objects) so what I basically do is:
A a = new A();
// bind the model (a) to the UI

When I need to replace the initial (empty) model with a new (empty)
model or a committed model, I simply set the new model to the new or
committed model and the bindings remain in place.

However, I now have two beans representing the model and have tried to
do the following:
A a = new A();
B b = new B();
// bind a and b to the UI

The setToB call, however, throws a NPE.

It's possible that I wouldn't be facing this problem if I registered
the objects with the DataContext, but I'd rather not if there's a way:
the above approach worked well so far.

I register the objects with the DataContext once their properties have
been properly edited and validated and the object itself is added to a
list of valid objects. It seemed to make sense to me that I can build
an object graph, register it's objects with the DataContext and then
simply commit or rollback the changes. It seems that my first
assumption was flawed.
Could someone please enlighten me on the subject?


View raw message