RE: Hollow state

From: David Solis (dsoli..egosoft.com.mx)
Date: Wed Feb 19 2003 - 13:36:50 EST

  • Next message: Craig Miskell: "RE: Hollow state"

    I've DataContext as a property in the Visit, and this is fine.
    All my pages implement the method (via a superclass):

        public DataContext getDataContext() {
            Visit visit = (Visit) getVisit();
            return visit.getDataContext();
        }

    The problem is: I've several CayenneDataObject subclases as persistent
    properties of pages and because of serialization these objects don't
    have DataContext (CayenneDataObject declares dataContext as transient).

    To clarify:

        public void setService(CustomerService service) {
            _service = service;
            fireObservedChange("service", service);
        }

        public CustomerService getService() {
            return _service;
        }

        public void initialize() {
            _service = null;
        }

        CustomerService _service;

    To fix the problem I've to modify the getter method:

        public CustomerService getService() {
            if (_service.getPersistenceState() == PersistenceState.HOLLOW) {
                _service = (CustomerService)
    getDataContext().refetchObject(_service.getObjectId());
            }
            return _service;
        }

    Regards

    David
    > -----Original Message-----
    > From: Schneider, Eric [mailto:eschneide..iaa-cref.org]
    > Sent: Wednesday, February 19, 2003 12:10 PM
    > To: 'David Solis'; cayenne-use..bjectstyle.org
    > Subject: RE: Hollow state
    >
    >
    > Hey David,
    >
    > So I'm guessing the dataContext object is a persistent
    > property on your page. I don't believe anything has changed
    > with persistent properties in tapestry. The following should work:
    >
    > private DataContext dataContext;
    >
    > public DataContext getDataContext() {
    > return dataContext;
    > }
    >
    > public void setDataContext(DataContext ctxt) {
    > dataContext = ctxt;
    > fireObservedChange("dataContext ", dataContext);
    > }
    >
    > public void detach() {
    > dataContext = null;
    >
    > super.detach();
    > }
    >
    > Are you doing something different?
    >
    > Cheers,
    > Eric
    >
    > -----Original Message-----
    > From: David Solis [mailto:dsoli..egosoft.com.mx]
    > Sent: Wednesday, February 19, 2003 1:01 PM
    > To: cayenne-use..bjectstyle.org
    > Subject: RE: Hollow state
    >
    >
    > I looked the cayenne source code and I found
    > CayenneDataObject already checks the hollow state and refetch
    > the object. The execption is in the line:
    >
    > dataContext.refetchObject(objectId);
    >
    > It seems to me dataContext is null.
    >
    > By the way Tapestry changed the way to persist values. Maybe
    > is a question to the Tapestry list.
    >
    > Any clues?
    >
    > David
    >
    > -----Original Message-----
    > From: David Solis [mailto:dsoli..egosoft.com.mx]
    > Sent: Wednesday, February 19, 2003 11:30 AM
    > To: cayenne-use..bjectstyle.org
    > Subject: Hollow state
    >
    >
    > I'm developing an application with Cayenne 1.0a5 and Tapestry
    > 2.4 alpha 3. I'm getting exceptions like this:
    >
    > java.lang.NullPointerException
    > *
    > org.objectstyle.cayenne.CayenneDataObject.readProperty(Cayenne
    > DataObject.jav
    > a:183)
    >
    > *
    > com.ixe.isis.ixenetadmin.model._CustomerService.getService(_Cu
    > stomerService.
    > java:134)
    >
    > *
    > com.ixe.isis.ixenetadmin.model.CustomerService.getDescription(
    > CustomerServic
    > e.java:18)
    >
    > *
    > com.ixe.isis.ixenetadmin.pages.customer.ServiceSignatureGroups
    > .getTitle(Serv
    > iceSignatureGroups.java:64)
    >
    > * java.lang.reflect.Method.invoke(Native Method)
    >
    > * ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java)
    >
    > * ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java)
    >
    > *
    > ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectProperty
    > Accessor.java)
    >
    >
    > *
    > ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java)
    >
    >
    > * ognl.OgnlRuntime.getProperty(OgnlRuntime.java)
    >
    > * ognl.ASTProperty.getValueBody(ASTProperty.java)
    >
    > * ognl.SimpleNode.getValue(SimpleNode.java)
    >
    > * ognl.Ognl.getValue(Ognl.java)
    >
    > * ognl.Ognl.getValue(Ognl.java)
    >
    > *
    > net.sf.tapestry.binding.ExpressionBinding.resolveProperty(Expr
    > essionBinding.
    > java:232)
    >
    > *
    > net.sf.tapestry.binding.ExpressionBinding.getObject(Expression
    > Binding.java:2
    > 25)
    >
    > *
    > net.sf.tapestry.binding.AbstractBinding.getString(AbstractBind
    > ing.java:141)
    >
    > The real problem is some cayenne EOs are in hollow state and
    > refetch is not automatic.
    >
    > ixenetadmin/ServiceSignatureGroups/customer {[]<oid:
    > com.ixe.isis.ixenetadmin.model.Customer: <RIM_NO: 34177>;
    > state: hollow>}
    >
    > ixenetadmin/ServiceSignatureGroups/service {[]<oid:
    > com.ixe.isis.ixenetadmin.model.CustomerService: <ID_CLIENTE_SERVICIO:
    > 4e5817c2-c0a8-141e-0069-cc0e0373ff20>; state: hollow>}
    >
    > I can "patch" the code to refetch every EO in hollow state,
    > but is this the "normal" behavior?
    >
    > Note: these objects are persistant properties to the page.
    >
    > I developed a prototype using Tapestry 2.3 and didn't
    > experience something similar.
    >
    > Any ideas?
    >
    > Regards
    >
    > David
    >
    >
    >
    >
    >
    > **********************************************************************
    > This message, including any attachments, contains
    > confidential information intended for a specific individual
    > and purpose, and is protected by law. If you are not the
    > intended recipient, please contact sender immediately by
    > reply e-mail and destroy all copies. You are hereby notified
    > that any disclosure, copying, or distribution of this
    > message, or the taking of any action based on it, is strictly
    > prohibited. TIAA-CREF
    > **********************************************************************
    >



    This archive was generated by hypermail 2.0.0 : Wed Feb 19 2003 - 13:39:59 EST