transient objects: NPE on a.setToB(new B())

From: Tomi NA (hefes..mail.com)
Date: Sat Nov 25 2006 - 10:44:40 EST

  • Next message: Andrus Adamchik: "Re: transient objects: NPE on a.setToB(new B())"

    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();
    a.setToB(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?

    TIA,
    t.n.a.



    This archive was generated by hypermail 2.0.0 : Sat Nov 25 2006 - 10:45:28 EST