You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by D Tim Cummings <ti...@triptera.com.au.INVALID> on 2021/05/12 10:50:10 UTC

Examples of Cayenne Tapestry apps

Does anyone know of any good open-source Cayenne Tapestry apps that show
best practice and latest features for using these two frameworks
together? Most of the Tapestry examples use Hibernate.

Tim




Re: Examples of Cayenne Tapestry apps

Posted by D Tim Cummings <ti...@triptera.com.au.INVALID>.
Thanks Michael. This is useful. I think I am persisting too much in my
Tapestry Cayenne app and would like to view other apps to see how they
avoid the temptation to @Persist.

I too am using tomcat for deployment. Fortunately I don't have any huge
forms.

Tim

> On 12/5/21 22:02, Michael Gentry wrote:
>> Hi Tim!
>>
>> The Tapestry+Cayenne apps I worked on weren't open source, but the
>> combination worked amazingly well for us.
>>
>> In the largest one, we had a small user base, but the object graph being
>> edited could be 100s or for a few, over 1000 records [1]. Because the
>> number of records could take a while to load in from the database and
>> because our validations had to traverse the entire object graph every time,
>> we chose to make the app session-based. Didn't have any issues with the
>> object graph being in session and Tapestry did a great job reading the data
>> from the Cayenne object graph to edit in the UI and pushing all the data
>> back to the Cayenne object graph on submit where we could re-validate.
>>
>> Our save button was essentially dataContext.commitChanges(), with a
>> try/catch block around it to handle errors. This was a HUGE advantage over
>> having to micromanage each individual record like you'd do with
>> Hibernate/JPA -- plus no LazyInitializationExceptions ever.
>>
>> My memory is a little fuzzy here, but I believe we had custom encoders for
>> Tapestry to tell it how to identify Cayenne objects, especially when you
>> were iterating over them. We had a common Cayenne superclass for all of our
>> objects that implemented this to make it simpler and allow us to re-use a
>> generic encoder. I believe this identifier (t5id) was simply a dynamic UUID
>> we'd generate for every Cayenne object when needed. No need to persist it
>> and it didn't have to be the same ID across sessions as it was only for
>> Tapestry to identify objects when doing a submit.
>>
>> mrg
>>
>> [1] We learned the hard way that Tomcat has a default limit of 10k form
>> inputs because one of our users was reporting data wasn't saving at the
>> BOTTOM of the page, but was saving at the TOP. To make it worse, Tomcat
>> just silently ignores anything after 10k inputs -- no error/exception/etc.
>> Had to adjust Tomcat to accept an unlimited number of inputs to get their
>> data saving again.
>>
>>
>> On Wed, May 12, 2021 at 6:50 AM D Tim Cummings <ti...@triptera.com.au.invalid>
>> wrote:
>>
>>> Does anyone know of any good open-source Cayenne Tapestry apps that show
>>> best practice and latest features for using these two frameworks
>>> together? Most of the Tapestry examples use Hibernate.
>>>
>>> Tim
>>>
>>>
>>>
>>>
>>>



Re: Examples of Cayenne Tapestry apps

Posted by Michael Gentry <bl...@gmail.com>.
Hi Tim!

The Tapestry+Cayenne apps I worked on weren't open source, but the
combination worked amazingly well for us.

In the largest one, we had a small user base, but the object graph being
edited could be 100s or for a few, over 1000 records [1]. Because the
number of records could take a while to load in from the database and
because our validations had to traverse the entire object graph every time,
we chose to make the app session-based. Didn't have any issues with the
object graph being in session and Tapestry did a great job reading the data
from the Cayenne object graph to edit in the UI and pushing all the data
back to the Cayenne object graph on submit where we could re-validate.

Our save button was essentially dataContext.commitChanges(), with a
try/catch block around it to handle errors. This was a HUGE advantage over
having to micromanage each individual record like you'd do with
Hibernate/JPA -- plus no LazyInitializationExceptions ever.

