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


The following commit(s) were added to refs/heads/CAUSEWAY-2485 by this push:
     new 2cceb83582 CAUSEWAY-2485: reworks @ActionLayout#fieldSet
2cceb83582 is described below

commit 2cceb83582472576a5bcc1d5af1ab469aca63b09
Author: danhaywood <[email protected]>
AuthorDate: Sun Apr 16 15:20:11 2023 +0100

    CAUSEWAY-2485: reworks @ActionLayout#fieldSet
---
 .../ActionLayoutDescribedAsPage-description.adoc   |  2 +-
 .../ActionLayoutFieldSetPage-description.adoc      | 61 ++++++++++++++++++---
 .../fieldSet/ActionLayoutFieldSetPage.java         | 62 ++++++++++++++++++++--
 .../fieldSet/ActionLayoutFieldSetPage.layout.xml   | 24 +++------
 4 files changed, 117 insertions(+), 32 deletions(-)

diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/describedAs/ActionLayoutDescribedAsPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/describedAs/ActionLayoutDescribedAsPage-description.adoc
index 65ca267ab2..603d6366d0 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/describedAs/ActionLayoutDescribedAsPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/describedAs/ActionLayoutDescribedAsPage-description.adoc
@@ -62,7 +62,7 @@ include::../ActionLayoutMenu.java[tags=menu-item-described-as]
 
 === .layout.xml
 
-Instead of using `@ActionLayout#describesAs`, it is also possible to specify a 
tooltip using the `<action id="..." describedAs="...">` in the 
link:https://causeway.apache.org/userguide/2.0.0-RC1/fun/ui.html#by-example[.layout.xml]
 file.
+Instead of using `@ActionLayout#describedAs`, it is also possible to specify a 
tooltip using the `<action id="..." describedAs="...">` in the 
link:https://causeway.apache.org/userguide/2.0.0-RC1/fun/ui.html#by-example[.layout.xml]
 file.
 
 One advantage of using the `.layout.xml` file is that changes can be picked up 
without having to restart the application.
 On the other hand, including descriptions can make that file rather large.
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage-description.adoc
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage-description.adoc
index 94820e91b0..05eae41108 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage-description.adoc
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage-description.adoc
@@ -1,13 +1,58 @@
 :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 `fieldSetId` attribute ...
 
