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 071cf9ec88 CAUSEWAY-2485: fleshes out new action choices page
071cf9ec88 is described below
commit 071cf9ec88471f2a01c4aed5fa18b038d17bb257
Author: danhaywood <[email protected]>
AuthorDate: Sun May 14 17:10:14 2023 +0100
CAUSEWAY-2485: fleshes out new action choices page
---
.../HasAsciiDocDescription_description.java | 3 +-
.../{depargs/DemoItem.java => TvCharacter.java} | 11 +--
.../actions/progmodel/TvCharacterPopulator.java | 45 +++++++++++
.../progmodel/{depargs/Parity.java => TvShow.java} | 18 +++--
.../ActionChoicesMenu.java} | 24 +++---
...ionChoicesPage-dependentChoiceDescription.adoc} | 23 +-----
.../choices/ActionChoicesPage-description.adoc | 93 ++++++++++++++++++++++
...ionChoicesPage-multipleChoicesDescription.adoc} | 23 +-----
...nChoicesPage-parameterMatchingDescription.adoc} | 23 +-----
...ActionChoicesPage-singleChoiceDescription.adoc} | 23 +-----
.../ActionChoicesPage.java} | 57 +++++++------
.../ActionChoicesPage.layout.xml} | 53 ++++++------
.../ActionChoicesPage_selectTvCharacter.java | 54 +++++++++++++
.../ActionChoicesPage_selectTvCharacterByShow.java | 66 +++++++++++++++
.../ActionChoicesPage_selectTvCharacters.java | 55 +++++++++++++
...ActionChoicesPage_selectTvCharactersByShow.java | 75 +++++++++++++++++
...ctionChoicesPage_selectTvCharactersByShows.java | 71 +++++++++++++++++
.../progmodel/depargs/ActionDependentArgsMenu.java | 18 ++---
...oc => ActionDependentArgsPage-description.adoc} | 0
.../progmodel/depargs/ActionDependentArgsPage.java | 15 ++--
...yout.xml => ActionDependentArgsPage.layout.xml} | 51 ++++++------
...> ActionDependentArgsPage_useAutoComplete.java} | 42 ++++------
...ionDependentArgsPage_useAutoCompleteMulti.java} | 44 ++++------
...ava => ActionDependentArgsPage_useChoices.java} | 37 ++++-----
...> ActionDependentArgsPage_useChoicesMulti.java} | 53 +++++-------
...ava => ActionDependentArgsPage_useDefault.java} | 14 ++--
...ava => ActionDependentArgsPage_useDisable.java} | 4 +-
...e.java => ActionDependentArgsPage_useHide.java} | 4 +-
...=> ActionDependentArgsPage_useIndependent.java} | 20 ++---
.../notes.txt} | 48 +++--------
.../src/main/java/demoapp/dom/menubars.layout.xml | 1 +
31 files changed, 697 insertions(+), 371 deletions(-)
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/_infra/asciidocdesc/HasAsciiDocDescription_description.java
b/examples/demo/domain/src/main/java/demoapp/dom/_infra/asciidocdesc/HasAsciiDocDescription_description.java
index 5ffa6043d4..bc9b668e15 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/_infra/asciidocdesc/HasAsciiDocDescription_description.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/_infra/asciidocdesc/HasAsciiDocDescription_description.java
@@ -45,7 +45,6 @@ public class HasAsciiDocDescription_description {
return asciiDocReaderService.readFor(hasAsciiDocDescription,
"description");
}
- @Inject
- AsciiDocReaderService asciiDocReaderService;
+ @Inject AsciiDocReaderService asciiDocReaderService;
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/DemoItem.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvCharacter.java
similarity index 81%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/DemoItem.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvCharacter.java
index 7a6ed67c72..785ce74285 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/DemoItem.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvCharacter.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package demoapp.dom.domain.actions.progmodel.depargs;
+package demoapp.dom.domain.actions.progmodel;
import javax.inject.Named;
@@ -25,7 +25,6 @@ import org.apache.causeway.applib.annotation.Editing;
import org.apache.causeway.applib.annotation.Nature;
import org.apache.causeway.applib.annotation.ObjectSupport;
import org.apache.causeway.applib.annotation.Property;
-import org.apache.causeway.applib.annotation.PropertyLayout;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@@ -38,19 +37,17 @@ import lombok.Setter;
@NoArgsConstructor
@AllArgsConstructor(staticName="of")
@EqualsAndHashCode // required for the Dependent Arguments demo to work
properly
-public class DemoItem {
+public class TvCharacter {
@ObjectSupport public String title() {
- return String.format("DemoItem '%s' (%s)", getName(), getParity());
+ return getName();
}
@Property(editing = Editing.DISABLED)
- @PropertyLayout(describedAs="The name of this 'DemoItem'.")
@Getter @Setter private String name;
@Property(editing = Editing.DISABLED)
- @PropertyLayout(describedAs="The parity of this 'DemoItem'.")
- @Getter @Setter private Parity parity;
+ @Getter @Setter private TvShow tvShow;
@Override
public String toString() {
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvCharacterPopulator.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvCharacterPopulator.java
new file mode 100644
index 0000000000..fa1cf02d85
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvCharacterPopulator.java
@@ -0,0 +1,45 @@
+/*
+ * 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 agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package demoapp.dom.domain.actions.progmodel;
+
+import java.util.Set;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class TvCharacterPopulator {
+
+ public void populate(Set<TvCharacter> items) {
+ items.clear();
+ items.add(TvCharacter.of("Tom", TvShow.THE_GOOD_LIFE));
+ items.add(TvCharacter.of("Barbara", TvShow.THE_GOOD_LIFE));
+ items.add(TvCharacter.of("Jerry", TvShow.THE_GOOD_LIFE));
+ items.add(TvCharacter.of("Margo", TvShow.THE_GOOD_LIFE));
+ items.add(TvCharacter.of("Joey", TvShow.FRIENDS));
+ items.add(TvCharacter.of("Monica", TvShow.FRIENDS));
+ items.add(TvCharacter.of("Rachel", TvShow.FRIENDS));
+ items.add(TvCharacter.of("Phoebe", TvShow.FRIENDS));
+ items.add(TvCharacter.of("Chandler", TvShow.FRIENDS));
+ items.add(TvCharacter.of("Ross", TvShow.FRIENDS));
+ items.add(TvCharacter.of("Mary", TvShow.MMM));
+ items.add(TvCharacter.of("Mungo", TvShow.MMM));
+ items.add(TvCharacter.of("Midge", TvShow.MMM));
+ }
+}
+
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/Parity.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvShow.java
similarity index 74%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/Parity.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvShow.java
index 505e59f229..8118c44ab7 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/Parity.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/TvShow.java
@@ -16,16 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/
-package demoapp.dom.domain.actions.progmodel.depargs;
+package demoapp.dom.domain.actions.progmodel;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
import org.apache.causeway.applib.annotation.ObjectSupport;
-public enum Parity {
- EVEN,
- ODD;
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public enum TvShow {
+ THE_GOOD_LIFE("The Good Life"),
+ FRIENDS("Friends"),
+ MMM("Mary, Mungo and Midge");
+
+ private final String title;
+
@ObjectSupport public String title() {
- return name();
+ return title;
}
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesMenu.java
similarity index 71%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesMenu.java
index 89264bc211..243c7028d1 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesMenu.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package demoapp.dom.domain.actions.progmodel.depargs;
+package demoapp.dom.domain.actions.progmodel.choices;
import javax.annotation.Priority;
import javax.inject.Inject;
@@ -24,7 +24,6 @@ import javax.inject.Named;
import org.apache.causeway.applib.annotation.Action;
import org.apache.causeway.applib.annotation.ActionLayout;
-import org.apache.causeway.applib.annotation.DomainObjectLayout;
import org.apache.causeway.applib.annotation.DomainService;
import org.apache.causeway.applib.annotation.NatureOfService;
import org.apache.causeway.applib.annotation.PriorityPrecedence;
@@ -33,26 +32,23 @@ import
org.apache.causeway.applib.services.factory.FactoryService;
import lombok.RequiredArgsConstructor;
import lombok.val;
-@Named("demo.ActionDependentArgsMenu")
+import demoapp.dom.domain.actions.progmodel.TvCharacterPopulator;
+
+@Named("demo.ActionChoicesMenu")
@DomainService(nature=NatureOfService.VIEW)
@Priority(PriorityPrecedence.EARLY)
@RequiredArgsConstructor(onConstructor_ = { @Inject })
-public class ActionDependentArgsMenu {
+public class ActionChoicesMenu {
final FactoryService factoryService;
+ final TvCharacterPopulator tvCharacterPopulator;
@Action
@ActionLayout(cssClassFa="fa-bolt")
- public ActionDependentArgsPage dependentArgsActions(){
- val demo = factoryService.viewModel(new ActionDependentArgsPage());
-
- demo.getItems().clear();
- demo.getItems().add(DemoItem.of("first", Parity.ODD));
- demo.getItems().add(DemoItem.of("second", Parity.EVEN));
- demo.getItems().add(DemoItem.of("third", Parity.ODD));
- demo.getItems().add(DemoItem.of("last", Parity.EVEN));
-
- return demo;
+ public ActionChoicesPage choices(){
+ val page = factoryService.viewModel(new ActionChoicesPage());
+ tvCharacterPopulator.populate(page.getTvCharacters());
+ return page;
}
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc
similarity index 62%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc
index c43b0cecfe..c2d7267e72 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc
@@ -1,24 +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 [...]
-(since 1.18.0 and 2.0.0-M3)
+The actions in this section illustrate how to implement an action where the
choices of one parameter are dependent upon the value of an earlier parameter.
+The first is a single choice, associated to the parameter by *number*.
+The second is a multiple choice, associated to the parameter by *name*.
-Known issues
link:https://issues.apache.org/jira/browse/CAUSEWAY-2319[CAUSEWAY-2319]
-[source,java]
-----
-
-public void act(X param0, Y param1, ...) { // <.>
- ...
-}
-
-public List<Y> choices1Act(X param0) { // <.>
- return ...
-}
-
-----
-
-<.> Action with multiple parameters
-<.> Choices for param1 depend on the user specified param0.
-
-See the associated action demo
-link:${SOURCES_DEMO}/demoapp/dom/actions/depargs[sources].
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-description.adoc
new file mode 100644
index 0000000000..316dbdd5c4
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-description.adoc
@@ -0,0 +1,93 @@
+: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 [...]
+
+Before an action can be invoked, the end-user has to provide an argument for
each of its parameters.
+If the parameter is a value (String, number, date etc.) then they can just
enter the value in a field.
+But if the parameter is a reference type, then some other mechanism is
required.
+
+A "choices" supporting method provides a set of candidate arguments for the
parameter type, rendered in the UI as a drop-down list.
+The list of choices is expected to be small, and should (if possible) only
proffer candidates that would also pass any validation rules (otherwise it
would make for a frustrating user experience).
+
+There are several variations:
+
+* the parameter itself maybe either a scalar or a collection
+* the supporting "choices" method can be associated with the parameter by
number, or by name
+* the choices of one parameter can depend upon another.
+** The preceding N-1 parameters are supplied to the Nth "choices" supporting
method.
+** Or a single record-like structure can be defined and this can be passed
through to all supporting methods instead.
+
+As noted above, choices are _always_ required for reference types.
+It is also possible to specify choices for value types, though this is much
less commonly done.
+
+== How this demo works
+
+On the left hand side is a list of objects representing TV characters, also
indicating the TV show that they appeared in.
+Below is a list of selected characters, initially empty.
+
+In the middle are a set of actions, each of which can be used to select a TV
character or characters.
+These demonstrate the variations listed in the introduction above.
+
+In terms of code:
+
+* this action allows a single TV character to be selected.
+It matches the supporting "choices" method with the parameter by number.
++
+[source,java]
+.ActionChoicesPage_selectTvCharacter.java
+----
+include::ActionChoicesPage_selectTvCharacter.java[tags=class]
+----
+<.> defines the 0th-param
+<.> provides the choices for the 0-th parameter.
+The collection's element type must match that of the parameter.
+
+* this action is similar, but allows multiple TV characters to be selected.
+This time, it matches the supporting "choices" method with the parameter by
name.
++
+[source,java]
+.ActionChoicesPage_selectTvCharacters.java
+----
+include::ActionChoicesPage_selectTvCharacters.java[tags=class]
+----
+<.> provides the choices for the "tvCharacters" parameter
+
+* the next example demonstrates dependent arguments, so that the TV characters
are first filtered by the show that they appeared in.
++
+[source,java]
+.ActionChoicesPage_selectTvCharacterByShow.java
+----
+include::ActionChoicesPage_selectTvCharacterByShow.java[tags=class]
+----
+<.> this parameter is used to filter the TV characters
+<.> the choices method is matched by number ...
+<.> \... and has a subset of the parameters of the action itself ("N-1" of
them).
+
+* the next example is similar; dependent arguments but with a multiple
selection, and using names to match the choices method:
++
+[source,java]
+.ActionChoicesPage_selectTvCharactersByShows.java
+----
+include::ActionChoicesPage_selectTvCharactersByShows.java[tags=class]
+----
+<.> the choices method matches a parameter of the action by name ...
+<.> \... and accepts all the parameters defined in the action _up to_ (but not
including) the matched parameter.
+
+* the final example also demonstrates dependent arguments, but using a
"Parameters" record.
++
+[source,java]
+.ActionChoicesPage_selectTvCharactersByShow.java
+----
+include::ActionChoicesPage_selectTvCharactersByShow.java[tags=class]
+----
+<.> the set of parameters of the action ...
+<.> \... are also defined as fields of a `Parameters` type
+<.>
+<.> the framework will set the fields of Parameters object as appropriate
+
++
+In a small action like this, there is little to be gained by introducing a
"Parameters" record class.
+But if there were many parameters to the action and many supporting methods,
then introducing such a record class can significantly reduce the boilerplate.
++
+[TIP]
+====
+In this example the `Parameters` class uses lombok 'fluent" accessor, but
record classes can also be used for Java 14+.
+====
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc
similarity index 62%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc
index c43b0cecfe..ada51b0622 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc
@@ -1,24 +1,5 @@
: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 [...]
-(since 1.18.0 and 2.0.0-M3)
+The action above illustrates how to implement an action accepting multiple
choices for one of its parameters.
+It associates the choices to the parameter by *name* (`choicesTvCharacters`).
-Known issues
link:https://issues.apache.org/jira/browse/CAUSEWAY-2319[CAUSEWAY-2319]
-
-[source,java]
-----
-
-public void act(X param0, Y param1, ...) { // <.>
- ...
-}
-
-public List<Y> choices1Act(X param0) { // <.>
- return ...
-}
-
-----
-
-<.> Action with multiple parameters
-<.> Choices for param1 depend on the user specified param0.
-
-See the associated action demo
-link:${SOURCES_DEMO}/demoapp/dom/actions/depargs[sources].
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-parameterMatchingDescription.adoc
similarity index 62%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-parameterMatchingDescription.adoc
index c43b0cecfe..3db3a3c8d0 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-parameterMatchingDescription.adoc
@@ -1,24 +1,5 @@
: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 [...]
-(since 1.18.0 and 2.0.0-M3)
+The action in this section shows a variation on dependent arguments, using a
"record" structure to represent the set of parameters accepted by the action.
+With this coding convention it's idiomatic to associate the supporting method
by *name* rather than number.
-Known issues
link:https://issues.apache.org/jira/browse/CAUSEWAY-2319[CAUSEWAY-2319]
-
-[source,java]
-----
-
-public void act(X param0, Y param1, ...) { // <.>
- ...
-}
-
-public List<Y> choices1Act(X param0) { // <.>
- return ...
-}
-
-----
-
-<.> Action with multiple parameters
-<.> Choices for param1 depend on the user specified param0.
-
-See the associated action demo
-link:${SOURCES_DEMO}/demoapp/dom/actions/depargs[sources].
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-singleChoiceDescription.adoc
similarity index 62%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-singleChoiceDescription.adoc
index c43b0cecfe..d4099d2d01 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-singleChoiceDescription.adoc
@@ -1,24 +1,5 @@
: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 [...]
-(since 1.18.0 and 2.0.0-M3)
+The action above illustrates how to implement an action accepting a single
choice for one of its parameters.
+It associates the choices to the parameter by *number* (`choicesNAct`).
-Known issues
link:https://issues.apache.org/jira/browse/CAUSEWAY-2319[CAUSEWAY-2319]
-
-[source,java]
-----
-
-public void act(X param0, Y param1, ...) { // <.>
- ...
-}
-
-public List<Y> choices1Act(X param0) { // <.>
- return ...
-}
-
-----
-
-<.> Action with multiple parameters
-<.> Choices for param1 depend on the user specified param0.
-
-See the associated action demo
-link:${SOURCES_DEMO}/demoapp/dom/actions/depargs[sources].
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage.java
similarity index 60%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage.java
index a1070792c3..81b5516e63 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage.java
@@ -16,78 +16,83 @@
* specific language governing permissions and limitations
* under the License.
*/
-package demoapp.dom.domain.actions.progmodel.depargs;
+package demoapp.dom.domain.actions.progmodel.choices;
import java.util.LinkedHashSet;
import java.util.Set;
+import javax.inject.Inject;
import javax.inject.Named;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
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;
+import org.apache.causeway.applib.annotation.CollectionLayout;
import org.apache.causeway.applib.annotation.DomainObject;
import org.apache.causeway.applib.annotation.Editing;
import org.apache.causeway.applib.annotation.LabelPosition;
import org.apache.causeway.applib.annotation.Nature;
import org.apache.causeway.applib.annotation.ObjectSupport;
-import org.apache.causeway.applib.annotation.Optionality;
import org.apache.causeway.applib.annotation.Property;
import org.apache.causeway.applib.annotation.PropertyLayout;
import org.apache.causeway.applib.value.Markup;
+import org.apache.causeway.valuetypes.asciidoc.applib.value.AsciiDoc;
+
+import demoapp.dom._infra.resources.AsciiDocReaderService;
import lombok.Getter;
-import lombok.Setter;
import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
-@Named("demo.ActionDependentArgs")
+@Named("demo.ActionChoices")
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
-public class ActionDependentArgsPage implements HasAsciiDocDescription {
+public class ActionChoicesPage implements HasAsciiDocDescription {
@ObjectSupport public String title() {
- return "Action Dependent Arguments";
+ return "Action Choices";
}
- @Property(optionality = Optionality.OPTIONAL)
- @PropertyLayout(describedAs = "Default for first dialog paramater in
'Choices', 'Auto Complete' and 'Default'")
- @Getter @Setter
- private Parity dialogParityDefault = null;
@Property
- @PropertyLayout(describedAs = "Default for first dialog paramater in
'Hide' and 'Disable'")
- @Getter @Setter
- private boolean dialogCheckboxDefault = false;
-
+ @PropertyLayout(labelPosition=LabelPosition.NONE)
+ public AsciiDoc getSingleChoiceDescription() {
+ return asciiDocReaderService.readFor(this, "singleChoiceDescription");
+ }
@Property
@PropertyLayout(labelPosition=LabelPosition.NONE)
- public Markup getDependentText1() {
- return new Markup("Click one of above actions to see how dependent
arguments work. "
- + "Set defaults for the first dialog parameter here:");
+ public AsciiDoc getMultipleChoicesDescription() {
+ return asciiDocReaderService.readFor(this,
"multipleChoicesDescription");
}
-
@Property
@PropertyLayout(labelPosition=LabelPosition.NONE)
- public Markup getDependentText2() {
- return new Markup("Click one of above actions to see how dependent
arguments work. "
- + "Set defaults for the first dialog parameter here:");
+ public AsciiDoc getDependentChoiceDescription() {
+ return asciiDocReaderService.readFor(this,
"dependentChoiceDescription");
}
-
@Property
@PropertyLayout(labelPosition=LabelPosition.NONE)
- public Markup getIndependentText() {
- return new Markup("Click this action above to see independent
arguments do not clear "
- + "each other when changing.");
+ public AsciiDoc getParameterMatchingDescription() {
+ return asciiDocReaderService.readFor(this,
"parameterMatchingDescription");
}
+
@Collection
+ @CollectionLayout
@Getter
- private final Set<DemoItem> items = new LinkedHashSet<>();
+ private final Set<TvCharacter> tvCharacters = new LinkedHashSet<>();
+
+ @Collection
+ @CollectionLayout
+ @Getter
+ private final Set<TvCharacter> selectedTvCharacters = new
LinkedHashSet<>();
+
+ @Inject @XmlTransient AsciiDocReaderService asciiDocReaderService;
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs.layout.xml
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage.layout.xml
similarity index 63%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs.layout.xml
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage.layout.xml
index e5a90f7984..c64fbcd3dd 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs.layout.xml
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage.layout.xml
@@ -27,34 +27,31 @@
<bs3:col span="6">
<bs3:row>
<bs3:col span="12">
- <cpt:collection id="items"/>
- </bs3:col>
- </bs3:row>
- <bs3:row>
- <bs3:col span="12">
- <cpt:fieldSet name="Action Parameter Support"
id="actions-dep1">
-
- <cpt:action id="useChoices"/>
- <cpt:action id="useChoices2"/>
- <cpt:action id="useAutoComplete"/>
- <cpt:action id="useAutoComplete2"/>
- <cpt:action id="useDefault"/>
- <cpt:property id="dependentText1"/>
- <cpt:property id="dialogParityDefault" />
- </cpt:fieldSet>
-
- <cpt:fieldSet name="Action Parameter Support"
id="actions-dep2">
- <cpt:action id="useHide"/>
- <cpt:action id="useDisable"/>
- <cpt:property id="dependentText2"/>
- <cpt:property id="dialogCheckboxDefault" />
- </cpt:fieldSet>
-
- <cpt:fieldSet name="Action Parameter Support"
id="actions-indep">
- <cpt:action id="useIndependent"/>
- <cpt:property id="independentText"/>
- </cpt:fieldSet>
-
+ <bs3:row>
+ <bs3:col span="6">
+ <cpt:collection id="tvCharacters"/>
+ <cpt:collection id="selectedTvCharacters"/>
+ </bs3:col>
+ <bs3:col span="6">
+ <cpt:fieldSet name="Single Choice"
id="single-choices">
+ <cpt:action id="selectTvCharacter"/>
+ <cpt:property id="singleChoiceDescription"/>
+ </cpt:fieldSet>
+ <cpt:fieldSet name="Multiple Choices"
id="multi-choices">
+ <cpt:action id="selectTvCharacters"/>
+ <cpt:property id="multipleChoicesDescription"/>
+ </cpt:fieldSet>
+ <cpt:fieldSet name="Dependent Choice"
id="dependent-choice">
+ <cpt:action id="selectTvCharacterByShow"/>
+ <cpt:action id="selectTvCharactersByShows"/>
+ <cpt:property id="dependentChoiceDescription"/>
+ </cpt:fieldSet>
+ <cpt:fieldSet name="Parameter Matching"
id="parameter-matching">
+ <cpt:action id="selectTvCharactersByShow"/>
+ <cpt:property
id="parameterMatchingDescription"/>
+ </cpt:fieldSet>
+ </bs3:col>
+ </bs3:row>
</bs3:col>
</bs3:row>
<cpt:fieldSet name="Other" id="other"
unreferencedProperties="true"/>
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacter.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacter.java
new file mode 100644
index 0000000000..45852d51c4
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacter.java
@@ -0,0 +1,54 @@
+/*
+ * 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 agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package demoapp.dom.domain.actions.progmodel.choices;
+
+import java.util.Collection;
+
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.MemberSupport;
+import org.apache.causeway.applib.annotation.Optionality;
+import org.apache.causeway.applib.annotation.Parameter;
+import org.apache.causeway.applib.annotation.SemanticsOf;
+
+import lombok.RequiredArgsConstructor;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+
+//tag::class[]
+@Action(semantics = SemanticsOf.IDEMPOTENT)
+@RequiredArgsConstructor
+public class ActionChoicesPage_selectTvCharacter {
+
+ private final ActionChoicesPage page;
+
+ @MemberSupport public ActionChoicesPage act(
+ @Parameter(optionality = Optionality.MANDATORY)
+ final TvCharacter tvCharacter // <.>
+ ) {
+ page.getSelectedTvCharacters().clear();
+ page.getSelectedTvCharacters().add(tvCharacter);
+ return page;
+ }
+
+ @MemberSupport public Collection<TvCharacter> choices0Act() { // <.>
+ return page.getTvCharacters();
+ }
+}
+//end::class[]
+
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacterByShow.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacterByShow.java
new file mode 100644
index 0000000000..9899f09ef9
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacterByShow.java
@@ -0,0 +1,66 @@
+/*
+ * 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 agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package demoapp.dom.domain.actions.progmodel.choices;
+
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.MemberSupport;
+import org.apache.causeway.applib.annotation.Optionality;
+import org.apache.causeway.applib.annotation.Parameter;
+import org.apache.causeway.applib.annotation.SemanticsOf;
+
+import lombok.RequiredArgsConstructor;
+import lombok.Value;
+import lombok.experimental.Accessors;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
+//tag::class[]
+@Action(semantics = SemanticsOf.IDEMPOTENT)
+@RequiredArgsConstructor
+public class ActionChoicesPage_selectTvCharacterByShow {
+
+ private final ActionChoicesPage page;
+
+ @MemberSupport public ActionChoicesPage act(
+ @Parameter(optionality = Optionality.MANDATORY)
+ final TvShow tvShow, // <.>
+ @Parameter(optionality = Optionality.MANDATORY)
+ final TvCharacter tvCharacter
+ ) {
+ page.getSelectedTvCharacters().clear();
+ page.getSelectedTvCharacters().add(tvCharacter);
+ return page;
+ }
+
+ @MemberSupport public Collection<TvCharacter> choices1Act( // <.>
+ TvShow tvShow // <.>
+ ) {
+ return page.getTvCharacters()
+ .stream()
+ .filter(tvCharacter -> tvShow == null ||
+ tvShow == tvCharacter.getTvShow())
+ .collect(Collectors.toList());
+ }
+}
+//end::class[]
+
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacters.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacters.java
new file mode 100644
index 0000000000..84cffe0ce4
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacters.java
@@ -0,0 +1,55 @@
+/*
+ * 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 agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package demoapp.dom.domain.actions.progmodel.choices;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.MemberSupport;
+import org.apache.causeway.applib.annotation.Optionality;
+import org.apache.causeway.applib.annotation.Parameter;
+import org.apache.causeway.applib.annotation.SemanticsOf;
+
+import lombok.RequiredArgsConstructor;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+
+//tag::class[]
+@Action(semantics = SemanticsOf.IDEMPOTENT)
+@RequiredArgsConstructor
+public class ActionChoicesPage_selectTvCharacters {
+
+ private final ActionChoicesPage page;
+
+ @MemberSupport public ActionChoicesPage act(
+ @Parameter(optionality = Optionality.MANDATORY)
+ List<TvCharacter> tvCharacters //
<.>
+ ) {
+ page.getSelectedTvCharacters().clear();
+ page.getSelectedTvCharacters().addAll(tvCharacters);
+ return page;
+ }
+
+ @MemberSupport public Collection<TvCharacter> choicesTvCharacters() { //
<1>
+ return page.getTvCharacters();
+ }
+}
+//end::class[]
+
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShow.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShow.java
new file mode 100644
index 0000000000..e89cda4522
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShow.java
@@ -0,0 +1,75 @@
+/*
+ * 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 agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package demoapp.dom.domain.actions.progmodel.choices;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.MemberSupport;
+import org.apache.causeway.applib.annotation.Optionality;
+import org.apache.causeway.applib.annotation.Parameter;
+import org.apache.causeway.applib.annotation.SemanticsOf;
+import org.apache.causeway.applib.services.message.MessageService;
+
+import lombok.RequiredArgsConstructor;
+import lombok.Value;
+import lombok.val;
+import lombok.experimental.Accessors;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
+//tag::class[]
+@Action(semantics = SemanticsOf.SAFE)
+@RequiredArgsConstructor
+public class ActionChoicesPage_selectTvCharactersByShow {
+
+ private final ActionChoicesPage page;
+
+ @MemberSupport public ActionChoicesPage act(
+ @Parameter(optionality = Optionality.MANDATORY)
+ TvShow tvShow, // <.>
+ @Parameter(optionality = Optionality.MANDATORY)
+ List<TvCharacter> tvCharacters
+ ) {
+ page.getSelectedTvCharacters().clear();
+ page.getSelectedTvCharacters().addAll(tvCharacters);
+ return page;
+ }
+
+ @Value @Accessors(fluent = true)
+ static class Parameters { // <.>
+ TvShow tvShow;
+ List<TvCharacter> tvCharacters;
+ }
+
+ @MemberSupport public List<TvCharacter> choicesTvCharacters(
+ Parameters params // <2>
+ ) {
+ val tvShowSelected = params.tvShow(); // <.>
+ return page.getTvCharacters()
+ .stream()
+ .filter(tvCharacter -> tvShowSelected ==
tvCharacter.getTvShow())
+ .collect(Collectors.toList());
+ }
+}
+//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShows.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShows.java
new file mode 100644
index 0000000000..bbf15f37c4
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShows.java
@@ -0,0 +1,71 @@
+/*
+ * 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 agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package demoapp.dom.domain.actions.progmodel.choices;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.MemberSupport;
+import org.apache.causeway.applib.annotation.Optionality;
+import org.apache.causeway.applib.annotation.Parameter;
+import org.apache.causeway.applib.annotation.SemanticsOf;
+import org.apache.causeway.applib.services.message.MessageService;
+import org.apache.causeway.commons.internal.base._NullSafe;
+
+import lombok.RequiredArgsConstructor;
+import lombok.Value;
+import lombok.val;
+import lombok.experimental.Accessors;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
+//tag::class[]
+@Action(semantics = SemanticsOf.SAFE)
+@RequiredArgsConstructor
+public class ActionChoicesPage_selectTvCharactersByShows {
+
+ private final ActionChoicesPage page;
+
+ @MemberSupport public ActionChoicesPage act(
+ @Parameter(optionality = Optionality.MANDATORY)
+ List<TvShow> tvShows,
+ @Parameter(optionality = Optionality.MANDATORY)
+ List<TvCharacter> tvCharacters
+ ) {
+ page.getSelectedTvCharacters().clear();
+ page.getSelectedTvCharacters().addAll(tvCharacters);
+ return page;
+ }
+
+ @MemberSupport public List<TvCharacter> choicesTvCharacters( // <.>
+ List<TvShow> tvShows // <.>
+ ) {
+ return page.getTvCharacters()
+ .stream()
+ .filter(tvCharacter -> tvShows != null &&
+
tvShows.contains(tvCharacter.getTvShow()))
+ .collect(Collectors.toList());
+ }
+}
+//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
index 89264bc211..548e378b9d 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
@@ -24,12 +24,15 @@ import javax.inject.Named;
import org.apache.causeway.applib.annotation.Action;
import org.apache.causeway.applib.annotation.ActionLayout;
-import org.apache.causeway.applib.annotation.DomainObjectLayout;
import org.apache.causeway.applib.annotation.DomainService;
import org.apache.causeway.applib.annotation.NatureOfService;
import org.apache.causeway.applib.annotation.PriorityPrecedence;
import org.apache.causeway.applib.services.factory.FactoryService;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvCharacterPopulator;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
import lombok.RequiredArgsConstructor;
import lombok.val;
@@ -40,19 +43,14 @@ import lombok.val;
public class ActionDependentArgsMenu {
final FactoryService factoryService;
+ final TvCharacterPopulator tvCharacterPopulator;
@Action
@ActionLayout(cssClassFa="fa-bolt")
public ActionDependentArgsPage dependentArgsActions(){
- val demo = factoryService.viewModel(new ActionDependentArgsPage());
-
- demo.getItems().clear();
- demo.getItems().add(DemoItem.of("first", Parity.ODD));
- demo.getItems().add(DemoItem.of("second", Parity.EVEN));
- demo.getItems().add(DemoItem.of("third", Parity.ODD));
- demo.getItems().add(DemoItem.of("last", Parity.EVEN));
-
- return demo;
+ val page = factoryService.viewModel(new ActionDependentArgsPage());
+ tvCharacterPopulator.populate(page.getItems());
+ return page;
}
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
similarity index 100%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs-description.adoc
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
index a1070792c3..8c888bec30 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.causeway.applib.annotation.Collection;
+import org.apache.causeway.applib.annotation.CollectionLayout;
import org.apache.causeway.applib.annotation.DomainObject;
import org.apache.causeway.applib.annotation.Editing;
import org.apache.causeway.applib.annotation.LabelPosition;
@@ -38,6 +39,9 @@ import org.apache.causeway.applib.annotation.Property;
import org.apache.causeway.applib.annotation.PropertyLayout;
import org.apache.causeway.applib.value.Markup;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
import lombok.Getter;
import lombok.Setter;
@@ -55,14 +59,14 @@ public class ActionDependentArgsPage implements
HasAsciiDocDescription {
}
@Property(optionality = Optionality.OPTIONAL)
- @PropertyLayout(describedAs = "Default for first dialog paramater in
'Choices', 'Auto Complete' and 'Default'")
+ @PropertyLayout(describedAs = "Default for the first parameter'")
@Getter @Setter
- private Parity dialogParityDefault = null;
+ private TvShow firstParamDefault = null;
@Property
- @PropertyLayout(describedAs = "Default for first dialog paramater in
'Hide' and 'Disable'")
+ @PropertyLayout(describedAs = "Default for first first parameter")
@Getter @Setter
- private boolean dialogCheckboxDefault = false;
+ private boolean checkboxDefault = false;
@Property
@PropertyLayout(labelPosition=LabelPosition.NONE)
@@ -86,8 +90,9 @@ public class ActionDependentArgsPage implements
HasAsciiDocDescription {
}
@Collection
+ @CollectionLayout
@Getter
- private final Set<DemoItem> items = new LinkedHashSet<>();
+ private final Set<TvCharacter> items = new LinkedHashSet<>();
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs.layout.xml
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.layout.xml
similarity index 63%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs.layout.xml
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.layout.xml
index e5a90f7984..b7b7f85bc8 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs.layout.xml
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.layout.xml
@@ -27,34 +27,35 @@
<bs3:col span="6">
<bs3:row>
<bs3:col span="12">
- <cpt:collection id="items"/>
- </bs3:col>
- </bs3:row>
- <bs3:row>
- <bs3:col span="12">
- <cpt:fieldSet name="Action Parameter Support"
id="actions-dep1">
-
- <cpt:action id="useChoices"/>
- <cpt:action id="useChoices2"/>
- <cpt:action id="useAutoComplete"/>
- <cpt:action id="useAutoComplete2"/>
- <cpt:action id="useDefault"/>
- <cpt:property id="dependentText1"/>
- <cpt:property id="dialogParityDefault" />
- </cpt:fieldSet>
+ <bs3:row>
+ <bs3:col span="6">
+ <cpt:collection id="items"/>
+ </bs3:col>
+ <bs3:col span="6">
+ <cpt:fieldSet name="Action Parameter Support"
id="actions-dep1">
- <cpt:fieldSet name="Action Parameter Support"
id="actions-dep2">
- <cpt:action id="useHide"/>
- <cpt:action id="useDisable"/>
- <cpt:property id="dependentText2"/>
- <cpt:property id="dialogCheckboxDefault" />
- </cpt:fieldSet>
+ <cpt:action id="useChoices"/>
+ <cpt:action id="useChoicesMulti"/>
+ <cpt:action id="useAutoComplete"/>
+ <cpt:action id="useAutoCompleteMulti"/>
+ <cpt:action id="useDefault"/>
+ <cpt:property id="dependentText1"/>
+ <cpt:property id="firstParamDefault" />
+ </cpt:fieldSet>
- <cpt:fieldSet name="Action Parameter Support"
id="actions-indep">
- <cpt:action id="useIndependent"/>
- <cpt:property id="independentText"/>
- </cpt:fieldSet>
+ <cpt:fieldSet name="Action Parameter Support"
id="actions-dep2">
+ <cpt:action id="useHide"/>
+ <cpt:action id="useDisable"/>
+ <cpt:property id="dependentText2"/>
+ <cpt:property id="dialogCheckboxDefault" />
+ </cpt:fieldSet>
+ <cpt:fieldSet name="Action Parameter Support"
id="actions-indep">
+ <cpt:action id="useIndependent"/>
+ <cpt:property id="independentText"/>
+ </cpt:fieldSet>
+ </bs3:col>
+ </bs3:row>
</bs3:col>
</bs3:row>
<cpt:fieldSet name="Other" id="other"
unreferencedProperties="true"/>
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useAutoComplete.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useAutoComplete.java
similarity index 78%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useAutoComplete.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useAutoComplete.java
index 7a6b559353..4b534263dd 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useAutoComplete.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useAutoComplete.java
@@ -33,6 +33,9 @@ import org.apache.causeway.applib.annotation.PromptStyle;
import org.apache.causeway.applib.services.message.MessageService;
import org.apache.causeway.commons.internal.base._Strings;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.val;
@@ -41,7 +44,7 @@ import lombok.experimental.Accessors;
@ActionLayout(named="Auto Complete", promptStyle = PromptStyle.DIALOG_MODAL)
@Action
@RequiredArgsConstructor
-public class ActionDependentArgs_useAutoComplete {
+public class ActionDependentArgsPage_useAutoComplete {
@Inject MessageService messageService;
@@ -49,47 +52,34 @@ public class ActionDependentArgs_useAutoComplete {
@Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
static class Parameters {
- Parity parity;
- DemoItem item1;
+ TvShow tvShow;
+ TvCharacter item1;
}
@MemberSupport public ActionDependentArgsPage act(
-
- // PARAM 0
- @Parameter(optionality = Optionality.MANDATORY) final
- Parity parity,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY) final
- DemoItem item
-
- ) {
-
+ @Parameter(optionality = Optionality.MANDATORY) final TvShow tvShow,
+ @Parameter(optionality = Optionality.MANDATORY) final TvCharacter item
+ ) {
messageService.informUser(item.getName());
return holder;
}
- // -- PARAM 0 (Parity)
-
- @MemberSupport public Parity default0Act() {
- return holder.getDialogParityDefault();
+ @MemberSupport public TvShow default0Act() {
+ return holder.getFirstParamDefault();
}
-
- // -- PARAM 1 (DemoItem)
-
- @MemberSupport public DemoItem default1Act(final Parameters params) {
+ @MemberSupport public TvCharacter default1Act(final Parameters params) {
// fill in first that is possible based on the first param from the UI
dialog
- return params.parity()==null
+ return params.tvShow()==null
? null
: autoComplete1Act(params, "")
.stream().findFirst().orElse(null);
}
- @MemberSupport public Collection<DemoItem> autoComplete1Act(
+ @MemberSupport public Collection<TvCharacter> autoComplete1Act(
final Parameters params,
@MinLength(2) final String search) {
- val parity = params.parity(); // <-- the refining parameter from the
dialog above
+ val parity = params.tvShow(); // <-- the refining parameter from the
dialog above
if(parity == null) {
return holder.getItems()
@@ -100,7 +90,7 @@ public class ActionDependentArgs_useAutoComplete {
return holder.getItems()
.stream()
- .filter(item->parity == item.getParity())
+ .filter(item->parity == item.getTvShow())
.filter(item->_Strings.isNullOrEmpty(search)
? true
:
item.getName().toLowerCase().contains(search.toLowerCase()))
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useAutoComplete2.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useAutoCompleteMulti.java
similarity index 83%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useAutoComplete2.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useAutoCompleteMulti.java
index 674f4312ad..5303b24cdf 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useAutoComplete2.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useAutoCompleteMulti.java
@@ -36,6 +36,9 @@ import org.apache.causeway.commons.internal.base._NullSafe;
import org.apache.causeway.commons.internal.base._Strings;
import org.apache.causeway.commons.internal.collections._Lists;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.val;
@@ -46,7 +49,7 @@ import lombok.experimental.Accessors;
promptStyle = PromptStyle.DIALOG_MODAL)
@Action
@RequiredArgsConstructor
-public class ActionDependentArgs_useAutoComplete2 {
+public class ActionDependentArgsPage_useAutoCompleteMulti {
@Inject MessageService messageService;
@@ -54,46 +57,33 @@ public class ActionDependentArgs_useAutoComplete2 {
@Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
static class Parameters {
- List<Parity> parities;
- List<DemoItem> items;
+ List<TvShow> parities;
+ List<TvCharacter> items;
}
@MemberSupport public ActionDependentArgsPage act(
-
- // PARAM 0
- @Parameter(optionality = Optionality.MANDATORY) final
- List<Parity> parities,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY) final
- List<DemoItem> items
-
- ) {
-
+ @Parameter(optionality = Optionality.MANDATORY) final List<TvShow>
tvShows,
+ @Parameter(optionality = Optionality.MANDATORY) final
List<TvCharacter> items
+ ) {
_NullSafe.stream(items)
.forEach(item->messageService.informUser(item.getName()));
return holder;
}
- // -- PARAM 0 (Parities)
-
- @MemberSupport public List<Parity> defaultParities(final Parameters
params) {
- return _Lists.of(holder.getDialogParityDefault());
+ @MemberSupport public List<TvShow> defaultTvShows(final Parameters params)
{
+ return _Lists.of(holder.getFirstParamDefault());
}
-
- // -- PARAM 1 (DemoItem)
-
- @MemberSupport public List<DemoItem> defaultItems(final Parameters params)
{
+ @MemberSupport public List<TvCharacter> defaultItems(final Parameters
params) {
val paritiesFromDialog = params.parities(); // <-- the refining
parameter from the dialog above
if(_NullSafe.isEmpty(paritiesFromDialog)) {
return Collections.emptyList();
}
return autoCompleteItems(params, "");
}
-
- @MemberSupport public List<DemoItem> autoCompleteItems(
+ @MemberSupport public List<TvCharacter> autoCompleteItems(
final Parameters params,
- @MinLength(2) final String search) {
+ @MinLength(2) final String search
+ ) {
val paritiesFromDialog = params.parities(); // <-- the refining
parameter from the dialog above
@@ -102,13 +92,11 @@ public class ActionDependentArgs_useAutoComplete2 {
}
return holder.getItems()
.stream()
- .filter(item->paritiesFromDialog.contains(item.getParity()))
+ .filter(item->paritiesFromDialog.contains(item.getTvShow()))
.filter(item->_Strings.isNullOrEmpty(search)
? true
:
item.getName().toLowerCase().contains(search.toLowerCase()))
.collect(Collectors.toList());
}
-
-
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useChoices.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useChoices.java
similarity index 76%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useChoices.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useChoices.java
index c89f1d0a6c..0259e79bf5 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useChoices.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useChoices.java
@@ -32,6 +32,9 @@ import org.apache.causeway.applib.annotation.PromptStyle;
import org.apache.causeway.applib.annotation.SemanticsOf;
import org.apache.causeway.applib.services.message.MessageService;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.val;
@@ -40,7 +43,7 @@ import lombok.experimental.Accessors;
@ActionLayout(named="Choices", promptStyle = PromptStyle.DIALOG_MODAL)
@Action(semantics = SemanticsOf.SAFE)
@RequiredArgsConstructor
-public class ActionDependentArgs_useChoices {
+public class ActionDependentArgsPage_useChoices {
@Inject MessageService messageService;
@@ -48,51 +51,43 @@ public class ActionDependentArgs_useChoices {
@Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
static class Parameters {
- Parity parity;
- DemoItem item1;
+ TvShow tvShow;
+ TvCharacter item1;
}
@MemberSupport public ActionDependentArgsPage act(
-
- // PARAM 0
- @Parameter(optionality = Optionality.MANDATORY) final
- Parity parity,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY) final
- DemoItem item
-
- ) {
-
+ @Parameter(optionality = Optionality.MANDATORY) final TvShow tvShow,
+ @Parameter(optionality = Optionality.MANDATORY) final TvCharacter item
+ ) {
messageService.informUser(item.getName());
return holder;
}
// -- PARAM 0 (Parity)
- @MemberSupport public Parity default0Act() {
- return holder.getDialogParityDefault();
+ @MemberSupport public TvShow default0Act() {
+ return holder.getFirstParamDefault();
}
// -- PARAM 1 (DemoItem)
- @MemberSupport public DemoItem default1Act(final Parameters params) {
+ @MemberSupport public TvCharacter default1Act(final Parameters params) {
// fill in first that is possible based on the first param from the UI
dialog
- return params.parity()==null
+ return params.tvShow()==null
? null
: choices1Act(params).stream().findFirst().orElse(null);
}
- @MemberSupport public Collection<DemoItem> choices1Act(final Parameters
params) {
+ @MemberSupport public Collection<TvCharacter> choices1Act(final Parameters
params) {
- val parity = params.parity(); // <-- the refining parameter from the
dialog above
+ val parity = params.tvShow(); // <-- the refining parameter from the
dialog above
if(parity == null) {
return holder.getItems();
}
return holder.getItems()
.stream()
- .filter(item->parity == item.getParity())
+ .filter(item->parity == item.getTvShow())
.collect(Collectors.toList());
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useChoices2.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useChoicesMulti.java
similarity index 67%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useChoices2.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useChoicesMulti.java
index 8f5e9721e3..f227e0ffe6 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useChoices2.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useChoicesMulti.java
@@ -35,6 +35,9 @@ import
org.apache.causeway.applib.services.message.MessageService;
import org.apache.causeway.commons.internal.base._NullSafe;
import org.apache.causeway.commons.internal.collections._Lists;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.val;
@@ -45,7 +48,7 @@ import lombok.experimental.Accessors;
named="MultiChoices",
promptStyle = PromptStyle.DIALOG_MODAL)
@RequiredArgsConstructor
-public class ActionDependentArgs_useChoices2 {
+public class ActionDependentArgsPage_useChoicesMulti {
@Inject MessageService messageService;
@@ -53,54 +56,36 @@ public class ActionDependentArgs_useChoices2 {
@Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
static class Parameters {
- List<Parity> parities;
- List<DemoItem> items;
+ List<TvShow> tvShows;
+ List<TvCharacter> tvCharacters;
}
@MemberSupport public ActionDependentArgsPage act(
-
- // PARAM 0
- @Parameter(optionality = Optionality.MANDATORY)
- List<Parity> parities,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY)
- List<DemoItem> items
-
- ) {
-
- _NullSafe.stream(items)
- .forEach(item->messageService.informUser(item.getName()));
-
+ @Parameter(optionality = Optionality.MANDATORY) List<TvShow> tvShows,
+ @Parameter(optionality = Optionality.MANDATORY) List<TvCharacter>
tvCharacters
+ ) {
+ _NullSafe.stream(tvCharacters)
+ .forEach(item->messageService.informUser(item.getName()));
return holder;
}
- // -- PARAM 0 (Parities)
-
- @MemberSupport public List<Parity> defaultParities(Parameters params) {
- return _Lists.of(holder.getDialogParityDefault());
+ @MemberSupport public List<TvShow> defaultTvShows(Parameters params) {
+ return _Lists.of(holder.getFirstParamDefault());
}
- // -- PARAM 1 (DemoItem)
-
- @MemberSupport public List<DemoItem> defaultItems(Parameters params) {
-
- return choicesItems(params); // <-- fill in all that are possible
based on the first param from the UI dialog
+ @MemberSupport public List<TvCharacter> defaultTvCharacters(Parameters
params) {
+ return choicesTvCharacters(params); // <.> <.> fill in all
that are possible based on the first param from the UI dialog
}
- @MemberSupport public List<DemoItem> choicesItems(Parameters params) {
-
- val paritiesFromDialog = params.parities(); // <-- the refining
parameter from the dialog above
-
- if(_NullSafe.isEmpty(paritiesFromDialog)) {
+ @MemberSupport public List<TvCharacter> choicesTvCharacters(Parameters
params) {
+ val tvShowsSelected = params.tvShows(); // <.> <.> as selected in
first param
+ if(_NullSafe.isEmpty(tvShowsSelected)) {
return Collections.emptyList();
}
return holder.getItems()
.stream()
- .filter(item->paritiesFromDialog.contains(item.getParity()))
+ .filter(item->tvShowsSelected.contains(item.getTvShow()))
.collect(Collectors.toList());
}
-
-
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useDefault.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDefault.java
similarity index 88%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useDefault.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDefault.java
index f14a14a44d..ceccd6a2fc 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useDefault.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDefault.java
@@ -29,6 +29,8 @@ import org.apache.causeway.applib.annotation.ParameterLayout;
import org.apache.causeway.applib.annotation.PromptStyle;
import org.apache.causeway.applib.services.message.MessageService;
+import demoapp.dom.domain.actions.progmodel.TvShow;
+
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.val;
@@ -37,7 +39,7 @@ import lombok.experimental.Accessors;
@ActionLayout(named="Default", promptStyle = PromptStyle.DIALOG_MODAL)
@Action
@RequiredArgsConstructor
-public class ActionDependentArgs_useDefault {
+public class ActionDependentArgsPage_useDefault {
@Inject MessageService messageService;
@@ -45,7 +47,7 @@ public class ActionDependentArgs_useDefault {
@Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
static class Parameters {
- Parity parity;
+ TvShow tvShow;
String message;
}
@@ -53,7 +55,7 @@ public class ActionDependentArgs_useDefault {
// PARAM 0
@Parameter(optionality = Optionality.MANDATORY) final
- Parity parity,
+ TvShow tvShow,
// PARAM 1
@Parameter(optionality = Optionality.MANDATORY)
@@ -68,16 +70,16 @@ public class ActionDependentArgs_useDefault {
// -- PARAM 0 (Parity)
- @MemberSupport public Parity defaultParity(final Parameters params) {
+ @MemberSupport public TvShow defaultTvShow(final Parameters params) {
- return mixee.getDialogParityDefault();
+ return mixee.getFirstParamDefault();
}
// -- PARAM 1 (String message)
@MemberSupport public String defaultMessage(final Parameters params) {
- val parityFromDialog = params.parity(); // <-- the refining parameter
from the dialog above
+ val parityFromDialog = params.tvShow(); // <-- the refining parameter
from the dialog above
if(parityFromDialog == null) {
return "no parity selected";
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useDisable.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDisable.java
similarity index 96%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useDisable.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDisable.java
index 220243107a..cb7acde832 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useDisable.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDisable.java
@@ -36,7 +36,7 @@ import lombok.experimental.Accessors;
@ActionLayout(named="Disable", promptStyle = PromptStyle.DIALOG_MODAL)
@Action
@RequiredArgsConstructor
-public class ActionDependentArgs_useDisable {
+public class ActionDependentArgsPage_useDisable {
@Inject MessageService messageService;
@@ -68,7 +68,7 @@ public class ActionDependentArgs_useDisable {
// -- PARAM 0 (boolean disableMessageField)
@MemberSupport public boolean default0Act() {
- return holder.isDialogCheckboxDefault();
+ return holder.isCheckboxDefault();
}
// -- PARAM 1 (String message)
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useHide.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useHide.java
similarity index 96%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useHide.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useHide.java
index 0a8fd310cd..60eb6728fa 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useHide.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useHide.java
@@ -36,7 +36,7 @@ import lombok.experimental.Accessors;
@ActionLayout(named="Hide", promptStyle = PromptStyle.DIALOG_MODAL)
@Action
@RequiredArgsConstructor
-public class ActionDependentArgs_useHide {
+public class ActionDependentArgsPage_useHide {
@Inject MessageService messageService;
@@ -68,7 +68,7 @@ public class ActionDependentArgs_useHide {
// -- PARAM 0 (boolean hideMessageField)
@MemberSupport public boolean default0Act(final Parameters params) {
- return holder.isDialogCheckboxDefault();
+ return holder.isCheckboxDefault();
}
// -- PARAM 1 (String message)
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useIndependent.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useIndependent.java
similarity index 79%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useIndependent.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useIndependent.java
index 36bca6dd1b..ca772defb1 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_useIndependent.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useIndependent.java
@@ -30,13 +30,15 @@ import org.apache.causeway.applib.annotation.Parameter;
import org.apache.causeway.applib.annotation.PromptStyle;
import org.apache.causeway.applib.services.message.MessageService;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
import lombok.RequiredArgsConstructor;
import lombok.val;
@ActionLayout(named="Independent Args", promptStyle = PromptStyle.DIALOG_MODAL)
@Action
@RequiredArgsConstructor
-public class ActionDependentArgs_useIndependent {
+public class ActionDependentArgsPage_useIndependent {
@Inject MessageService messageService;
@@ -46,19 +48,19 @@ public class ActionDependentArgs_useIndependent {
// PARAM 0
@Parameter(optionality = Optionality.MANDATORY) final
- Parity parity,
+ TvShow tvShow,
// PARAM 1
@Parameter(optionality = Optionality.MANDATORY) final
- DemoItem item1,
+ TvCharacter item1,
// PARAM 2
@Parameter(optionality = Optionality.MANDATORY) final
- DemoItem item2
+ TvCharacter item2
) {
- val message = String.format("got %s %s %s", parity, item1.getParity(),
item2.getParity());
+ val message = String.format("got %s %s %s", tvShow, item1.getTvShow(),
item2.getTvShow());
messageService.informUser(message);
return holder;
@@ -66,19 +68,19 @@ public class ActionDependentArgs_useIndependent {
// -- PARAM 0 (Parity)
- @MemberSupport public Parity default0Act() {
- return holder.getDialogParityDefault();
+ @MemberSupport public TvShow default0Act() {
+ return holder.getFirstParamDefault();
}
// -- PARAM 1 (DemoItem item1)
- @MemberSupport public Collection<DemoItem> choices1Act() {
+ @MemberSupport public Collection<TvCharacter> choices1Act() {
return holder.getItems();
}
// -- PARAM 2 (DemoItem item2)
- @MemberSupport public Collection<DemoItem> choices2Act() {
+ @MemberSupport public Collection<TvCharacter> choices2Act() {
return holder.getItems();
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_bulkAction.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/paramstyles/notes.txt
similarity index 62%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_bulkAction.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/paramstyles/notes.txt
index afd1f285f7..dc43dfd80c 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgs_bulkAction.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/paramstyles/notes.txt
@@ -1,41 +1,13 @@
-/*
- * 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 agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package demoapp.dom.domain.actions.progmodel.depargs;
-
-import java.util.Collection;
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.apache.causeway.applib.annotation.Action;
-import org.apache.causeway.applib.annotation.ActionLayout;
-import org.apache.causeway.applib.annotation.MemberSupport;
-import org.apache.causeway.applib.annotation.Optionality;
-import org.apache.causeway.applib.annotation.Parameter;
-import org.apache.causeway.applib.annotation.PromptStyle;
-import org.apache.causeway.applib.services.message.MessageService;
-import org.apache.causeway.commons.internal.collections._Lists;
-import org.apache.causeway.commons.internal.debug._Probe;
-
-import lombok.RequiredArgsConstructor;
-import lombok.Value;
-import lombok.experimental.Accessors;
+Idea is that we could show the 3 different ways in which parameters can be
specified:
+
+- using a numbers
+- using by name.
+- using a `Parameters` class (see below)
+
+Show them all as both regular actions and as mixins.
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Action(choicesFrom = "items")
@ActionLayout(promptStyle = PromptStyle.DIALOG_MODAL)
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
index 08641abc7b..35f5346e81 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
+++ b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
@@ -89,6 +89,7 @@ For latest we use:
https://raw.githubusercontent.com/apache/causeway/master/anto
<mb3:serviceAction objectType="demo.BulkActionMenu"
id="bulkActions">
<cpt:named>Bulk Actions</cpt:named>
</mb3:serviceAction>
+ <mb3:serviceAction objectType="demo.ActionChoicesMenu"
id="choices"/>
<mb3:serviceAction objectType="demo.ActionDependentArgsMenu"
id="dependentArgsActions">
<cpt:named>Dependent Arguments</cpt:named>
</mb3:serviceAction>