My memory is a little fuzzy here, but I believe we had custom encoders for
Tapestry to tell it how to identify Cayenne objects, especially when you
were iterating over them. We had a common Cayenne superclass for all of our
objects that implemented this to make it simpler and allow us to re-use a
generic encoder. I believe this identifier (t5id) was simply a dynamic UUID
we'd generate for every Cayenne object when needed. No need to persist it
and it didn't have to be the same ID across sessions as it was only for
Tapestry to identify objects when doing a submit.

mrg

[1] We learned the hard way that Tomcat has a default limit of 10k form
inputs because one of our users was reporting data wasn't saving at the
BOTTOM of the page, but was saving at the TOP. To make it worse, Tomcat
just silently ignores anything after 10k inputs -- no error/exception/etc.
Had to adjust Tomcat to accept an unlimited number of inputs to get their
data saving again.


On Wed, May 12, 2021 at 6:50 AM D Tim Cummings <ti...@triptera.com.au.invalid>
wrote:

> Does anyone know of any good open-source Cayenne Tapestry apps that show
> best practice and latest features for using these two frameworks
> together? Most of the Tapestry examples use Hibernate.
>
> Tim
>
>
>
>

Re: Examples of Cayenne Tapestry apps

Posted by D Tim Cummings <ti...@triptera.com.au.INVALID>.
Forwarding to list.

