You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Martin Strand <ma...@entcap.se> on 2005/11/01 15:44:12 UTC

Persist large objects

Hi.
I want to persist a large object on the client, but it would be much  
better if I could just persist its id and then re-create it on the server  
on each request. Can Tapestry do this for me? I could do it myself,  
something like this:

----
private User user;

public void detach()
{
   user = null;
   super.detach();
}

public User getUser()
{
   if (user == null)
   {
     user = new User(getUserId());
   }
   return user;
}

@Persist("client:page")
public abstract int getuserId();
----



But I'd prefer to let Tapestry do it for me, something like this:

----
@Persist("client:page")
public abstract User getUser();
----

How could I make the second version understand that it only needs to  
persist the user id?

Thanks,
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Robert Zeigler <ro...@scazdl.org>.
Ah, didn't know that, sorry... I'm curious as the motivation for /not/
using datasqueezers?

Robert

Howard Lewis Ship wrote:
> The client property persistent manager doesn't use the data squeezer;
> it always serializes a bunch of objects to a MIME64 stream.  A
> DataSqueezer is used for objects encoded as listener parameters or as
> hidden form fields.
> 
> On 11/1/05, Robert Zeigler <ro...@scazdl.org> wrote:
> 
>>Create a custom data squeezer for your object and register it.
>>
>>Robert
>>
>>Martin Strand wrote:
>>
>>>Hi.
>>>I want to persist a large object on the client, but it would be much
>>>better if I could just persist its id and then re-create it on the
>>>server  on each request. Can Tapestry do this for me? I could do it
>>>myself,  something like this:
>>>
>>>----
>>>private User user;
>>>
>>>public void detach()
>>>{
>>>  user = null;
>>>  super.detach();
>>>}
>>>
>>>public User getUser()
>>>{
>>>  if (user == null)
>>>  {
>>>    user = new User(getUserId());
>>>  }
>>>  return user;
>>>}
>>>
>>>@Persist("client:page")
>>>public abstract int getuserId();
>>>----
>>>
>>>
>>>
>>>But I'd prefer to let Tapestry do it for me, something like this:
>>>
>>>----
>>>@Persist("client:page")
>>>public abstract User getUser();
>>>----
>>>
>>>How could I make the second version understand that it only needs to
>>>persist the user id?
>>>
>>>Thanks,
>>>Martin
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Jakarta Tapestry
> Creator, Jakarta HiveMind
> 
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Robert Zeigler <ro...@scazdl.org>.
Indeed, I find it highly inconsistent and problematic.
Why should url parameters and hidden form field objects be stored
differently if they are for a "hidden form field" or "listener" vs. if
they are for client side persistence? If you are using forms and posts
to do the client side persistence, then the objects are getting written
to hidden form fields.  If you are using get, then they are written to
the URL.  I see no reason for the difference.  Personally, I use
cayenne; I wrote a cayenne squeeze adapter; the fact that I would have
to handle objects different for client side persistence essentially
relegates the usefulness of client-side persistence, for me, to about 0.
I suspect that there was some motivation behind this decision (because,
obviously, a consistent developer experience wasn't it), but I don't
know what that motivation was.  Anybody who /does/ know the motivation
want to comment on it?

Robert

Vjeran Marcinko wrote:
> Hi all.
> 
> Robert probably knows that he can overcome his problem by manually
> taking care of entity's ID, but whole point of having custom
> DataSqueezer in application should be that developer should never again
> have to worry what part of entity is being squeezed, and how it is being
> unsqueezed afterwards.
> 
> As said, it all works nicely for listener parameters and form fields,
> but strangely, same mechanism hasn't been utilized for client persistence.
> Not that it bothers me, since I never used custom DataSqueezers, but I
> think I understand Robert's confusion.
> 
> -Vjeran
> 
> ----- Original Message ----- From: "Ron Piterman" <rp...@gmx.net>
> To: <ta...@jakarta.apache.org>
> Sent: Tuesday, November 01, 2005 9:19 PM
> Subject: Re: Persist large objects
> 
> 
> I did not quite follow Henri's idea.
> I would do exacly as you suggest- persist just the id and use it.
> *maybe* that will work:
> 
> <property name="id" persist="..."/>
> <property name="object" initial-value="populateId(id)"/>
> 
> public Object populateId(Object id) {
>  return ....;
> }
> 
> Cheers,
> Ron
> 
> 
> ציטוט Martin Strand:
> 
>> Ok, does that mean that the best way is to persist the object id and
>> then simply re-create the object myself on each request?
>> That's what I'm doing now, I just found that the same set of methods
>> (detach(), get/setSomeObject(), @Persist get/setSomeObjectId()) keeps
>> repeating itself in several of my page classes, so I figured perhaps
>> Tapestry could give me a hand. :)
>>
>> --Martin
>>
>> On Tue, 01 Nov 2005 17:44:27 +0100, Howard Lewis Ship
>> <hl...@gmail.com> wrote:
>>
>>> The client property persistent manager doesn't use the data squeezer;
>>> it always serializes a bunch of objects to a MIME64 stream.  A
>>> DataSqueezer is used for objects encoded as listener parameters or as
>>> hidden form fields.
>>>
>>> On 11/1/05, Robert Zeigler <ro...@scazdl.org> wrote:
>>>
>>>> Create a custom data squeezer for your object and register it.
>>>>
>>>> Robert
>>>>
>>>> Martin Strand wrote:
>>>> > Hi.
>>>> > I want to persist a large object on the client, but it would be much
>>>> > better if I could just persist its id and then re-create it on the
>>>> > server  on each request. Can Tapestry do this for me? I could do it
>>>> > myself,  something like this:
>>>> >
>>>> > ----
>>>> > private User user;
>>>> >
>>>> > public void detach()
>>>> > {
>>>> >   user = null;
>>>> >   super.detach();
>>>> > }
>>>> >
>>>> > public User getUser()
>>>> > {
>>>> >   if (user == null)
>>>> >   {
>>>> >     user = new User(getUserId());
>>>> >   }
>>>> >   return user;
>>>> > }
>>>> >
>>>> > @Persist("client:page")
>>>> > public abstract int getuserId();
>>>> > ----
>>>> >
>>>> >
>>>> >
>>>> > But I'd prefer to let Tapestry do it for me, something like this:
>>>> >
>>>> > ----
>>>> > @Persist("client:page")
>>>> > public abstract User getUser();
>>>> > ----
>>>> >
>>>> > How could I make the second version understand that it only needs to
>>>> > persist the user id?
>>>> >
>>>> > Thanks,
>>>> > Martin
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Vjeran Marcinko <vj...@email.t-com.hr>.
Hi all.

