2015-05-20 11:08 GMT+02:00 Lance Java <lance.j...@googlemail.com>:

> 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 (and should not) be
rendered when my export event is called. Persisting would also make no
sense because the html grid display only a part of the grid data source
(pagninated), while the export event intent to fetch the whole
GridDataSource.


> Therefore it's perfectly reasonable for the GridDataSource to be invoked
> once for the initial html render and again for the export.
>

Let split the problem into 2 different issues i've got :

1.
The field "@BindParameter GridDataSource source" trigger a build of the
GridDataSource object each time I use the field "source". A method
generated by Tapestry named "conduit_get_source" is called, which in turns
call the getter for the GridDataSource in the template, which in my code
creates a new GridDataSource. That's probably my bad, because the method
"getDataSource" is not a pure getter, but constructs a new instance each
time. Fixing that (with @Cached) resolve the issue of my initial post
(without using a custom CachingDataSource)

2.
The field "@InjectContainer Grid grid", by the same mecanism, was calling
the getDataSource method of my page, which constructed the GridDataSource.
The @Cached annotation fixed that too.

So everything works fine now.

Its still not possible to use the "GridDataSource source" field of the Grid
in this case, because this field is not visible from outside, except if the
field "org.apache.tapestry5.corelib.components.Grid#cachingSource" is set.
And to my understanding of the Grid source code, there is no way to
initialize the "cachingSource" field, except by the "setupRender" event on
the Grid.

Thank you for your answer, you had making me think more about my issue and
digging more further into it to find the root cause.

Reply via email to