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 e3ac5361a99186701b903ce14528dbf7a5c8d159
Author: danhaywood <[email protected]>
AuthorDate: Sun Apr 30 11:07:16 2023 +0100

    CAUSEWAY-2485: fleshes out @CollectionLayout#defaultView
---
 .../CollectionLayout/CollectionLayoutMenu.java     | 13 ++++-
 .../CollectionLayoutCssClassPage-description.adoc  |  4 +-
 .../cssClass/CollectionLayoutCssClassPage.java     |  8 +--
 .../child/CollectionLayoutCssClassChildVm.java     |  2 +-
 ...ollectionLayoutDefaultViewPage-description.adoc | 60 ++++++++++++++++++++--
 .../CollectionLayoutDefaultViewPage.java           | 46 +++++++++++++----
 .../CollectionLayoutDefaultViewPage.layout.xml     | 11 ++++
 ...ctionLayoutDefaultViewChildVm-description.adoc} |  7 +--
 .../child/CollectionLayoutDefaultViewChildVm.java} | 10 ++--
 .../CollectionLayoutDefaultViewChildVm.layout.xml} | 15 ++++--
 10 files changed, 134 insertions(+), 42 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 8365219672..49ef4dd77b 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
@@ -33,6 +33,7 @@ import 
demoapp.dom.domain.collections.Collection.typeOf.child.CollectionTypeOfCh
 import 
demoapp.dom.domain.collections.CollectionLayout.cssClass.CollectionLayoutCssClassPage;
 import 
demoapp.dom.domain.collections.CollectionLayout.cssClass.child.CollectionLayoutCssClassChildVm;
 import 
demoapp.dom.domain.collections.CollectionLayout.defaultView.CollectionLayoutDefaultViewPage;
+import 
demoapp.dom.domain.collections.CollectionLayout.defaultView.child.CollectionLayoutDefaultViewChildVm;
 import 
demoapp.dom.domain.collections.CollectionLayout.describedAs.CollectionLayoutDescribedAsPage;
 import 
demoapp.dom.domain.collections.CollectionLayout.hidden.CollectionLayoutHiddenPage;
 import 
