Another problem due to changes PageRecorder in 2.4 version

From: David Solis (dsoli..egosoft.com.mx)
Date: Wed Feb 19 2003 - 14:17:00 EST

  • Next message: David Solis: "RE: 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(CayenneDataObject
    .java:183)

    *
    com.ixe.isis.ixenetadmin.model._CustomerService.getService(_CustomerServ
    ice.java:134)

    *
    com.ixe.isis.ixenetadmin.model.CustomerService.getDescription(CustomerSe
    rvice.java:18)

    *
    com.ixe.isis.ixenetadmin.pages.customer.ServiceSignatureGroups.getTitle(
    ServiceSignatureGroups.java:64)

    * java.lang.reflect.Method.invoke(Native Method)

    * ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java)

    * ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java)

    *
    ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.j
    ava)

    *
    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(ExpressionBind
    ing.java:232)

    *
    net.sf.tapestry.binding.ExpressionBinding.getObject(ExpressionBinding.ja
    va:225)

    *
    net.sf.tapestry.binding.AbstractBinding.getString(AbstractBinding.java:1
    41)
     
    I developed the prototype using Tapestry 2.3 and didn't experience
    something similar.
     
    More information:

    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();
        }

    I've several CayenneDataObject subclases as persistent properties of
    pages and because of serialization DataContext for these objects is null
    (CayenneDataObject declares dataContext as transient).

    To clarify:

        public CustomerService getService() {
            return _service;
        }

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

        public void initialize() {
            _service = null;
        }

        CustomerService _service;

    In order 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;
        }

    This is obviously an artifact and I don't want to "patch" the code. In
    addition I can't use the new declarative properties.
     
    According to Cayenne developers DataConext must be transient:
    "Serialization works the other way around in Cayenne - DataContext
    serializes and deserializes its objects. Making context transient allows
    to avoid double serialization (Craig Miskell, who implemented this code
    may, correct me if I am wrong). So if Visit's DataContext is serialized,
    all objects should be restored properly (see DataContext.readObject())."

    The fact is: I can't use Tapestry 2.4 with Cayenne as the same way as
    with Tapestry 2.3.
     
     
    Any ideas?
     
    Regards
     
    David



    This archive was generated by hypermail 2.0.0 : Wed Feb 19 2003 - 14:20:20 EST