On 13/5/21 17:03, Andrus Adamchik wrote:
> Ah sorry, missed this piece. I have the services declared in the
> Bootique module via provider methods, and there's also a "shared
> context supplier" service, that is a wrapper against ObjectContext
> singleton (appropriate for read-only work of course; writable contexts
> should not be shared). See below.
>
> Andrus
> ------
> @Provides @Singleton SharedContextSupplier provideCayenneContextSupplier(ServerRuntime runtime) {
>     return new DefaultSharedContextSupplier(runtime.newContext());
> }
> @Singleton @Provides private ObjectIdCoder provideIdCoder(IdCoder idCoder) {
>     return new ObjectIdCoder(idCoder);
> }
>
> @Singleton @Provides private PersistentCoder providePersistentCoder(IdCoder idCoder, SharedContextSupplier contextSupplier) {
>     return new PersistentCoder(idCoder, contextSupplier);
> }
>
> @Singleton @Provides private IdCoder provideIdCoder(ServerRuntime serverRuntime) {
>     return new IdCoder(serverRuntime.getDataDomain().getEntityResolver());
> }
> public interface SharedContextSupplier extends Supplier<ObjectContext> {
>     ObjectContext get();
> }
> public class DefaultSharedContextSupplier implements
> SharedContextSupplier {
>
>     private ObjectContext sharedContext;
>
>     public DefaultSharedContextSupplier(ObjectContext sharedContext) {
>         this.sharedContext = sharedContext;
>     }
>
>     @Override public ObjectContext get() {
>         return sharedContext;
>     }
> }
>
>
>
>> On May 13, 2021, at 9:56 AM, D Tim Cummings <tim@triptera.com.au
>> <ma...@triptera.com.au>> wrote:
>>
>> Thanks Andrus. I am trying to use encoders like you have done. I put
>> the method contributeValueEncoderSource in my AppModule.java.
>>
>> 1. Is Supplier from java.util.function.Supplier (re: your class
>> PersistentCoder)?
>>
>> 2. Do I need to add the following to bind in AppModule.java? (If not
>> I got 'No service implements the interface').
>>
>>   public static void bind(ServiceBinder binder) {
>>     // ...
>>     binder.bind(PersistentCoder.class, PersistentCoder.class);
>>     binder.bind(ObjectIdCoder.class, ObjectIdCoder.class);
>>     binder.bind(IdCoder.class, IdCoder.class);
>>     binder.bind(EntityResolver.class, EntityResolver.class);
>>   }
>>  
>> 3. I am now getting an error
>>
>> No service implements the interface java.util.function.Supplier
>>
>> Thanks
>> Tim
>>
>> On 12/5/21 21:57, Andrus Adamchik wrote:
>>>> On May 12, 2021, at 1:50 PM, D Tim Cummings wrote:
>>>>
>>>> Does anyone know of any good open-source Cayenne Tapestry apps that show
>>>> best practice and latest features for using these two frameworks
>>>> together? Most of the Tapestry examples use Hibernate.
>>>>
>>>> Tim
>>> Hi Tim,
>>>
>>> Not aware of any other than this ancient one [1] (I see your commits in there :)) . Also you probably know that Bootique supports Tapestry [2], and that's what we are on. As for the Tapestry part, we are using vanilla Tapestry functionality for the most part. Looking at my own (non-open source) Tapestry modules [3,4], the only Cayenne extension is encoders for Persistent and ObjectId [5], so that objects can be encoded/decoded to/from page URL parameters. So our entire integration can fit in an email message, and that's the beauty of it :)
>>>  
>>> Andrus
>>>
>>> -----
>>>
>>> [1] https://github.com/andrus/wowodc13
>>> [2] https://github.com/bootique/bootique-tapestry
>>> [3] Bootique config:
>>>
>>> TapestryModule.extend(binder).addTapestryModule(TapestryModule.class)
>>>     // this ensures that T5 JS/CSS only includes when the page or components explicitly import parts of
>>>     // the stack
>>>     .setSymbol(SymbolConstants.INCLUDE_CORE_STACK, "false")
>>>     // turn off Tapestry Bootstrap .. we don't have much choice in the matter of the root selection
>>>     // it has to be one of the standard T5 locations. "META-INF/asset" is the most neutral one..
>>>     .setSymbol(SymbolConstants.BOOTSTRAP_ROOT, "classpath:/META-INF/assets")
>>>     .setSymbol(SymbolConstants.OMIT_GENERATOR_META, "true");
>>>
>>> [4] Tapestry module loaded via Bootique:
>>>
>>> public class TapestryModule {
>>>
>>>     public void contributeValueEncoderSource(
>>>             MappedConfiguration<Class, ValueEncoderFactory> configuration,
>>>             PersistentCoder persistentCoder, 
>>>             ObjectIdCoder objectIdCoder) {
>>>
>>>         configuration.add(Persistent.class, c -> persistentCoder);
>>>         configuration.add(ObjectId.class, c -> objectIdCoder);
>>>     }
>>> }
>>>
>>> [5] ID coders 
>>>
>>> import org.apache.cayenne.ObjectId;
>>> import org.apache.cayenne.lifecycle.id.IdCoder;
>>> import org.apache.tapestry5.ValueEncoder;
>>>
>>> public class ObjectIdCoder implements ValueEncoder<ObjectId> {
>>>
>>>     private IdCoder idCoder;
>>>
>>>     public ObjectIdCoder(IdCoder idCoder) {
>>>         this.idCoder = idCoder;
>>>     }
>>>
>>>     @Override
>>>     public String toClient(ObjectId value) {
>>>         return idCoder.getStringId(value);
>>>     }
>>>
>>>     @Override
>>>     public ObjectId toValue(String clientValue) {
>>>         return idCoder.getObjectId(clientValue);
>>>     }
>>> }
>>>
>>> import org.apache.cayenne.Cayenne;
>>> import org.apache.cayenne.ObjectContext;
>>> import org.apache.cayenne.Persistent;
>>> import org.apache.cayenne.lifecycle.id.IdCoder;
>>> import org.apache.tapestry5.ValueEncoder;
>>>
>>> public class PersistentCoder implements ValueEncoder<Persistent> {
>>>
>>>     private IdCoder idCoder;
>>>     private Supplier<ObjectContext> contextSupplier;
>>>
>>>     public PersistentCoder(IdCoder idCoder, Supplier<ObjectContext> contextSupplier) {
>>>         this.idCoder = idCoder;
>>>         this.contextSupplier = contextSupplier;
>>>     }
>>>
>>>     @Override
>>>     public String toClient(Persistent value) {
>>>         return idCoder.getStringId(value);
>>>     }
>>>
>>>     @Override
>>>     public Persistent toValue(String clientValue) {
>>>
>>>         // TODO: should we be using ObjectIdQuery with caching?
>>>
>>>         return (Persistent) Cayenne.objectForPK(
>>>                 contextSupplier.get(),
>>>                 idCoder.getObjectId(clientValue));
>>>     }
>>> }
>>>
>>>
>>>
>>>
>>
>
-- 
Triptera Pty Ltd
D Tim Cummings
0418778422
tim@triptera.com.au

