In the past I've used a url session state service I wrote in order to get
the Grids persisted data into the URL instead of the session. It works but
it's inconvenient because it difficult to change the persistence strategy
on just the Grid. I see in 5.4 the data needed to persist the Grid state
has been moved to an object. This still works fine I just needed to write
an encoder for GridPaginationModel. However it's still difficult to use
because the Grid is declared like this

**
217
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l217>
     * The pagination model for the Grid, which encapsulates current
page, sort column id,
218
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l218>
     * and sort ascending/descending. If not bound, a persistent
property of the Grid is used.
219
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l219>
     * When rendering the Grid in a loop, this should be bound in some
way to keep successive instances
220
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l220>
     * of the Grid configured individually.
221
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l221>
     *
222
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l222>
     * @since 5.4
223
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l223>
     */
224
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l224>
    @Parameter(value = "defaultPaginationModel")
225
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l225>
    private GridPaginationModel paginationModel;
226
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l226>
227
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l227>
    @Property
228
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l228>
    @Persist
229
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l229>
    private GridPaginationModel defaultPaginationModel;
230
<https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java;h=ecbd1598fc774aa178d15c7bde0682a7a4cfc322;hb=HEAD#l230>


Which means I can't just create a mixin something like this

@BindParamegter
private GridPaginationModel paginationModel;

@Property
@Persist("url")
private GridPaginationModel urlPaginationModel


void setupRender() {
if ( paginationModel == null ) {
paginationModel = urlPaginationModel;
}

}

because @BindParameter does not work if the components parameter has a
default value. The Grid is one of the few places where Tapestry creates a
session. It would be nice if this was easy to fix globally. Would it be
possible to remove the default value and set the default if needed in
setupRender? I think this would make it easier to globally replace the
persistence strategy for all Grids.

Thanks
Barry

Reply via email to