You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Borut Bolčina <bo...@najdi.si> on 2005/10/24 23:27:49 UTC

Cayenne integration guidelines

Hi,

I searched through the archives and read all that I could about 
integrating Cayenne with Tapestry. The latest thread "Tapestry, Cayenne 
and Squeezer" was informative, especially Filip's post which is on wiki 
also. All other posts were a bit out of date I think dealing with T3. 
Although reading about cayenne squeezer did light some bulbs (ok, more 
of a flickering that is) I felt insecure about how to get started.

I guess it boils down to whether you go stateless or not? In the former 
case one should use ASO session scoped object (visit) and if you want to 
stay stateless, than you should use all the help from 
CayenneDataSqueezer. Is that correct?

Are there  T4 & Cayenne (stateful, stateless or both) examples (best 
practices) somewhere I missed?

Regards,
Borut

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


Re: Cayenne integration guidelines

Posted by Neil Pierson <ne...@gmail.com>.
I'm sure Eric meant 'stateful' instead of 'stateless'.

On 11/1/05, Borut Bolčina <bo...@najdi.si> wrote:
>
> Hi, you got me a bit confused here. See below.
>
>
> > For stateless apps, each individual user has their own DataContext in
> > the Visit object.
>
> Isn't visit (ASO session) the very definition of stateful application?
> According to HLS: "When a session-scoped application state object is
> first created, or when the first persistent page property is recorded.
> At this point, Tapestry will create the HttpSession to hold the object
> or property.". I don't want a session to be created on my first page.
> Now, I understand in T4 I can have persistent properties and stay
> stateless by storing those properties on client side. I guess this can
> be achieved by using hidden fields but with less comfort.
>
>
>
>

Re: Cayenne integration guidelines

Posted by Borut Bolčina <bo...@najdi.si>.
Hi, you got me a bit confused here. See below.

Eric Schneider wrote:

> Borut,
>
> I've always stuck to the simplest approach.  If I'm dealing with a  
> completely stateless application, I share one DataContext for all  
> users (in T4 as a hivemind singleton).   

So each request from browser (user) can change anything in one and only 
DataContext. I imagine there can be such cases where no harm can be done 
to the underlying data.

> For stateless apps, each  individual user has their own DataContext in 
> the Visit object.   

Isn't visit (ASO session) the very definition of stateful application? 
According to HLS: "When a session-scoped application state object is 
first created, or when the first persistent page property is recorded. 
At this point, Tapestry will create the HttpSession to hold the object 
or property.". I don't want a session to be created on my first page. 
Now, I understand in T4 I can have persistent properties and stay 
stateless by storing those properties on client side. I guess this can 
be achieved by using hidden fields but with less comfort.

Consider this scenario:

   1. Page A must collect email and serial number and answers to some
      questions. Based on the email and a number a db look-up must be
      made to see if this "user" already exists (if he/she already
      answered the questions). This can be done by shared (singleton)
      DataContext (I guess by this DataContext context =
      DataContext.getThreadDataContext();)
   2. If the user exists, get this User DataObject and if it doesn't
      create one. In either case pass DataObject to page B via bucket
      brigade pattern.
   3. On page B edit some of the DataObject's properties in text fields,
      validate them and consequently save them along with the data
      collected on page A which were passed on page B also (user's
      answers). If users existed an UPDATE must be made, if not an
      INSERT. An update is made if DataObject is in CHANGED state, so
      the DataContext into which this existing user was fetched in on
      page A must be the same as this DataObject's properties are being
      edited on page B. And that would be this global DataContext.

Can anyone comment please?