Re: Examples of Cayenne Tapestry apps

Posted by Andrus Adamchik <aa...@gmail.com>.
> 
> On May 12, 2021, at 1:50 PM, D Tim Cummings <ti...@triptera.com.au.INVALID> wrote:
> 
> Does anyone know of any good open-source Cayenne Tapestry apps that show
> best practice and latest features for using these two frameworks
> together? Most of the Tapestry examples use Hibernate.
> 
> Tim

Hi Tim,

Not aware of any other than this ancient one [1] (I see your commits in there :)) . Also you probably know that Bootique supports Tapestry [2], and that's what we are on. As for the Tapestry part, we are using vanilla Tapestry functionality for the most part. Looking at my own (non-open source) Tapestry modules [3,4], the only Cayenne extension is encoders for Persistent and ObjectId [5], so that objects can be encoded/decoded to/from page URL parameters. So our entire integration can fit in an email message, and that's the beauty of it :)
 
Andrus

-----

[1] https://github.com/andrus/wowodc13
[2] https://github.com/bootique/bootique-tapestry
[3] Bootique config:

TapestryModule.extend(binder).addTapestryModule(TapestryModule.class)
    // this ensures that T5 JS/CSS only includes when the page or components explicitly import parts of
    // the stack
    .setSymbol(SymbolConstants.INCLUDE_CORE_STACK, "false")
    // turn off Tapestry Bootstrap .. we don't have much choice in the matter of the root selection
    // it has to be one of the standard T5 locations. "META-INF/asset" is the most neutral one..
    .setSymbol(SymbolConstants.BOOTSTRAP_ROOT, "classpath:/META-INF/assets")
    .setSymbol(SymbolConstants.OMIT_GENERATOR_META, "true");

[4] Tapestry module loaded via Bootique:

public class TapestryModule {

    public void contributeValueEncoderSource(
            MappedConfiguration<Class, ValueEncoderFactory> configuration,
            PersistentCoder persistentCoder, 
            ObjectIdCoder objectIdCoder) {

        configuration.add(Persistent.class, c -> persistentCoder);
        configuration.add(ObjectId.class, c -> objectIdCoder);
    }
}

[5] ID coders 

import org.apache.cayenne.ObjectId;
import org.apache.cayenne.lifecycle.id.IdCoder;
import org.apache.tapestry5.ValueEncoder;

public class ObjectIdCoder implements ValueEncoder<ObjectId> {

    private IdCoder idCoder;

    public ObjectIdCoder(IdCoder idCoder) {
        this.idCoder = idCoder;
    }

    @Override
    public String toClient(ObjectId value) {
        return idCoder.getStringId(value);
    }

    @Override
    public ObjectId toValue(String clientValue) {
        return idCoder.getObjectId(clientValue);
    }
}

import org.apache.cayenne.Cayenne;
import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.lifecycle.id.IdCoder;
import org.apache.tapestry5.ValueEncoder;

public class PersistentCoder implements ValueEncoder<Persistent> {

    private IdCoder idCoder;
    private Supplier<ObjectContext> contextSupplier;

    public PersistentCoder(IdCoder idCoder, Supplier<ObjectContext> contextSupplier) {
        this.idCoder = idCoder;
        this.contextSupplier = contextSupplier;
    }

    @Override
    public String toClient(Persistent value) {
        return idCoder.getStringId(value);
    }

    @Override
    public Persistent toValue(String clientValue) {

        // TODO: should we be using ObjectIdQuery with caching?

        return (Persistent) Cayenne.objectForPK(
                contextSupplier.get(),
                idCoder.getObjectId(clientValue));
    }
}





Re: Examples of Cayenne Tapestry apps

Posted by Michael Gentry <bl...@gmail.com>.
Using Spring/Thymeleaf+JPA currently...really missing
Tapestry+Cayenne--much more elegant, IMO.


