You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/03/14 06:41:57 UTC

[causeway] branch master updated: CAUSEWAY-3310: [Demo] Action Layout Annotation - flesh out associateWith and sequence

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

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/master by this push:
     new 69acc47b5f CAUSEWAY-3310: [Demo] Action Layout Annotation - flesh out associateWith and sequence
69acc47b5f is described below

commit 69acc47b5ffc1f26e504d09c7c4fa6e16596ee66
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Mar 14 07:41:52 2023 +0100

    CAUSEWAY-3310: [Demo] Action Layout Annotation - flesh out associateWith
    and sequence
---
 .../ActionLayoutAssociateWithVm-description.adoc    | 21 +++++++++++++++------
 .../associateWith/ActionLayoutAssociateWithVm.java  | 18 +++++++++++++++++-
 .../ActionLayoutSequenceVm-description.adoc         | 15 +++++++++++----
 .../sequence/ActionLayoutSequenceVm.java            | 21 +++++++++++++++++++--
 4 files changed, 62 insertions(+), 13 deletions(-)

diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm-description.adoc
index be75119844..1684d8ca96 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm-description.adoc
@@ -1,12 +1,21 @@
 :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 `associateWith` attribute ...
+The `associateWith` attribute associates an action with a property or collection, specifying its id.
 
-WARNING: TODO[CAUSEWAY-3310]
-Associates this action with a property or collection, specifying its id.
-To specify the layout order use ActionLayout#sequence() .
-For example @ActionLayout(associateWith="items") @ActionLayout(sequence="2.1")
-Note that it is also possible to associate an action with a collection using Action#choicesFrom() (which has the additional semantic of the rows of the element being used as choices for that action’s collection parameter of the same type as the elements of the collection).
+[source,java,indent=0]
+----
+include::ActionLayoutAssociateWithVm.java[tags=act_and_prop]
+----
 
+<.> associates this action `'act'` with property `'property'`
 
+To specify the layout order use `ActionLayout#sequence()`.
 
+.for example
+----
+@ActionLayout(associateWith="items") @ActionLayout(sequence="2.1")
+----
+
+Note that it is also possible to associate an action with a collection using `Action#choicesFrom`, 
+which has the additional semantic of the rows of the element being used as choices for that action’s collection parameter 
+of the same type as the elements of the collection.
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm.java
index 54a6cf4ff6..dd483d3b72 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/associateWith/ActionLayoutAssociateWithVm.java
@@ -21,6 +21,7 @@ package demoapp.dom.domain.actions.ActionLayout.associateWith;
 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,8 +30,11 @@ 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.Property;
 
 import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+import lombok.Getter;
+import lombok.Setter;
 
 //tag::class[]
 @DomainObject(
@@ -45,12 +49,24 @@ public class ActionLayoutAssociateWithVm implements HasAsciiDocDescription {
         return "ActionLayout#associateWith";
     }
 
+//tag::act_and_prop[]
     @Action
     @ActionLayout(
-            associateWith = "xxx")
+            associateWith = "property"  // <.>
+//end::act_and_prop[]
+            ,describedAs = "@ActionLayout(associateWith = \"property\")"
+//tag::act_and_prop[]
+            )
     public Object act(final String arg) {
         return this;
     }
 
+    @Property
+    @XmlElement
+    @Getter @Setter
+    private String property = "a property";
+//end::act_and_prop[]
+
+
 }
 //end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm-description.adoc
index 62b06d4cd2..3080960cd5 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm-description.adoc
@@ -1,7 +1,14 @@
 :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 `sequence` attribute ...
+The `sequence` attribute governs the order of this member relative to other members in the same (layout) group, 
+given in Dewey-decimal notation.
 
-WARNING: TODO[CAUSEWAY-3310]
-The order of this member relative to other members in the same (layout) group, given in Dewey-decimal notation.
-An alternative is to use the Xxx.layout.xml file, where Xxx is the domain object name.
+[source,java,indent=0]
+----
+include::ActionLayoutSequenceVm.java[tags=act1and2]
+----
+
+<.> applies dewey ordinal `'1.0'` and in effect renders this action before the other 
+<.> applies dewey ordinal `'2.0'` and in effect renders this action after the other
+
+An alternative is to use a `Xxx.layout.xml` file, where 'Xxx' is the domain object name.
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm.java
index c7d864c102..ebc42a1afe 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/ActionLayout/sequence/ActionLayoutSequenceVm.java
@@ -45,12 +45,29 @@ public class ActionLayoutSequenceVm implements HasAsciiDocDescription {
         return "ActionLayout#sequence";
     }
 
+//tag::act1and2[]
     @Action
     @ActionLayout(
-            sequence = "0")
-    public Object act(final String arg) {
+            sequence = "1.0" // <.>
+//end::act1and2[]
+            ,describedAs = "@ActionLayout(sequence = \"1.0\")"
+//tag::act1and2[]
+            )
+    public Object actFirst(final String arg) {
         return this;
     }
 
+    @Action
+    @ActionLayout(
+            sequence = "2.0" // <.>
+//end::act1and2[]
+            ,describedAs = "@ActionLayout(sequence = \"2.0\")"
+//tag::act1and2[]
+            )
+    public Object actSecond(final String arg) {
+        return this;
+    }
+//end::act1and2[]
+
 }
 //end::class[]