demoapp.dom.domain.collections.CollectionLayout.named.CollectionLayoutNamedPage;
@@ -75,7 +76,17 @@ public class CollectionLayoutMenu {
     @ActionLayout(cssClassFa="fa-atom",
         describedAs = "View collection as a table, or collapsed, or some other 
representation if available")
     public CollectionLayoutDefaultViewPage defaultView(){
-        return new CollectionLayoutDefaultViewPage();
+        CollectionLayoutDefaultViewPage page = new 
CollectionLayoutDefaultViewPage();
+        samples.stream()
+                .map(CollectionLayoutDefaultViewChildVm::new)
+                .forEach(e -> page.getChildren().add(e));
+        samples.stream()
+                .map(CollectionLayoutDefaultViewChildVm::new)
+                .forEach(e -> page.getMoreChildren().add(e));
+        samples.stream()
+                .map(CollectionLayoutDefaultViewChildVm::new)
+                .forEach(e -> page.getYetMoreChildren().add(e));
+        return page;
     }
 
     @Action(semantics = SemanticsOf.SAFE)
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage-description.adoc
index bd77bd4dd9..c1a889cafe 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage-description.adoc
@@ -9,8 +9,8 @@ The `application.css` file is then be used to apply styling to 
that CSS class.
 
 == How this demo works
 
-This page contains two properties.
-The `children` property uses `@CollectionLayout#cssClass` to specify a custom 
CSS class of "red", while the `childrenUsingLayout` collection specifies a 
custom CSS class using the `layout.xml` file.
+This page contains two collections.
+The `children` collection uses `@CollectionLayout#cssClass` to specify a 
custom CSS class of "red", while the `moreChildre` collection specifies a 
custom CSS class using the `layout.xml` file.
 
 In terms of code:
 
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage.java
index 2bef2eeab8..734a5e63fd 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/CollectionLayoutCssClassPage.java
@@ -27,7 +27,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.causeway.applib.annotation.Collection;
@@ -36,16 +35,11 @@ import org.apache.causeway.applib.annotation.DomainObject;
 import org.apache.causeway.applib.annotation.Nature;
 import org.apache.causeway.applib.annotation.ObjectSupport;
 
-import 
demoapp.dom.domain.collections.Collection.domainEvent.CollectionDomainEventPage;
-import 
demoapp.dom.domain.collections.Collection.domainEvent.child.CollectionDomainEventChildVm;
-
-import 
demoapp.dom.domain.collections.CollectionLayout.cssClass.child.CollectionLayoutCssClassChildVm;
-
 import lombok.Getter;
 import lombok.Setter;
 
 import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
-import demoapp.dom.domain._entities.DemoEntity;
+import 
demoapp.dom.domain.collections.CollectionLayout.cssClass.child.CollectionLayoutCssClassChildVm;
 
 //tag::class[]
 @Named("demo.CollectionLayoutCssClassPage")
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/child/CollectionLayoutCssClassChildVm.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/child/CollectionLayoutCssClassChildVm.java
index 3be73c137d..d643d04a20 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/child/CollectionLayoutCssClassChildVm.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/child/CollectionLayoutCssClassChildVm.java
@@ -37,10 +37,10 @@ import lombok.Setter;
 import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
 
 //tag::class[]
+@Named("demo.CollectionLayoutCssClassChildVm")
 @XmlRootElement(name = "demo.CollectionLayoutCssClassChildVm")
 @XmlType
 @XmlAccessorType(XmlAccessType.FIELD)
-@Named("demo.CollectionLayoutCssClassChildVm")
 @DomainObject(nature=Nature.VIEW_MODEL)
 @NoArgsConstructor
 public class CollectionLayoutCssClassChildVm implements HasAsciiDocDescription 
{
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage-description.adoc
index dcfac3a1b5..172d483a6e 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage-description.adoc
@@ -1,9 +1,59 @@
 :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 `defaultView` attribute ...
 
-WARNING: TODO[CAUSEWAY-3311]
-Indicates which view is used by default to render the collection.
-This is a simple string; every available implementation is required to use a 
different string.
-The default is "table". Extensions provide also: "excel" (download as Excel 
spreadsheet), "calendar" and "map".
+The `defaultView` attribute is used to specify how each collection should be 
initially be presented.
+
+There are two built-in views:
+
+* "table", which shows all collection in a table view (an "expanded" view, if 
you like), and
+* "hidden", which shows only the name of the collection (in a "collapsed view)"
+
+One reason to hide collections is if they are seldom used.
+Another is to improve the load speed of the page by reducing the amount of 
data to be retrieved.
+
+Extensions can provide alternative views:
+
+* "excel" (download as Excel spreadsheet)
+* "calendar" (requires the implementation of an interface to indicate the date)
+//* "map".
+
+Every view is identified by a simple string, all of which must be unique.
+
+The `defaultView` attribute can be specified using either the 
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/CollectionLayout.html#defaultView[@CollectionLayout#defaultView]
 annotation, or by using the 
link:https://causeway.apache.org/userguide/2.0.0-RC1/fun/ui.html#by-example[.layout.xml]
 layout file.
+
+If no `defaultView` is specified, then "table" is assumed.
+
+== How this demo works
+
+This page shows three collections, unimaginatively named `children`, 
`moreChildren` and `yetMoreChildren`.
+The first is shown using the normal "table" view, while the latter two use the 
"hidden" view; the last using the `.layout.xml` file to do so.
+
+In terms of code:
+
+* the `children` property is defined as:
++
+[source,java,indent=0]
+----
+include::CollectionLayoutDefaultViewPage.java[tags=children]
+----
+<.> explicitly specifies that the collection is shown expanded, as a table
+
+* the `moreChildren` property is defined as:
++
+[source,java,indent=0]
+----
+include::CollectionLayoutDefaultViewPage.java[tags=more-children]
+----
+<.> explicitly specifies that the collection is shown hidden/collapsed
+
+* the `yetMoreChildren` collection has no annotation but instead defines the 
`defaultView` attribute using `Xxx.layout.xml`:
++
+[source,xml,indent=0,tabsize=4]
+.CollectionLayoutDefaultViewPage.layout.xml
+----
+<cpt:collection id="yetMoreChildren" defaultView="hidden"/>
+----
+
+
+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.
 
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.java
index 87f20f6b19..934b881fda 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.java
@@ -24,8 +24,9 @@ import java.util.List;
 import javax.inject.Named;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.causeway.applib.annotation.Collection;
@@ -38,12 +39,11 @@ import lombok.Getter;
 import lombok.Setter;
 
 import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
-import demoapp.dom.domain._entities.DemoEntity;
+import 
demoapp.dom.domain.collections.CollectionLayout.defaultView.child.CollectionLayoutDefaultViewChildVm;
 
 //tag::class[]
-@DomainObject(
-        nature=Nature.VIEW_MODEL)
-@Named("demo.CollectionLayoutDefaultViewVm")
+@Named("demo.CollectionLayoutDefaultViewPage")
+@DomainObject(nature=Nature.VIEW_MODEL)
 @XmlRootElement(name = "root")
 @XmlType
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -53,14 +53,38 @@ public class CollectionLayoutDefaultViewPage implements 
HasAsciiDocDescription {
         return "@CollectionLayout#defaultView";
     }
 
-//tag::collection[]
-    @Collection
+//tag::children[]
+    @Collection()
     @CollectionLayout(
-        defaultView = "hidden")
-    @XmlTransient
+            defaultView = "table",          // <.>
+            paged = 5
+    )
+    @XmlElementWrapper(name = "children")
+    @XmlElement(name = "child")
     @Getter @Setter
-    private List<DemoEntity> collection = new ArrayList<>();
-//end::collection[]
+    private List<CollectionLayoutDefaultViewChildVm> children = new 
ArrayList<>();
+//end::children[]
+
+//tag::more-children[]
+    @Collection()
+    @CollectionLayout(
+            defaultView = "hidden",         // <.>
+            paged = 5
+    )
+    @XmlElementWrapper(name = "moreChildren")
+    @XmlElement(name = "child")
+    @Getter @Setter
+    private List<CollectionLayoutDefaultViewChildVm> moreChildren = new 
ArrayList<>();
+//end::more-children[]
+
+//tag::yet-more-children[]
+    @Collection()
+    @CollectionLayout(paged = 5)             // <.>
+    @XmlElementWrapper(name = "moreChildren")
+    @XmlElement(name = "child")
+    @Getter @Setter
+    private List<CollectionLayoutDefaultViewChildVm> yetMoreChildren = new 
ArrayList<>();
+//end::yet-more-children[]
 
 }
 //end::class[]
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.layout.xml
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.layout.xml
index 9e55f97df5..0c4ae75069 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.layout.xml
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.layout.xml
@@ -26,7 +26,18 @@
 
        <bs3:row>
                <bs3:col span="6">
+                       <bs3:row>
+                               <bs3:col span="12">
+                                       <cpt:collection id="children"/>
+                                       <cpt:collection id="moreChildren"/>
+                                       <cpt:collection id="yetMoreChildren" 
defaultView="hidden"/>
+                               </bs3:col>
+                       </bs3:row>
+                       <bs3:row>
+                               <bs3:col span="12">
                        <cpt:fieldSet name="Other" id="other" 
unreferencedProperties="true"/>
+               </bs3:col>
+                       </bs3:row>
                </bs3:col>
                <bs3:col span="6">
                        <cpt:fieldSet name="Description" id="description" >
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm-description.adoc
similarity index 69%
copy from 
examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage-description.adoc
copy to 
examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm-description.adoc
index dcfac3a1b5..f6ae770285 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm-description.adoc
@@ -1,9 +1,4 @@
 :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 `defaultView` attribute ...
-
-WARNING: TODO[CAUSEWAY-3311]
-Indicates which view is used by default to render the collection.
-This is a simple string; every available implementation is required to use a 
different string.
-The default is "table". Extensions provide also: "excel" (download as Excel 
spreadsheet), "calendar" and "map".
+This is a child object used in the demonstration of 
`CollectionLayout#defaultView()`.
 
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/child/CollectionLayoutCssClassChildVm.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm.java
similarity index 83%
copy from 
examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/child/CollectionLayoutCssClassChildVm.java
copy to 
examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm.java
index 3be73c137d..b5fda85929 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/cssClass/child/CollectionLayoutCssClassChildVm.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm.java
@@ -16,7 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package demoapp.dom.domain.collections.CollectionLayout.cssClass.child;
+package demoapp.dom.domain.collections.CollectionLayout.defaultView.child;
 
 import javax.inject.Named;
 import javax.xml.bind.annotation.XmlAccessType;
@@ -37,16 +37,16 @@ import lombok.Setter;
 import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
 
 //tag::class[]
-@XmlRootElement(name = "demo.CollectionLayoutCssClassChildVm")
+@Named("demo.CollectionLayoutDefaultViewChildVm")
+@XmlRootElement(name = "demo.CollectionLayoutDefaultViewChildVm")
 @XmlType
 @XmlAccessorType(XmlAccessType.FIELD)
-@Named("demo.CollectionLayoutCssClassChildVm")
 @DomainObject(nature=Nature.VIEW_MODEL)
 @NoArgsConstructor
-public class CollectionLayoutCssClassChildVm implements HasAsciiDocDescription 
{
+public class CollectionLayoutDefaultViewChildVm implements 
HasAsciiDocDescription {
 
 //end::class[]
-    public CollectionLayoutCssClassChildVm(final String value) {
+    public CollectionLayoutDefaultViewChildVm(final String value) {
         this.value = value;
     }
 
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.layout.xml
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm.layout.xml
similarity index 82%
copy from 
examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.layout.xml
copy to 
examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm.layout.xml
index 9e55f97df5..a5d295bce2 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/CollectionLayoutDefaultViewPage.layout.xml
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/CollectionLayout/defaultView/child/CollectionLayoutDefaultViewChildVm.layout.xml
@@ -26,7 +26,14 @@
 
        <bs3:row>
                <bs3:col span="6">
-                       <cpt:fieldSet name="Other" id="other" 
unreferencedProperties="true"/>
+                       <bs3:row>
+                               <bs3:col span="12">
+                                       <cpt:fieldSet name="Properties" 
id="properties">
+                                               <cpt:property id="value"/>
+                                       </cpt:fieldSet>
+                                       <cpt:fieldSet name="Other" id="other" 
unreferencedProperties="true"/>
+                               </bs3:col>
+                       </bs3:row>
                </bs3:col>
                <bs3:col span="6">
                        <cpt:fieldSet name="Description" id="description" >
@@ -36,9 +43,9 @@
                                <cpt:action id="inspectMetamodel"  
position="PANEL_DROPDOWN"/>
                                <cpt:action id="downloadMetamodelXml"  
position="PANEL_DROPDOWN"/>
                                <cpt:action id="downloadJdoMetamodel"  
position="PANEL_DROPDOWN"/>
-                               <cpt:action id="recentCommands"  
position="PANEL_DROPDOWN"/>
-                               <cpt:action id="recentExecutions"  
position="PANEL_DROPDOWN"/>
-                               <cpt:action id="recentAuditTrailEntries"  
position="PANEL_DROPDOWN"/>
+                <cpt:action id="recentCommands"  position="PANEL_DROPDOWN"/>
+                <cpt:action id="recentExecutions"  position="PANEL_DROPDOWN"/>
+                <cpt:action id="recentAuditTrailEntries"  
position="PANEL_DROPDOWN"/>
                                <cpt:action id="impersonateWithRoles"  
position="PANEL_DROPDOWN"/>
                                <cpt:action id="openRestApi" 
position="PANEL_DROPDOWN" />
                                <cpt:property id="description"/>

Reply via email to