Robert probably knows that he can overcome his problem by manually taking 
care of entity's ID, but whole point of having custom DataSqueezer in 
application should be that developer should never again have to worry what 
part of entity is being squeezed, and how it is being unsqueezed afterwards.

As said, it all works nicely for listener parameters and form fields, but 
strangely, same mechanism hasn't been utilized for client persistence.
Not that it bothers me, since I never used custom DataSqueezers, but I think 
I understand Robert's confusion.

-Vjeran

----- Original Message ----- 
From: "Ron Piterman" <rp...@gmx.net>
To: <ta...@jakarta.apache.org>
Sent: Tuesday, November 01, 2005 9:19 PM
Subject: Re: Persist large objects


I did not quite follow Henri's idea.
I would do exacly as you suggest- persist just the id and use it.
*maybe* that will work:

<property name="id" persist="..."/>
<property name="object" initial-value="populateId(id)"/>

public Object populateId(Object id) {
  return ....;
}

Cheers,
Ron


ציטוט Martin Strand:
> Ok, does that mean that the best way is to persist the object id and then 
> simply re-create the object myself on each request?
> That's what I'm doing now, I just found that the same set of methods 
> (detach(), get/setSomeObject(), @Persist get/setSomeObjectId()) keeps 
> repeating itself in several of my page classes, so I figured perhaps 
> Tapestry could give me a hand. :)
>
> --Martin
>
> On Tue, 01 Nov 2005 17:44:27 +0100, Howard Lewis Ship <hl...@gmail.com> 
> wrote:
>
>> The client property persistent manager doesn't use the data squeezer;
>> it always serializes a bunch of objects to a MIME64 stream.  A
>> DataSqueezer is used for objects encoded as listener parameters or as
>> hidden form fields.
>>
>> On 11/1/05, Robert Zeigler <ro...@scazdl.org> wrote:
>>
>>> Create a custom data squeezer for your object and register it.
>>>
>>> Robert
>>>
>>> Martin Strand wrote:
>>> > Hi.
>>> > I want to persist a large object on the client, but it would be much
>>> > better if I could just persist its id and then re-create it on the
>>> > server  on each request. Can Tapestry do this for me? I could do it
>>> > myself,  something like this:
>>> >
>>> > ----
>>> > private User user;
>>> >
>>> > public void detach()
>>> > {
>>> >   user = null;
>>> >   super.detach();
>>> > }
>>> >
>>> > public User getUser()
>>> > {
>>> >   if (user == null)
>>> >   {
>>> >     user = new User(getUserId());
>>> >   }
>>> >   return user;
>>> > }
>>> >
>>> > @Persist("client:page")
>>> > public abstract int getuserId();
>>> > ----
>>> >
>>> >
>>> >
>>> > But I'd prefer to let Tapestry do it for me, something like this:
>>> >
>>> > ----
>>> > @Persist("client:page")
>>> > public abstract User getUser();
>>> > ----
>>> >
>>> > How could I make the second version understand that it only needs to
>>> > persist the user id?
>>> >
>>> > Thanks,
>>> > Martin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.6/152 - Release Date: 31.10.2005



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Ron Piterman <rp...@gmx.net>.
I did not quite follow Henri's idea.
I would do exacly as you suggest- persist just the id and use it.
*maybe* that will work:

<property name="id" persist="..."/>
<property name="object" initial-value="populateId(id)"/>

public Object populateId(Object id) {
  return ....;
}

Cheers,
Ron


ציטוט Martin Strand:
> Ok, does that mean that the best way is to persist the object id and 
> then  simply re-create the object myself on each request?
> That's what I'm doing now, I just found that the same set of methods  
> (detach(), get/setSomeObject(), @Persist get/setSomeObjectId()) keeps  
> repeating itself in several of my page classes, so I figured perhaps  
> Tapestry could give me a hand. :)
> 
> --Martin
> 
> On Tue, 01 Nov 2005 17:44:27 +0100, Howard Lewis Ship 
> <hl...@gmail.com>  wrote:
> 
>> The client property persistent manager doesn't use the data squeezer;
>> it always serializes a bunch of objects to a MIME64 stream.  A
>> DataSqueezer is used for objects encoded as listener parameters or as
>> hidden form fields.
>>
>> On 11/1/05, Robert Zeigler <ro...@scazdl.org> wrote:
>>
>>> Create a custom data squeezer for your object and register it.
>>>
>>> Robert
>>>
>>> Martin Strand wrote:
>>> > Hi.
>>> > I want to persist a large object on the client, but it would be much
>>> > better if I could just persist its id and then re-create it on the
>>> > server  on each request. Can Tapestry do this for me? I could do it
>>> > myself,  something like this:
>>> >
>>> > ----
>>> > private User user;
>>> >
>>> > public void detach()
>>> > {
>>> >   user = null;
>>> >   super.detach();
>>> > }
>>> >
>>> > public User getUser()
>>> > {
>>> >   if (user == null)
>>> >   {
>>> >     user = new User(getUserId());
>>> >   }
>>> >   return user;
>>> > }
>>> >
>>> > @Persist("client:page")
>>> > public abstract int getuserId();
>>> > ----
>>> >
>>> >
>>> >
>>> > But I'd prefer to let Tapestry do it for me, something like this:
>>> >
>>> > ----
>>> > @Persist("client:page")
>>> > public abstract User getUser();
>>> > ----
>>> >
>>> > How could I make the second version understand that it only needs to
>>> > persist the user id?
>>> >
>>> > Thanks,
>>> > Martin
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Henri Dupre <he...@gmail.com>.
I believe you could do that using a hivemind service and you could
inject in your hivemind service the object id value and put all your
methods in that object.

Henri.

