This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch CAUSEWAY-2485
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit f874de4719d0ef9fda210290d23d094835233b67
Author: danhaywood <[email protected]>
AuthorDate: Sun Apr 30 16:42:46 2023 +0100

    CAUSEWAY-2485: fleshes out @CollectionLayout#named and #paged
---
 .../CollectionLayout/CollectionLayoutMenu.java     |  3 ++
 .../CollectionLayoutNamedPage-description.adoc     |  4 +-
 .../CollectionLayoutPagedPage-description.adoc     | 50 +++++++++++++++++++---
 .../paged/CollectionLayoutPagedPage.layout.xml     |  2 +-
 .../DomainObjectLayoutPagedPage-description.adoc   |  3 +-
 .../demo/domain/src/main/resources/application.yml |  2 +
 6 files changed, 55 insertions(+), 9 deletions(-)

diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/CollectionLayoutMenu.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/CollectionLayoutMenu.java
index 4a17e59968..a2f04bd434 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/CollectionLayoutMenu.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/CollectionLayoutMenu.java
@@ -140,6 +140,9 @@ public class CollectionLayoutMenu {
         samples.stream()
                 .map(CollectionLayoutPagedChildVm::new)
                 .forEach(e -> page.getChildren().add(e));
+        samples.stream()
+                .map(CollectionLayoutPagedChildVm::new)
+                .forEach(e -> page.getMoreChildren().add(e));
         return page;
     }
 
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/named/CollectionLayoutNamedPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/named/CollectionLayoutNamedPage-description.adoc
index c8b582ac6a..52676d1e14 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/named/CollectionLayoutNamedPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/named/CollectionLayoutNamedPage-description.adoc
@@ -13,7 +13,7 @@ This page object has two collections, and both has had their 
name explicitly spe
 
 In terms of code:
 
-* the `children` property has its name specified using the 
`@CollectionLayout#named()` annotation:
+* the `children` collection has its name specified using the 
`@CollectionLayout#named()` annotation:
 +
 [source,java,indent=0]
 ----
@@ -21,7 +21,7 @@ include::CollectionLayoutNamedPage.java[tags=children]
 ----
 <.> explicitly specifies the name of the collection
 
-* meanwhile, the `moreChildren` property has its name specified using the 
`Xxx.layout.xml` file:
+* meanwhile, the `moreChildren` collection has its name specified using the 
`Xxx.layout.xml` file:
 +
 [source,xml,indent=0,tabsize=4]
 ----
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage-description.adoc
index 531e92dc3c..3cb2e181cb 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage-description.adoc
@@ -1,9 +1,49 @@
 :Notice: Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE file distributed with this work 
for additional information regarding copyright ownership. The ASF licenses this 
file to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance with the License. You may obtain a copy of 
the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by 
applicable law or ag [...]
 
-The `paged` attribute ...
+If a collection contains many instances, then by default these are paged.
+The 
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObjectLayout.html#paged[@DomainObjectLayout#paged]
 is used to specify how many instances of the domain object should be shown for 
parented collections (those belonging to an object).
+This can be overridden on a case-by-case basis using 
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/CollectionLayout.html#paged[@CollectionLayout#paged].
 
-WARNING: TODO[CAUSEWAY-3311]
-The page size for instances of this class when rendered within a table.
-If annotated on a collection, then the page size refers to parented 
collections (eg Order#lineItems ).
-If annotated on a type, then the page size refers to standalone collections 
(eg as returned from a repository query).
+NOTE: the 
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObjectLayout.html#paged[@DomainObjectLayout#paged]
 value is also used for standalone collections (those returned from an action 
invocation).
+
+== How this demo works
+
+This page object has two collections, with each having a custom value of 
`paged` of 5.
+Accordingly, only 5 objects are shown per page.
+
+The first uses the annotation, the second uses `.layout.xml`
+In terms of code:
+
+* the `children` collection is annotated:
++
+[source,java,indent=0]
+----
+include::CollectionLayoutPagedPage.java[tags=children]
+----
+<.> explicitly indicates only 5 instances per page
+
+* meanwhile, the `moreChildren` collection uses the `Xxx.layout.xml` file:
++
+[source,xml,indent=0,tabsize=4]
+----
+<cpt:collection id="moreChildren" paged="5"/>
+----
++
+One advantage of the layout file over the annotation is that the layout file 
is dynamic: it can be modified and the changes reloaded in a running 
application.
+
+
+
+== Related configuration property
+
+To set the global default for `paged` of parented collections, use this 
configuration property:
+
+[source,yaml]
+.application.yaml
+----
+causeway:
+  applib:
+    annotation:
+      collection-layout:
+        paged: 15
+----
 
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage.layout.xml
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage.layout.xml
index d7450c3c78..913b2994ef 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage.layout.xml
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/paged/CollectionLayoutPagedPage.layout.xml
@@ -29,7 +29,7 @@
                        <bs3:row>
                                <bs3:col span="12">
                                        <cpt:collection id="children"/>
-                                       <cpt:collection id="moreChildren"/>
+                                       <cpt:collection id="moreChildren" 
paged="5"/>
                                </bs3:col>
                        </bs3:row>
                        <bs3:row>
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/paged/DomainObjectLayoutPagedPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/paged/DomainObjectLayoutPagedPage-description.adoc
index d2b3d48a7c..063c153d1a 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/paged/DomainObjectLayoutPagedPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/paged/DomainObjectLayoutPagedPage-description.adoc
@@ -1,6 +1,7 @@
 :Notice: Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE file distributed with this work 
for additional information regarding copyright ownership. The ASF licenses this 
file to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance with the License. You may obtain a copy of 
the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by 
applicable law or ag [...]
 
-The 
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObjectLayout.html#paged[@DomainObjectLayout#paged]
 is used to specify how many instances of the domain object should be shown, 
per page, in both parented collections (those belonging to an object) and 
standalone collections (those returned from an action invocation).
+If a collection contains many instances, then by default these are paged.
+The 
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObjectLayout.html#paged[@DomainObjectLayout#paged]
 is used to specify how many instances of the domain object should be shown for 
both parented collections (those belonging to an object) and standalone 
collections (those returned from an action invocation).
 
 NOTE: for parented collections, the `paged` value can be overridden on a 
case-by-case basis using 
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/CollectionLayout.html#paged[@CollectionLayout#paged].
 
diff --git a/examples/demo/domain/src/main/resources/application.yml 
b/examples/demo/domain/src/main/resources/application.yml
index 8878910ae7..e82e510d68 100644
--- a/examples/demo/domain/src/main/resources/application.yml
+++ b/examples/demo/domain/src/main/resources/application.yml
@@ -51,6 +51,8 @@ causeway:
         label-position: left
       parameter-layout:
         label-position: left
+      collection-layout:
+        paged: 15
 
   core:
     meta-model:

Reply via email to