On Tue, Jun 8, 2021 at 11:32 PM Robert Zeigler <ro...@roxanemy.com>
wrote:

> I haven't really been involved in java for a long time (primarily python
> these days), but nice to see that someone else picked up what Kevin and I
> started ages ago. Odd thing is, I thought I had officially ported
> tapestry5-cayenne over to github a long while ago; I have a t5cayenne repo
> in my account... but it's empty. Might just have to look for an excuse to
> pick up java, Tapestry, Cayenne again.
>
> On Tue, Jun 8, 2021 at 10:01 AM Richard Frovarp <rf...@apache.org>
> wrote:
>
> > There is an integration library that was developed by a group of people
> > once upon a time. It was abandoned, but was Apache License 2. So I've
> > picked up a fork, and have it updated.
> >
> > https://code.google.com/archive/p/tapestry5-cayenne/
> >
> > https://github.com/NDSU-Information-Technology/tapestry5-cayenne
> >
> > I've released the artifacts to Maven Central using my namesspace over at
> > edu.ndsu. Works the same as the archived version, just updated some.
> > What I have up is for internal use, as I don't have the time to fully
> > bring our fork up to snuff with respect to documentation, etc at the
> > moment. But others are obviously free to use it.
> >
> > And you're looking for an example:
> >
> >
> >
> https://github.com/NDSU-Information-Technology/international-capstone-exchange
> >
> > That uses the integration service. Versions are kind of old, but the
> > idea is the same.
> >
> >
> > On 5/12/21 5:50 AM, D Tim Cummings wrote:
> > > Does anyone know of any good open-source Cayenne Tapestry apps that
> show
> > > best practice and latest features for using these two frameworks
> > > together? Most of the Tapestry examples use Hibernate.
> > >
> > > Tim
> > >
> > >
> > >
> >
>

Re: Examples of Cayenne Tapestry apps

Posted by Richard Frovarp <rf...@apache.org>.
That code is one of the main reasons we switched over to it. We have a 
lot of small web application at my institution to solve a variety of 
problems, and Tapestry, Cayenne, plus that integration library has been 
key to us getting a lot of work done.

I had found various copies of that code after Google Code shut down. 
Don't entirely remember where I pulled it from. What I've done is enough 
to ensure that it works for our internal use, and is at a set of 
coordinates that won't collide with anyone else. I'd certainly be happy 
to collaborate with your or anyone else on that code.

Richard

On 6/8/21 10:32 PM, Robert Zeigler wrote:
> I haven't really been involved in java for a long time (primarily python
> these days), but nice to see that someone else picked up what Kevin and I
> started ages ago. Odd thing is, I thought I had officially ported
> tapestry5-cayenne over to github a long while ago; I have a t5cayenne repo
> in my account... but it's empty. Might just have to look for an excuse to
> pick up java, Tapestry, Cayenne again.
> 
> On Tue, Jun 8, 2021 at 10:01 AM Richard Frovarp <rf...@apache.org> wrote:
> 
>> There is an integration library that was developed by a group of people
>> once upon a time. It was abandoned, but was Apache License 2. So I've
>> picked up a fork, and have it updated.
>>
>> https://code.google.com/archive/p/tapestry5-cayenne/
>>
>> https://github.com/NDSU-Information-Technology/tapestry5-cayenne
>>
>> I've released the artifacts to Maven Central using my namesspace over at
>> edu.ndsu. Works the same as the archived version, just updated some.
>> What I have up is for internal use, as I don't have the time to fully
>> bring our fork up to snuff with respect to documentation, etc at the
>> moment. But others are obviously free to use it.
>>
>> And you're looking for an example:
>>
>>
>> https://github.com/NDSU-Information-Technology/international-capstone-exchange
>>
>> That uses the integration service. Versions are kind of old, but the
>> idea is the same.
>>
>>
>> On 5/12/21 5:50 AM, D Tim Cummings wrote:
>>> Does anyone know of any good open-source Cayenne Tapestry apps that show
>>> best practice and latest features for using these two frameworks
>>> together? Most of the Tapestry examples use Hibernate.
>>>
>>> Tim
>>>
>>>
>>>
>>
> 


