Re: Grid mixin: grid datasource get instancied on each use

2015-05-20 Thread Thiago H de Paula Figueiredo
On Wed, 20 May 2015 10:11:34 -0300, Lance Java wrote: As you've discovered... Tapestry replaces field access with Binding.get() using plastic byte code magic. You can use a local variable to avoid multiple gets. Or annotate the getter with @Cached. :) Eg: @BindParameter private GridData

Re: Grid mixin: grid datasource get instancied on each use

2015-05-20 Thread Lance Java
As you've discovered... Tapestry replaces field access with Binding.get() using plastic byte code magic. You can use a local variable to avoid multiple gets. Eg: @BindParameter private GridDataSource source; ... GridDataSource sourceCopy = source; doStuff(sourceCopy); doMoreStuff(sourceCopy);

Re: Grid mixin: grid datasource get instancied on each use

2015-05-20 Thread Nicolas Bouillon
2015-05-20 11:08 GMT+02:00 Lance Java : > The initial render of the grid occurs on a different request to the > "export" event. Tapestry does not maintain state between requests (unless > you explicitly @Persist which i wouldn't recommend). > Of course, that is well understood. The grid is not (a

Re: Grid mixin: grid datasource get instancied on each use

2015-05-20 Thread Lance Java
The initial render of the grid occurs on a different request to the "export" event. Tapestry does not maintain state between requests (unless you explicitly @Persist which i wouldn't recommend). Therefore it's perfectly reasonable for the GridDataSource to be invoked once for the initial html rend

Re: Grid mixin: grid datasource get instancied on each use

2015-05-20 Thread Nicolas Bouillon
Following your advice, i've replicated the class CachingDataSource (from Grid class) inside my mixin, and created an instance of it using the BindParameter GridDataSource. @BindParameter private GridDataSource source; @OnEvent(value = EXPORT_EVENT) public StreamResponse export() { CachingDat

Re: Grid mixin: grid datasource get instancied on each use

2015-05-19 Thread Nicolas Bouillon
Thank you for your response. But grid.getDataSource() returns null. I guess it's because I'm in a event handler method (grid.getDataSource() is not null in the AfterRenderTemplate method). 2015-05-15 10:49 GMT+02:00 Lance Java : > I'm not entirely sure the problem but it's likely caused by @Bi

Re: Grid mixin: grid datasource get instancied on each use

2015-05-15 Thread Lance Java
I'm not entirely sure the problem but it's likely caused by @BindParameter which is likely invoking the binding each access. Try @InjectContainer Grid grid; And grid.getDataSource(). This will give you an instance of CachingDataSource which should have the lazy behaviour you want.

Grid mixin: grid datasource get instancied on each use

2015-05-11 Thread Nicolas Bouillon
Hi, I'm trying to write a export file mixin for the Grid component and I got a strange behavior on the GridDataSource value. My code is quite simple for now : public class Exportable { public static final String EXPORT_EVENT = "EXPORT"; @InjectContainer private Grid grid; @Bin