It is hard to say. What version of Tapestry are you working with?

Not my business to say, but I'd be more than a little worried about
trying to store so much state in a cookie object. Despite the relative
ease with which different API's make it possible to muck around with
them most people don't realize that the very large/cumbersome penalty
for this nicety is that all cookie state must be transmitted on each
http request. Just think of it like running with weights on your legs.

On 2/12/07, Manri Offermann <[EMAIL PROTECTED]> wrote:
Hi Tapestry users,

I am trying to store an ASO in a cookie. I have read previous posts about 
problems when the cookie is written and that the issue was fixed, but I still 
seem to have problems.

Somehow the store() method of my CookieScopeManager does not write anything to 
the cookie at all.

Is this issue still related to TAPESTRY-825? Can somebody help me out?

Best regards,

Manri


Here is my CookieScopeManager:

public class CookieScopeManager implements StateObjectPersistenceManager {

    private String applicationId;
 private CookieSource cookieSource;
 private DataSqueezer dataSqueezer;

 /**
  * @see 
org.apache.tapestry.engine.state.StateObjectPersistenceManager#exists(java.lang.String)
  */
 public boolean exists(String objectName) {
        return cookieSource.readCookieValue(buildKey(objectName)) != null;
 }

 /**
  * @see 
org.apache.tapestry.engine.state.StateObjectPersistenceManager#get(java.lang.String,
 org.apache.tapestry.engine.state.StateObjectFactory)
  */
 public Object get(String objectName, StateObjectFactory factory) {
  String key = buildKey(objectName);

        String value = cookieSource.readCookieValue(key);
        if (value == null)
         value = "X"; // NullDataSqueezerFilter
        Object result = dataSqueezer.unsqueeze(value);
        if (result == null) {
         System.out.println("create");
         result = factory.createStateObject();
         cookieSource.writeCookieValue(key, dataSqueezer.squeeze(result));
        }
        System.out.println(ReflectionToStringBuilder.toString(result));
        return result;
 }

 /**
  * @see 
org.apache.tapestry.engine.state.StateObjectPersistenceManager#store(java.lang.String,
 java.lang.Object)
  */
 public void store(String objectName, Object stateObject) {
  try {
   throw new Exception();
  } catch (Exception e) {
   e.printStackTrace();
  }
  String key = buildKey(objectName);
        cookieSource.writeCookieValue(key, dataSqueezer.squeeze(stateObject));
        System.out.println(ReflectionToStringBuilder.toString(stateObject));
        cookieSource.writeCookieValue("foo", "bar");
 }

    private String buildKey(String objectName) {
        return "state:" + applicationId + ":" + objectName;
    }

 /**
  * @param applicationId the applicationId to set
  */
 public void setApplicationId(String applicationId) {
  this.applicationId = applicationId;
 }

 /**
  * @param cookieSource the cookieSource to set
  */
 public void setCookieSource(CookieSource cookieSource) {
  this.cookieSource = cookieSource;
 }

 /**
  * @param dataSqueezer the dataSqueezer to set
  */
 public void setDataSqueezer(DataSqueezer dataSqueezer) {
  this.dataSqueezer = dataSqueezer;
 }
}


--
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to