On 11/1/05, Martin Strand <ma...@entcap.se> wrote:
> Ok, does that mean that the best way is to persist the object id and then
> simply re-create the object myself on each request?
> That's what I'm doing now, I just found that the same set of methods
> (detach(), get/setSomeObject(), @Persist get/setSomeObjectId()) keeps
> repeating itself in several of my page classes, so I figured perhaps
> Tapestry could give me a hand. :)
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Martin Strand <ma...@entcap.se>.
Ok, does that mean that the best way is to persist the object id and then  
simply re-create the object myself on each request?
That's what I'm doing now, I just found that the same set of methods  
(detach(), get/setSomeObject(), @Persist get/setSomeObjectId()) keeps  
repeating itself in several of my page classes, so I figured perhaps  
Tapestry could give me a hand. :)

--Martin

On Tue, 01 Nov 2005 17:44:27 +0100, Howard Lewis Ship <hl...@gmail.com>  
wrote:

> The client property persistent manager doesn't use the data squeezer;
> it always serializes a bunch of objects to a MIME64 stream.  A
> DataSqueezer is used for objects encoded as listener parameters or as
> hidden form fields.
>
> On 11/1/05, Robert Zeigler <ro...@scazdl.org> wrote:
>> Create a custom data squeezer for your object and register it.
>>
>> Robert
>>
>> Martin Strand wrote:
>> > Hi.
>> > I want to persist a large object on the client, but it would be much
>> > better if I could just persist its id and then re-create it on the
>> > server  on each request. Can Tapestry do this for me? I could do it
>> > myself,  something like this:
>> >
>> > ----
>> > private User user;
>> >
>> > public void detach()
>> > {
>> >   user = null;
>> >   super.detach();
>> > }
>> >
>> > public User getUser()
>> > {
>> >   if (user == null)
>> >   {
>> >     user = new User(getUserId());
>> >   }
>> >   return user;
>> > }
>> >
>> > @Persist("client:page")
>> > public abstract int getuserId();
>> > ----
>> >
>> >
>> >
>> > But I'd prefer to let Tapestry do it for me, something like this:
>> >
>> > ----
>> > @Persist("client:page")
>> > public abstract User getUser();
>> > ----
>> >
>> > How could I make the second version understand that it only needs to
>> > persist the user id?
>> >
>> > Thanks,
>> > Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Howard Lewis Ship <hl...@gmail.com>.
The client property persistent manager doesn't use the data squeezer;
it always serializes a bunch of objects to a MIME64 stream.  A
DataSqueezer is used for objects encoded as listener parameters or as
hidden form fields.

On 11/1/05, Robert Zeigler <ro...@scazdl.org> wrote:
> Create a custom data squeezer for your object and register it.
>
> Robert
>
> Martin Strand wrote:
> > Hi.
> > I want to persist a large object on the client, but it would be much
> > better if I could just persist its id and then re-create it on the
> > server  on each request. Can Tapestry do this for me? I could do it
> > myself,  something like this:
> >
> > ----
> > private User user;
> >
> > public void detach()
> > {
> >   user = null;
> >   super.detach();
> > }
> >
> > public User getUser()
> > {
> >   if (user == null)
> >   {
> >     user = new User(getUserId());
> >   }
> >   return user;
> > }
> >
> > @Persist("client:page")
> > public abstract int getuserId();
> > ----
> >
> >
> >
> > But I'd prefer to let Tapestry do it for me, something like this:
> >
> > ----
> > @Persist("client:page")
> > public abstract User getUser();
> > ----
> >
> > How could I make the second version understand that it only needs to
> > persist the user id?
> >
> > Thanks,
> > Martin
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Persist large objects

Posted by Robert Zeigler <ro...@scazdl.org>.
Create a custom data squeezer for your object and register it.

Robert

Martin Strand wrote:
> Hi.
> I want to persist a large object on the client, but it would be much 
> better if I could just persist its id and then re-create it on the
> server  on each request. Can Tapestry do this for me? I could do it
> myself,  something like this:
> 
> ----
> private User user;
> 
> public void detach()
> {
>   user = null;
>   super.detach();
> }
> 
> public User getUser()
> {
>   if (user == null)
>   {
>     user = new User(getUserId());
>   }
>   return user;
> }
> 
> @Persist("client:page")
> public abstract int getuserId();
> ----
> 
> 
> 
> But I'd prefer to let Tapestry do it for me, something like this:
> 
> ----
> @Persist("client:page")
> public abstract User getUser();
> ----
> 
> How could I make the second version understand that it only needs to 
> persist the user id?
> 
> Thanks,
> Martin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org