> I  haven't used the CayenneDataSqueezer, simply because I haven't had 
> to  yet (though, I understand it's extremely useful).
>
> My object entities tend to be a bit wide, so they're not something  
> I'd typically squeeze into a direct link for example (really long  
> urls can lead to undesired results w/some browsers).   More often I  
> squeeze the object's ObjectId on actions related to specific data  
> objects.
>
> Hope that helps.
> Eric
>
> On Oct 24, 2005, at 5:27 PM, Borut Bolčina wrote:
>
>> Hi,
>>
>> I searched through the archives and read all that I could about  
>> integrating Cayenne with Tapestry. The latest thread "Tapestry,  
>> Cayenne and Squeezer" was informative, especially Filip's post  which 
>> is on wiki also. All other posts were a bit out of date I  think 
>> dealing with T3. Although reading about cayenne squeezer did  light 
>> some bulbs (ok, more of a flickering that is) I felt insecure  about 
>> how to get started.
>>
>> I guess it boils down to whether you go stateless or not? In the  
>> former case one should use ASO session scoped object (visit) and if  
>> you want to stay stateless, than you should use all the help from  
>> CayenneDataSqueezer. Is that correct?
>>
>> Are there  T4 & Cayenne (stateful, stateless or both) examples  (best 
>> practices) somewhere I missed?
>>
>> Regards,
>> Borut
>>
>> ---------------------------------------------------------------------
>> 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: Cayenne integration guidelines

Posted by Johan Maasing <jo...@zoom.nu>.
Eric Schneider wrote:
> Borut,
> 
> I've always stuck to the simplest approach.  If I'm dealing with a  
> completely stateless application, I share one DataContext for all  users 
> (in T4 as a hivemind singleton).   For stateless apps, each  individual 
> user has their own DataContext in the Visit object.   I  haven't used 
> the CayenneDataSqueezer, simply because I haven't had to  yet (though, I 
> understand it's extremely useful).
> 
> My object entities tend to be a bit wide, so they're not something  I'd 
> typically squeeze into a direct link for example (really long  urls can 
> lead to undesired results w/some browsers).   More often I  squeeze the 
> object's ObjectId on actions related to specific data  objects.

I would say that then you have had to use the squeezer but you did not 
know it :-) I have recently started using Cayenne and I found that 
Roberts squeezer is a wonderful piece of refactoring of exactly that 
operation. Even if it is not difficult to implement why repeat that code 
on several pages when the squeezer can do it.

I also found that the DataContext.getThreadDataContext() is very 
convinient for getting hold of the DataContext.
http://objectstyle.org/cayenne/userguide/deploy/webapplicationcontextprovider.html 


As a newbie on Cayenne I found that those two things made it rather easy 
  to get things running.

> 
> Hope that helps.
> Eric

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


Re: Cayenne integration guidelines

Posted by Eric Schneider <er...@centralparksoftware.com>.
Borut,

I've always stuck to the simplest approach.  If I'm dealing with a  
completely stateless application, I share one DataContext for all  
users (in T4 as a hivemind singleton).   For stateless apps, each  
individual user has their own DataContext in the Visit object.   I  
haven't used the CayenneDataSqueezer, simply because I haven't had to  
yet (though, I understand it's extremely useful).

My object entities tend to be a bit wide, so they're not something  
I'd typically squeeze into a direct link for example (really long  
urls can lead to undesired results w/some browsers).   More often I  
squeeze the object's ObjectId on actions related to specific data  
objects.

Hope that helps.
Eric

On Oct 24, 2005, at 5:27 PM, Borut Bolčina wrote:

> Hi,
>
> I searched through the archives and read all that I could about  
> integrating Cayenne with Tapestry. The latest thread "Tapestry,  
> Cayenne and Squeezer" was informative, especially Filip's post  
> which is on wiki also. All other posts were a bit out of date I  
> think dealing with T3. Although reading about cayenne squeezer did  
> light some bulbs (ok, more of a flickering that is) I felt insecure  
> about how to get started.
>
> I guess it boils down to whether you go stateless or not? In the  
> former case one should use ASO session scoped object (visit) and if  
> you want to stay stateless, than you should use all the help from  
> CayenneDataSqueezer. Is that correct?
>
> Are there  T4 & Cayenne (stateful, stateless or both) examples  
> (best practices) somewhere I missed?
>
> Regards,
> Borut
>
> ---------------------------------------------------------------------
> 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