-WARNING: TODO[CAUSEWAY-3310]
-Specifies the id of associated FieldSet .To associate an Action with a 
Collection , use Action#choicesFrom() instead.
-For a more in depth description see the analogous PropertyLayout#fieldSetId() .
+There are several annotations that influence the rendering of the various 
properties, collections and actions that make up a typical domain object:
+
+* if an actions is associated with a property (using 
`@ActionLayout#associateWith`), then it will be rendered close to that 
property; by default below the property.
+
+* if an action is associated with a collection (using either 
`@CollectionLayout#associateWith` or `@Collection#choicesFrom`), then again it 
will be rendered close to the collection (as part of the collection's table 
header).
+
+* alternatively, an action can merely be associated with a fieldset.
+This can be done either by 
link:https://causeway.apache.org/refguide/2.0.0-SNAPSHOT/applib/index/annotation/ActionLayout.html#fieldsetid[@ActionLayout#fieldSetId]
 (using the fieldset's id) and 
link:https://causeway.apache.org/refguide/2.0.0-SNAPSHOT/applib/index/annotation/ActionLayout.html#fieldsetname[@ActionLayout#fieldSetName]
 (using its name)
+
+As an alternative to using annotations, you might also use the 
link:https://causeway.apache.org/userguide/2.0.0-RC1/fun/ui.html#by-example[.layout.xml]
 file.
+One advantage of using the `.layout.xml` file is that changes can be picked up 
without having to restart the application.
+
+It's even possible to combine the two approaches.
+Some people use the `.layout.xml` file for the large-scale layout (rows, 
columns, fieldsets), and then use annotations to slot the properties, 
collections and actions into that larger-scale layout.
+
+
+=== How this demo works
+
+This page object has two properties, each of which is in its own fieldset.
+A `.layout.xml` file defines this:
+
+[source,xml]
+.layout.xml
+----
+...
+<cpt:fieldSet id="id" name="Identity">
+    <cpt:property id="name"/>
+</cpt:fieldSet>
+<cpt:fieldSet id="detail" name="Detail">
+    <cpt:property id="notes"/>
+</cpt:fieldSet>
+...
+----
+
+It also has two actions, associated with different fieldsets:
+
+* associated using the fieldset's `id`:
++
+[source,java,indent=0]
+----
+include::ActionLayoutFieldSetPage.java[tags=fieldsetId]
+----
+<.> maps to the fieldset using an `id`
+<.> positioned on the fieldset's panel (the default is to position in the 
panel's dropdown)
+
+* associated using the fieldset `name`:
++
+[source,java,indent=0]
+----
+include::ActionLayoutFieldSetPage.java[tags=fieldsetName]
+----
+<.> maps to the fieldset using its `name`
+<.> no position specified, so appears in the panel's dropdown.
 
-The `fieldSetName` attribute ...
 
-WARNING: TODO[CAUSEWAY-3310]
-Specifies the friendly-name of associated FieldSet or Collection .To associate 
an Action with a Collection , use Action#choicesFrom() instead.
-For a more in depth description see the analogous PropertyLayout#fieldSetId() ;
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.java
index e65522c61a..8f3758c744 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.java
@@ -21,6 +21,7 @@ package demoapp.dom.domain.actions.ActionLayout.fieldSet;
 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.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
@@ -29,29 +30,80 @@ import org.apache.causeway.applib.annotation.ActionLayout;
 import org.apache.causeway.applib.annotation.DomainObject;
 import org.apache.causeway.applib.annotation.Nature;
 import org.apache.causeway.applib.annotation.ObjectSupport;
+import org.apache.causeway.applib.annotation.ParameterLayout;
+import org.apache.causeway.applib.annotation.Property;
+import org.apache.causeway.applib.annotation.PropertyLayout;
+
+import org.springframework.data.repository.query.Param;
+
+import lombok.Getter;
+import lombok.Setter;
 
 import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
 
-//tag::class[]
 @DomainObject(
         nature=Nature.VIEW_MODEL)
 @Named("demo.ActionLayoutFieldSetVm")
 @XmlRootElement(name = "root")
 @XmlType
 @XmlAccessorType(XmlAccessType.FIELD)
-public class ActionLayoutFieldSetPage implements HasAsciiDocDescription {
+//tag::class[]
+//...
+public class ActionLayoutFieldSetPage
+//end::class[]
+        implements HasAsciiDocDescription
+//tag::class[]
+{
+    @Property()
+    @XmlElement
+    @Getter @Setter
+    private String name;
+
+    @Property()
+    @PropertyLayout(multiLine = 5)
+    @XmlElement
+    @Getter @Setter
+    private String notes;
+
+    // ...
+//end::class[]
 
     @ObjectSupport public String title() {
         return "@ActionLayout#fieldSet...";
     }
 
+//tag::fieldsetId[]
     @Action
     @ActionLayout(
-            fieldSetId = "xxx",
-            fieldSetName = "xxx")
-    public Object act(final String arg) {
+            fieldSetId = "id",                          // <.>
+            position = ActionLayout.Position.PANEL      // <.>
+    )
+    public Object updateName(final String newName) {
+        setName(newName);
         return this;
     }
+    public String default0UpdateName() {
+        return getName();
+    }
+//end::fieldsetId[]
+
+//tag::fieldsetName[]
+    @Action
+    @ActionLayout(
+            fieldSetName = "Detail"                     // <.>
+                                                        // <.>
+    )
+    public Object updateNotes(
+            @ParameterLayout(multiLine = 5)
+            final String newNotes) {
+        setNotes(newNotes);
+        return this;
+    }
+    public String default0UpdateNotes() {
+        return getNotes();
+    }
+//end::fieldsetName[]
 
+//tag::class[]
 }
 //end::class[]
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.layout.xml
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.layout.xml
index b7b4ab6651..1a241c1c85 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.layout.xml
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/fieldSet/ActionLayoutFieldSetPage.layout.xml
@@ -26,24 +26,12 @@
 
        <bs3:row>
                <bs3:col span="6">
-                       <cpt:fieldSet name="General" id="general"/>
-                       <cpt:fieldSet name="Annotated" id="annotated"/>
-                       <cpt:fieldSet name="Layout" id="layout">
-                               <cpt:action id="layoutPanel" position="PANEL">
-                                       <cpt:named>Positioned on 
panel</cpt:named>
-                               </cpt:action>
-                               <cpt:action id="layoutPanelDropDown" 
position="PANEL_DROPDOWN">
-                                       <cpt:named>Positioned on panel in drop 
down</cpt:named>
-                               </cpt:action>
-                               <cpt:property id="readOnlyProperty2">
-                                       <cpt:action id="layoutBelow" 
position="BELOW">
-                                               <cpt:named>Positioned 
below</cpt:named>
-                                       </cpt:action>
-                                       <cpt:action id="layoutRight" 
position="RIGHT">
-                                               <cpt:named>Positioned 
right</cpt:named>
-                                       </cpt:action>
-                               </cpt:property>
-                       </cpt:fieldSet>
+                       <cpt:fieldSet id="id" name="Identity">
+                <cpt:property id="name"/>
+            </cpt:fieldSet>
+                       <cpt:fieldSet id="detail" name="Detail">
+                <cpt:property id="notes"/>
+            </cpt:fieldSet>
                        <cpt:fieldSet name="Other" id="other" 
unreferencedProperties="true"/>
                </bs3:col>
                <bs3:col span="6">

Reply via email to