tapestry-user@jakarta.apache.org
[Top] [All Lists]

RE: Visit, transient objects, and interaction with engine

Subject: RE: Visit, transient objects, and interaction with engine
From: "Robert Walker"
Date: Thu, 17 Mar 2005 16:10:08 -0700
Ryan,

I do exactly this kind of thing with my Visit class, and what I do is
have a base page class from which all the other pages in my application
descend. I then put convenience methods on that class for accessing
objects in the visit. For example:

public class MyBasePage extends BasePage {
        public Object getMyObject() {
                ((Visit) getVisit()).getMyObject(getRequestCycle());
        }
}

Then your OGNL expressions become:

ognl:myObject

Hope that helps,

Robert


-----Original Message-----
From: Ryan Crumley [mailto:crumley@xxxxxxxxx] 
Sent: Thursday, March 17, 2005 3:15 PM
To: tapestry-user@xxxxxxxxxxxxxxxxxx
Subject: Visit, transient objects, and interaction with engine


Following the example found in chapter ten in Tapestry in Action I
have created the following visit object:

public class Visit implements Serializable {
     private transient Object mMyObject;
     private int mMyObjectId;

     public Object getMyObject(IRequestCycle cycle) {
          if(mMyObject == null) {
               Engine engine = (Engine)cycle.getEngine();
               mMyObject = engine.loadMyObject(mMyObjectId);
          }
          return mMyObject;
     }
}

I like this implementation because the serialized Visit object will be
very small and the engine contains all the real logic required to save
and load my persistable objects.

I do not like that in order to obtain a reference to the engine object
I must pass in a IRequestCycle. This makes ognl expressions that
obtain a value from a property on mMyObject more complicated that
before:

ognl:visit.getMyObject(requestCycle).propertyOnMyObject

Are there any ideas on how to do this better? 

Thanks,
ryan

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>