Hello Jesse,
thanks for the quick response and thank you for the great work on Tapestry.
I forgot to mention that I am using the latest 4.1.2-SNAPSHOT.
I was thinking of storing user specific settings (GUI settings like widget
positions and settings etc.) in a cookie. Since I need to access those
settings very frequently in pages and components, I was too lazy to use
CookieSource and convert Strings to Objects and vica versa. My settings are
only valid for the session and another way would be to store the settings in
session scope, but since I try to keep my session object as small as
possible because my application is clustered, I thought of cookies. In my
previous application I have created a wrapper around CookieSource and using
DataSqueezer I was able to store and retrieve simple Objects (for which
SqueezeAdaptors were available) just like using a Map.
Thanks for the pointer to the Storage API, I have to take a closer look at
that.
Regards,
Manri
----- Original Message -----
From: "Jesse Kuhnert" <[EMAIL PROTECTED]>
To: "Tapestry users" <users@tapestry.apache.org>
Sent: Monday, February 12, 2007 4:45 PM
Subject: Re: TAPESTRY-825 ASO in cookie
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]