You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2020/08/09 10:02:15 UTC
[isis] branch ISIS-2222 updated: ISIS-2222: updates docs for
@Action#associateWith
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-2222
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/ISIS-2222 by this push:
new 63d50c7 ISIS-2222: updates docs for @Action#associateWith
63d50c7 is described below
commit 63d50c73dab4acffcadf5016a46f272212371f17
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Sun Aug 9 11:02:00 2020 +0100
ISIS-2222: updates docs for @Action#associateWith
---
.../ActionAssociateWithVm-description.adoc | 71 +++++++++++++++++++---
.../associateWith/ActionAssociateWithVm.java | 55 +++++++++++------
.../child/ActionAssociateWithVm_makeFavorite.java | 2 +-
.../ActionAssociateWithVm_noLongerFavorite.java | 2 +-
.../ActionAssociateWithVm_noLongerFavorites.java | 2 +-
5 files changed, 103 insertions(+), 29 deletions(-)
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm-description.adoc
index 7cc601e..1c76203 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm-description.adoc
@@ -12,11 +12,11 @@ In the Wicket viewer, the collection is rendered with checkboxes; those selected
== Associated with Properties
-The `AssociateWithVm` defines two properties, `text` and `anotherProperty`:
+The `AssociateWithVm` class defines two properties, `text` and `anotherProperty`:
[source,java]
----
-include::ActionAssociateWithVm.java[tags=class]
+include::ActionAssociateWithVm.java[tags=class-properties]
----
The regular `updateText` action is associated with the `text` property:
@@ -40,37 +40,94 @@ include::ActionAssociateWithVm_updateOtherProperty.java[tags=class]
== Collection
+The `AssociateWithVm` class also defines the `children` collection:
+
[source,java]
----
-include::ActionAssociateWithVm.java[tags=children]
+include::ActionAssociateWithVm.java[tags=class-collections-children]
----
+There are three actions associated with this collection:
-[source,java]
+* the `addChild` action:
++
+[source,java,indent=0]
----
-include::child/ActionAssociateWithChildVm.java[tags=class]
+include::ActionAssociateWithVm.java[tags=action-associateWith-children-1]
----
+<.> associates with the "children" collection
+<.> positioned first in the UI
-[source,java]
+* the `removeChild` action.
++
+[source,java,indent=0]
----
-include::ActionAssociateWithVm.java[tags=action-associateWith-collection]
+include::ActionAssociateWithVm.java[tags=action-associateWith-children-2]
----
+<.> associates with the "children" collection
+<.> positioned second in the UI
+<.> because this action is associated with a collection, no supporting `choices()` or `autoComplete(...)` is required to provide the parameter.
+Instead, the elements in the collection are automatically used.
++
+TIP: an explicit `choices()` or `autoComplete(...)` supporting method can be provided to override the default usage of the collection elements if required.
+
+* the `removeChildren` action, which allows multiple children to be removed:
++
+[source,java,indent=0]
+----
+include::ActionAssociateWithVm.java[tags=action-associateWith-children-3]
+----
+<.> associates with the "children" collection
+<.> positioned third in the UI
+<.> again, no supporting `choices()` or `autoComplete(...)` method is required.
+Instead, the elements of the collection are used as options.
+Also, each row in the collection is rendered with a checkbox, and those selected are used as the default for the parameter.
== Mixin Actions
+The `AssociateWithVm` class also defines the `favorites` collection:
+
+[source,java]
+----
+include::ActionAssociateWithVm.java[tags=class-collections-favorites]
+----
+
+There are three mixin actions associated with this collection:
+
+* the `makeFavorite` action.
+This takes a element from the "children" collectio and also adds to the "favorites" collection:
++
[source,java]
----
include::child/ActionAssociateWithVm_makeFavorite.java[tags=class]
----
+<.> associates with the "favorites" collection
+<.> positioned first in the UI
+<.> choices are taken from the "children" collection
+* the `noLongerFavorite` action.
+This just removes a selected element from the "children" collection:
++
[source,java]
----
include::child/ActionAssociateWithVm_noLongerFavorite.java[tags=class]
----
+<.> associates with the "children" collection
+<.> positioned second in the UI
+<.> because this action is associated with a collection, no supporting `choices()` or `autoComplete(...)` is required to provide the parameter.
+Instead, the elements in the collection are automatically used.
+* the `noLongerFavorites` action.
+This is similar to the previous action, but for multiple favorite elements:
++
[source,java]
----
include::child/ActionAssociateWithVm_noLongerFavorites.java[tags=class]
----
+<.> associates with the "favorites" collection
+<.> positioned third in the UI
+<.> because this action is associated with a collection, no supporting `choices()` or `autoComplete(...)` is required to provide the parameter.
+Instead, the elements in the collection are automatically used.
+
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm.java
index 0d1cbb3..edca44e 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/ActionAssociateWithVm.java
@@ -58,10 +58,14 @@ import demoapp.dom.types.Samples;
objectType = "demo.ActionAssociateWithVm"
)
@NoArgsConstructor
-//tag::class[]
+//tag::class-properties[]
+//tag::class-collections-children[]
+//tag::class-collections-favorites[]
public class ActionAssociateWithVm implements HasAsciiDocDescription {
-//end::class[]
+//end::class-properties[]
+//end::class-collections-children[]
+//end::class-collections-favorites[]
public ActionAssociateWithVm(String text) {
this.text = text;
}
@@ -70,7 +74,7 @@ public class ActionAssociateWithVm implements HasAsciiDocDescription {
return "Action#associateWith";
}
-//tag::class[]
+//tag::class-properties[]
@Property()
@MemberOrder(name = "annotation", sequence = "1")
@XmlElement(required = true)
@@ -84,21 +88,25 @@ public class ActionAssociateWithVm implements HasAsciiDocDescription {
private String otherProperty;
// ...
-//end::class[]
+//end::class-properties[]
-//tag::children[]
+//tag::class-collections-children[]
@Collection()
@CollectionLayout()
@Getter
private List<ActionAssociateWithChildVm> children = new ArrayList<>();
-//end::children[]
-//tag::children-favorites[]
+ // ...
+//end::class-collections-children[]
+
+//tag::class-collections-favorites[]
@Collection()
@CollectionLayout()
@Getter
private List<ActionAssociateWithChildVm> favorites = new ArrayList<>();
-//end::children-favorites[]
+
+ // ...
+//end::class-collections-favorites[]
//tag::action-associateWith-property[]
@Action(
@@ -119,10 +127,11 @@ public class ActionAssociateWithVm implements HasAsciiDocDescription {
}
//end::action-associateWith-property[]
-//tag::action-associateWith-collection[]
+//tag::action-associateWith-children-1[]
@Action(
semantics = SemanticsOf.IDEMPOTENT
- , associateWith = "children", associateWithSequence = "1" // <.>
+ , associateWith = "children" // <.>
+ , associateWithSequence = "1" // <.>
)
@ActionLayout(
describedAs =
@@ -134,12 +143,13 @@ public class ActionAssociateWithVm implements HasAsciiDocDescription {
return this;
}
-//end::action-associateWith-collection[]
+//end::action-associateWith-children-1[]
-//tag::action-associateWith-collection[]
+//tag::action-associateWith-children-2[]
@Action(
semantics = SemanticsOf.IDEMPOTENT
- , associateWith = "children", associateWithSequence = "2" // <.>
+ , associateWith = "children" // <.>
+ , associateWithSequence = "2" // <.>
)
@ActionLayout(
describedAs =
@@ -149,12 +159,14 @@ public class ActionAssociateWithVm implements HasAsciiDocDescription {
getChildren().removeIf(x -> Objects.equals(x.getValue(), child.getValue()));
return this;
}
-//end::action-associateWith-collection[]
+ // no choices or autoComplete required // <.>
+//end::action-associateWith-children-2[]
-//tag::action-associateWith-collection[]
+//tag::action-associateWith-children-3[]
@Action(
semantics = SemanticsOf.IDEMPOTENT
- , associateWith = "children", associateWithSequence = "3" // <.>
+ , associateWith = "children" // <.>
+ , associateWithSequence = "3" // <.>
)
@ActionLayout(
describedAs =
@@ -167,8 +179,13 @@ public class ActionAssociateWithVm implements HasAsciiDocDescription {
}
return this;
}
-//end::action-associateWith-collection[]
-//tag::class[]
+ // no choices or autoComplete required // <.>
+//end::action-associateWith-children-3[]
+//tag::class-properties[]
+//tag::class-collections-children[]
+//tag::class-collections-favorites[]
}
-//end::class[]
+//end::class-properties[]
+//end::class-collections-children[]
+//end::class-collections-favorites[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_makeFavorite.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_makeFavorite.java
index 5ddc252..cbc6289 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_makeFavorite.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_makeFavorite.java
@@ -35,7 +35,7 @@ import demoapp.dom.annotDomain.Action.associateWith.ActionAssociateWithVm;
//tag::class[]
@Action(
associateWith = "favorites" // <.>
- , associateWithSequence = "1"
+ , associateWithSequence = "1" // <.>
)
@ActionLayout(
describedAs =
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorite.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorite.java
index a4dffbe..5947b67 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorite.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorite.java
@@ -36,7 +36,7 @@ import demoapp.dom.annotDomain.Action.associateWith.ActionAssociateWithVm;
//tag::class[]
@Action(
associateWith = "favorites" // <.>
- , associateWithSequence = "2"
+ , associateWithSequence = "2" // <.>
)
@ActionLayout(
describedAs =
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorites.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorites.java
index 2a74f92..5794802 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorites.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/associateWith/child/ActionAssociateWithVm_noLongerFavorites.java
@@ -32,7 +32,7 @@ import demoapp.dom.annotDomain.Action.associateWith.ActionAssociateWithVm;
//tag::class[]
@Action(
associateWith = "favorites" // <.>
- , associateWithSequence = "2"
+ , associateWithSequence = "3" // <.>
)
@ActionLayout(
describedAs =