Re: Examples of Cayenne Tapestry apps

Posted by Robert Zeigler <ro...@roxanemy.com>.
I haven't really been involved in java for a long time (primarily python
these days), but nice to see that someone else picked up what Kevin and I
started ages ago. Odd thing is, I thought I had officially ported
tapestry5-cayenne over to github a long while ago; I have a t5cayenne repo
in my account... but it's empty. Might just have to look for an excuse to
pick up java, Tapestry, Cayenne again.

On Tue, Jun 8, 2021 at 10:01 AM Richard Frovarp <rf...@apache.org> wrote:

> There is an integration library that was developed by a group of people
> once upon a time. It was abandoned, but was Apache License 2. So I've
> picked up a fork, and have it updated.
>
> https://code.google.com/archive/p/tapestry5-cayenne/
>
> https://github.com/NDSU-Information-Technology/tapestry5-cayenne
>
> I've released the artifacts to Maven Central using my namesspace over at
> edu.ndsu. Works the same as the archived version, just updated some.
> What I have up is for internal use, as I don't have the time to fully
> bring our fork up to snuff with respect to documentation, etc at the
> moment. But others are obviously free to use it.
>
> And you're looking for an example:
>
>
> https://github.com/NDSU-Information-Technology/international-capstone-exchange
>
> That uses the integration service. Versions are kind of old, but the
> idea is the same.
>
>
> On 5/12/21 5:50 AM, D Tim Cummings wrote:
> > Does anyone know of any good open-source Cayenne Tapestry apps that show
> > best practice and latest features for using these two frameworks
> > together? Most of the Tapestry examples use Hibernate.
> >
> > Tim
> >
> >
> >
>

Re: Examples of Cayenne Tapestry apps

Posted by D Tim Cummings <ti...@triptera.com.au.INVALID>.
Thanks. I will check it out.

Tim

On 9/6/21 01:01, Richard Frovarp wrote:
> There is an integration library that was developed by a group of
> people once upon a time. It was abandoned, but was Apache License 2.
> So I've picked up a fork, and have it updated.
>
> https://code.google.com/archive/p/tapestry5-cayenne/
>
> https://github.com/NDSU-Information-Technology/tapestry5-cayenne
>
> I've released the artifacts to Maven Central using my namesspace over
> at edu.ndsu. Works the same as the archived version, just updated
> some. What I have up is for internal use, as I don't have the time to
> fully bring our fork up to snuff with respect to documentation, etc at
> the moment. But others are obviously free to use it.
>
> And you're looking for an example:
>
> https://github.com/NDSU-Information-Technology/international-capstone-exchange
>
>
> That uses the integration service. Versions are kind of old, but the
> idea is the same.
>
>
> On 5/12/21 5:50 AM, D Tim Cummings wrote:
>> Does anyone know of any good open-source Cayenne Tapestry apps that show
>> best practice and latest features for using these two frameworks
>> together? Most of the Tapestry examples use Hibernate.
>>
>> Tim
>>
>>
>>


Re: Examples of Cayenne Tapestry apps

Posted by Richard Frovarp <rf...@apache.org>.
There is an integration library that was developed by a group of people 
once upon a time. It was abandoned, but was Apache License 2. So I've 
picked up a fork, and have it updated.

https://code.google.com/archive/p/tapestry5-cayenne/

https://github.com/NDSU-Information-Technology/tapestry5-cayenne

I've released the artifacts to Maven Central using my namesspace over at 
edu.ndsu. Works the same as the archived version, just updated some. 
What I have up is for internal use, as I don't have the time to fully 
bring our fork up to snuff with respect to documentation, etc at the 
moment. But others are obviously free to use it.

And you're looking for an example:

https://github.com/NDSU-Information-Technology/international-capstone-exchange

That uses the integration service. Versions are kind of old, but the 
idea is the same.


On 5/12/21 5:50 AM, D Tim Cummings wrote:
> Does anyone know of any good open-source Cayenne Tapestry apps that show
> best practice and latest features for using these two frameworks
> together? Most of the Tapestry examples use Hibernate.
>
> Tim
>
>
>