This is an automated email from the ASF dual-hosted git repository.
danhaywood 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 c338242fb6 CAUSEWAY-2485: fleshes out action veto page
c338242fb6 is described below
commit c338242fb6fbdee2255727170af1e6ac9783867f
Author: danhaywood <[email protected]>
AuthorDate: Mon May 15 23:43:42 2023 +0100
CAUSEWAY-2485: fleshes out action veto page
---
.../ActionDependentArgsPage_useDefault.java | 91 ----------------------
.../ActionDependentArgsPage_useDisable.java | 84 --------------------
.../depargs/ActionDependentArgsPage_useHide.java | 82 -------------------
.../ActionDependentArgsPage_useIndependent.java | 89 ---------------------
.../dom/domain/actions/progmodel/disable/notes.txt | 3 -
.../dom/domain/actions/progmodel/hide/notes.txt | 3 -
.../ActionVetoMenu.java} | 20 +++--
.../progmodel/veto/ActionVetoPage-description.adoc | 54 +++++++++++++
.../ActionVetoPage-disableActionDescription.adoc} | 22 +-----
.../ActionVetoPage-hideActionDescription.adoc} | 23 +-----
.../ActionVetoPage-vetoParamDescription.adoc} | 23 +-----
.../ActionVetoPage.java} | 58 +++++++-------
.../ActionVetoPage.layout.xml} | 33 ++++----
.../ActionVetoPage_selectTvCharactersBySex.java | 87 +++++++++++++++++++++
...onVetoPage_selectTvCharactersIfNotDisabled.java | 58 ++++++++++++++
...tionVetoPage_selectTvCharactersIfNotHidden.java | 58 ++++++++++++++
.../src/main/java/demoapp/dom/menubars.layout.xml | 10 +--
.../src/main/resources/static/css/application.css | 2 +-
18 files changed, 320 insertions(+), 480 deletions(-)
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDefault.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDefault.java
deleted file mode 100644
index ceccd6a2fc..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDefault.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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 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.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;
-import lombok.experimental.Accessors;
-
-@ActionLayout(named="Default", promptStyle = PromptStyle.DIALOG_MODAL)
-@Action
-@RequiredArgsConstructor
-public class ActionDependentArgsPage_useDefault {
-
- @Inject MessageService messageService;
-
- private final ActionDependentArgsPage mixee;
-
- @Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
- static class Parameters {
- TvShow tvShow;
- String message;
- }
-
- public ActionDependentArgsPage act(
-
- // PARAM 0
- @Parameter(optionality = Optionality.MANDATORY) final
- TvShow tvShow,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY)
- @ParameterLayout(named = "Message") final
- String message
-
- ) {
-
- messageService.informUser(message);
- return mixee;
- }
-
- // -- PARAM 0 (Parity)
-
- @MemberSupport public TvShow defaultTvShow(final Parameters params) {
-
- return mixee.getFirstParamDefault();
- }
-
- // -- PARAM 1 (String message)
-
- @MemberSupport public String defaultMessage(final Parameters params) {
-
- val parityFromDialog = params.tvShow(); // <-- the refining parameter
from the dialog above
-
- if(parityFromDialog == null) {
- return "no parity selected";
- }
- return parityFromDialog.name();
- }
-
-}
-
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDisable.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDisable.java
deleted file mode 100644
index cb7acde832..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useDisable.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 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.ParameterLayout;
-import org.apache.causeway.applib.annotation.PromptStyle;
-import org.apache.causeway.applib.services.message.MessageService;
-
-import lombok.RequiredArgsConstructor;
-import lombok.Value;
-import lombok.experimental.Accessors;
-
-@ActionLayout(named="Disable", promptStyle = PromptStyle.DIALOG_MODAL)
-@Action
-@RequiredArgsConstructor
-public class ActionDependentArgsPage_useDisable {
-
- @Inject MessageService messageService;
-
- private final ActionDependentArgsPage holder;
-
- @Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
- static class Parameters {
- boolean disableMessageField;
- String message;
- }
-
- @MemberSupport public ActionDependentArgsPage act(
-
- // PARAM 0
- @ParameterLayout(named = "Disable Message Field") final
- boolean disableMessageField,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY)
- @ParameterLayout(named = "Message") final
- String message
-
- ) {
-
- messageService.informUser(message);
- return holder;
- }
-
- // -- PARAM 0 (boolean disableMessageField)
-
- @MemberSupport public boolean default0Act() {
- return holder.isCheckboxDefault();
- }
-
- // -- PARAM 1 (String message)
-
- @MemberSupport public String disable1Act(final boolean
disableMessageField) {
- return disableMessageField
- ? "disabled by dependent argument"
- : null;
- }
-
-
-}
-
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useHide.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useHide.java
deleted file mode 100644
index 60eb6728fa..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useHide.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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 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.ParameterLayout;
-import org.apache.causeway.applib.annotation.PromptStyle;
-import org.apache.causeway.applib.services.message.MessageService;
-
-import lombok.RequiredArgsConstructor;
-import lombok.Value;
-import lombok.experimental.Accessors;
-
-@ActionLayout(named="Hide", promptStyle = PromptStyle.DIALOG_MODAL)
-@Action
-@RequiredArgsConstructor
-public class ActionDependentArgsPage_useHide {
-
- @Inject MessageService messageService;
-
- private final ActionDependentArgsPage holder;
-
- @Value @Accessors(fluent = true) // fluent so we can replace this with
Java(14+) records later
- static class Parameters {
- boolean hideMessageField;
- String message;
- }
-
- @MemberSupport public ActionDependentArgsPage act(
-
- // PARAM 0
- @ParameterLayout(named = "Hide Message Field") final
- boolean hideMessageField,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY)
- @ParameterLayout(named = "Message") final
- String message
-
- ) {
-
- messageService.informUser(message);
- return holder;
- }
-
- // -- PARAM 0 (boolean hideMessageField)
-
- @MemberSupport public boolean default0Act(final Parameters params) {
- return holder.isCheckboxDefault();
- }
-
- // -- PARAM 1 (String message)
-
- @MemberSupport public boolean hide1Act(final Parameters params) {
- return params.hideMessageField();
- }
-
-
-}
-
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useIndependent.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useIndependent.java
deleted file mode 100644
index ca772defb1..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage_useIndependent.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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 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 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 ActionDependentArgsPage_useIndependent {
-
- @Inject MessageService messageService;
-
- private final ActionDependentArgsPage holder;
-
- @MemberSupport public ActionDependentArgsPage act(
-
- // PARAM 0
- @Parameter(optionality = Optionality.MANDATORY) final
- TvShow tvShow,
-
- // PARAM 1
- @Parameter(optionality = Optionality.MANDATORY) final
- TvCharacter item1,
-
- // PARAM 2
- @Parameter(optionality = Optionality.MANDATORY) final
- TvCharacter item2
-
- ) {
-
- val message = String.format("got %s %s %s", tvShow, item1.getTvShow(),
item2.getTvShow());
-
- messageService.informUser(message);
- return holder;
- }
-
- // -- PARAM 0 (Parity)
-
- @MemberSupport public TvShow default0Act() {
- return holder.getFirstParamDefault();
- }
-
- // -- PARAM 1 (DemoItem item1)
-
- @MemberSupport public Collection<TvCharacter> choices1Act() {
- return holder.getItems();
- }
-
- // -- PARAM 2 (DemoItem item2)
-
- @MemberSupport public Collection<TvCharacter> choices2Act() {
- return holder.getItems();
- }
-
-
-}
-
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/disable/notes.txt
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/disable/notes.txt
deleted file mode 100644
index 953ec611dd..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/disable/notes.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-example of disabling, with depargs
-
-circle-stop
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/hide/notes.txt
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/hide/notes.txt
deleted file mode 100644
index ef8be9378e..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/hide/notes.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-example of hiding, with depargs
-
-eye-slash
\ No newline at end of file
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/veto/ActionVetoMenu.java
similarity index 78%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsMenu.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoMenu.java
index 548e378b9d..f405b8987f 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/veto/ActionVetoMenu.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.veto;
import javax.annotation.Priority;
import javax.inject.Inject;
@@ -29,27 +29,25 @@ 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;
-@Named("demo.ActionDependentArgsMenu")
+import demoapp.dom.domain.actions.progmodel.TvCharacterPopulator;
+
+@Named("demo.ActionVetoMenu")
@DomainService(nature=NatureOfService.VIEW)
@Priority(PriorityPrecedence.EARLY)
@RequiredArgsConstructor(onConstructor_ = { @Inject })
-public class ActionDependentArgsMenu {
+public class ActionVetoMenu {
final FactoryService factoryService;
final TvCharacterPopulator tvCharacterPopulator;
@Action
- @ActionLayout(cssClassFa="fa-bolt")
- public ActionDependentArgsPage dependentArgsActions(){
- val page = factoryService.viewModel(new ActionDependentArgsPage());
- tvCharacterPopulator.populate(page.getItems());
+ @ActionLayout(cssClassFa="fa-ban")
+ public ActionVetoPage veto(){
+ val page = factoryService.viewModel(new ActionVetoPage());
+ tvCharacterPopulator.populate(page.getTvCharacters());
return page;
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-description.adoc
new file mode 100644
index 0000000000..3681526a55
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-description.adoc
@@ -0,0 +1,54 @@
+: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 [...]
+
+Sometimes the state of an object means that certain of its actions should not
be called.
+For example, there's no point in placing an order if that order has already
been placed.
+
+There are two means by which access to an action can be prevented: either by
hiding it, or by disabling it.
+This is done using a "hide" or a "disable" supporting method, associated with
the _name_ of the action to which they relate.
+
+Hiding and disabling also applies to action parameters, to remove the ability
to enter parameters if they aren't required based on the value of earlier
parameters.
+ This is done using a "hide" or a "disable" supporting method, associated with
the _parameter_ to which they relate either by name, number or using a
"Parameters" object.
+
+== 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.
+The first and second act at the action level, using a checkbox property to
hide or disable their respective actions.
+
+The third demonstrates how individual parameters can be hidden or disabled.
+Until a value has been specified for the first parameter, the other two
parameters are disabled.
+Thereafter, one will become enabled while the other will be hidden.
+
+In terms of code:
+
+* the action that is hidden based on the checkbox is:
++
+[source,java]
+.ActionVetoPage_selectTvCharactersIfNotHidden.java
+----
+include::ActionVetoPage_selectTvCharactersIfNotHidden.java[tags=class]
+----
+<.> causes the action to be hidden from view if the page's property is set.
+
+* the second action is similar, but is disabled rather than hidden:
++
+[source,java]
+.ActionVetoPage_selectTvCharactersIfNotDisabled.java
+----
+include::ActionVetoPage_selectTvCharactersIfNotDisabled.java[tags=class]
+----
+<.> causes the action to be disabled if the page's property is set.
+
+* the final example uses a "Parameters" record to hide or disable parameters
++
+[source,java]
+.ActionVetoPage_selectTvCharactersBySex.java
+----
+include::ActionVetoPage_selectTvCharactersBySex.java[tags=class]
+----
+<.> defines a "Parameters" object in line with the parameters of the action
itself
+<.> both the "maleTvCharacters" and "femaleTvCharacters" are initially
disabled until an argument has been set for the "sex" parameter
+<.> if "sex" is set to male, then only the "maleTvCharacters" parameter is
shown; and vice versa for female.
+
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-disableActionDescription.adoc
similarity index 62%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-disableActionDescription.adoc
index c43b0cecfe..a57abb8731 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-disableActionDescription.adoc
@@ -1,24 +1,4 @@
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with this work
for additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by
applicable law or ag [...]
-(since 1.18.0 and 2.0.0-M3)
+The enablement of the action can be controlled using the checkbox property
below.
-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-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-hideActionDescription.adoc
similarity index 62%
copy from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
copy to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-hideActionDescription.adoc
index c43b0cecfe..7a03f3965f 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-hideActionDescription.adoc
@@ -1,24 +1,3 @@
: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)
-
-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].
+The visibility of the action can be controlled using the checkbox property
below.
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-vetoParamDescription.adoc
similarity index 62%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-vetoParamDescription.adoc
index c43b0cecfe..ed219c32a5 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage-vetoParamDescription.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)
+This action demonstrates how individual parameters can be hidden or disabled.
-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].
+WARNING: There is a slight UI glitch when parameter field becomes editable;
tracked with https://issues.apache.org/jira/browse/CAUSEWAY-3463[CAUSEWAY-3463].
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/veto/ActionVetoPage.java
similarity index 66%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage.java
index 8c888bec30..f90d34294b 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/veto/ActionVetoPage.java
@@ -16,15 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
-package demoapp.dom.domain.actions.progmodel.depargs;
+package demoapp.dom.domain.actions.progmodel.veto;
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;
@@ -37,62 +39,64 @@ 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 demoapp.dom.domain.actions.progmodel.TvCharacter;
-import demoapp.dom.domain.actions.progmodel.TvShow;
+import org.apache.causeway.valuetypes.asciidoc.applib.value.AsciiDoc;
import lombok.Getter;
import lombok.Setter;
import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+import demoapp.dom._infra.resources.AsciiDocReaderService;
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+import demoapp.dom.domain.actions.progmodel.TvShow;
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
-@Named("demo.ActionDependentArgs")
+@Named("demo.ActionVeto")
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
-public class ActionDependentArgsPage implements HasAsciiDocDescription {
+public class ActionVetoPage implements HasAsciiDocDescription {
@ObjectSupport public String title() {
- return "Action Dependent Arguments";
+ return "Action Veto (hide and disable)";
}
- @Property(optionality = Optionality.OPTIONAL)
- @PropertyLayout(describedAs = "Default for the first parameter'")
- @Getter @Setter
- private TvShow firstParamDefault = null;
-
- @Property
- @PropertyLayout(describedAs = "Default for first first parameter")
- @Getter @Setter
- private boolean checkboxDefault = false;
@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 getHideActionDescription() {
+ return asciiDocReaderService.readFor(this, "hideActionDescription");
}
+ @Property(editing = Editing.ENABLED)
+ @Getter @Setter
+ private boolean actionHidden;
@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 getDisableActionDescription() {
+ return asciiDocReaderService.readFor(this, "disableActionDescription");
}
+ @Property(editing = Editing.ENABLED)
+ @Getter @Setter
+ private boolean actionDisabled;
@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 getVetoParamDescription() {
+ return asciiDocReaderService.readFor(this, "vetoParamDescription");
}
+
+ @Collection
+ @CollectionLayout
+ @Getter
+ private final Set<TvCharacter> tvCharacters = new LinkedHashSet<>();
+
@Collection
@CollectionLayout
@Getter
- private final Set<TvCharacter> items = new LinkedHashSet<>();
+ 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/ActionDependentArgsPage.layout.xml
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage.layout.xml
similarity index 71%
rename from
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.layout.xml
rename to
examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage.layout.xml
index b7b7f85bc8..14edfd7ba3 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/depargs/ActionDependentArgsPage.layout.xml
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage.layout.xml
@@ -29,30 +29,23 @@
<bs3:col span="12">
<bs3:row>
<bs3:col span="6">
- <cpt:collection id="items"/>
+ <cpt:collection id="tvCharacters"/>
+ <cpt:collection id="selectedTvCharacters"/>
</bs3:col>
<bs3:col span="6">
- <cpt:fieldSet name="Action Parameter Support"
id="actions-dep1">
-
- <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 name="Hide Action" id="hide-action">
+ <cpt:action
id="selectTvCharactersIfNotHidden"/>
+ <cpt:property id="hideActionDescription"/>
+ <cpt:property id="actionHidden"/>
</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 name="Disable Action"
id="disable-action">
+ <cpt:action
id="selectTvCharactersIfNotDisabled"/>
+ <cpt:property id="disableActionDescription"/>
+ <cpt:property id="actionDisabled"/>
</cpt:fieldSet>
-
- <cpt:fieldSet name="Action Parameter Support"
id="actions-indep">
- <cpt:action id="useIndependent"/>
- <cpt:property id="independentText"/>
+ <cpt:fieldSet name="Veto Parameters"
id="veto-parameter">
+ <cpt:action id="selectTvCharactersBySex"/>
+ <cpt:property id="vetoParamDescription"/>
</cpt:fieldSet>
</bs3:col>
</bs3:row>
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersBySex.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersBySex.java
new file mode 100644
index 0000000000..672ff8a75b
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersBySex.java
@@ -0,0 +1,87 @@
+/*
+ * 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.veto;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+
+import lombok.RequiredArgsConstructor;
+import lombok.Value;
+import lombok.experimental.Accessors;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.causeway.applib.annotation.*;
+
+//tag::class[]
+@Action
+@RequiredArgsConstructor
+public class ActionVetoPage_selectTvCharactersBySex {
+
+ private final ActionVetoPage page;
+
+ @MemberSupport public ActionVetoPage act(
+ @Parameter(optionality = Optionality.MANDATORY)
+ final TvCharacter.Sex sex,
// <.>
+ @Parameter(optionality = Optionality.OPTIONAL)
+ final List<TvCharacter> maleTvCharacters,
+ @Parameter(optionality = Optionality.OPTIONAL)
+ final List<TvCharacter> femaleTvCharacters
+ ) {
+ page.getSelectedTvCharacters().addAll(maleTvCharacters);
+ page.getSelectedTvCharacters().addAll(femaleTvCharacters);
+ return page;
+ }
+
+ @Value @Accessors(fluent = true)
// <1>
+ static class Parameters {
+ final TvCharacter.Sex sex;
+ final List<TvCharacter> maleTvCharacters;
+ final List<TvCharacter> femaleTvCharacters;
+ }
+
+ @MemberSupport public String disableMaleTvCharacters(Parameters
parameters) { // <.>
+ return parameters.sex() == null ? "Sex not yet selected" : null;
+ }
+ @MemberSupport public String disableFemaleTvCharacters(Parameters
parameters) { // <2>
+ return parameters.sex() == null ? "Sex not yet selected" : null;
+ }
+ @MemberSupport public boolean hideMaleTvCharacters(Parameters parameters)
{ // <.>
+ return parameters.sex() == TvCharacter.Sex.FEMALE;
+ }
+ @MemberSupport public boolean hideFemaleTvCharacters(Parameters
parameters) { // <3>
+ return parameters.sex() == TvCharacter.Sex.MALE;
+ }
+ @MemberSupport public java.util.Collection<TvCharacter>
choicesMaleTvCharacters() {
+ return pageTvCharacters(TvCharacter.Sex.MALE);
+ }
+ @MemberSupport public Collection<TvCharacter> choicesFemaleTvCharacters() {
+ return pageTvCharacters(TvCharacter.Sex.FEMALE);
+ }
+ // ...
+//end::class[]
+ private List<TvCharacter> pageTvCharacters(TvCharacter.Sex sex) {
+ return page.getTvCharacters().stream()
+ .filter(x -> x.getSex() == sex).collect(Collectors.toList());
+ }
+//tag::class[]
+}
+//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersIfNotDisabled.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersIfNotDisabled.java
new file mode 100644
index 0000000000..ed7df09452
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersIfNotDisabled.java
@@ -0,0 +1,58 @@
+/*
+ * 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.veto;
+
+import java.util.List;
+import java.util.Set;
+
+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 lombok.RequiredArgsConstructor;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+
+//tag::class[]
+@Action
+@RequiredArgsConstructor
+public class ActionVetoPage_selectTvCharactersIfNotDisabled {
+
+ private final ActionVetoPage page;
+
+ @MemberSupport public ActionVetoPage act(
+ @Parameter(optionality = Optionality.OPTIONAL)
+ final List<TvCharacter> tvCharacters
+ ) {
+ page.getSelectedTvCharacters().addAll(tvCharacters);
+ return page;
+ }
+
+ @MemberSupport public String disableAct() { // <.>
+ return page.isActionDisabled()
+ ? "Action has been disabled"
+ : null;
+ }
+ @MemberSupport public Set<TvCharacter> choicesTvCharacters() {
+ return page.getTvCharacters();
+ }
+}
+//end::class[]
+
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersIfNotHidden.java
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersIfNotHidden.java
new file mode 100644
index 0000000000..ce2007a879
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/veto/ActionVetoPage_selectTvCharactersIfNotHidden.java
@@ -0,0 +1,58 @@
+/*
+ * 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.veto;
+
+import demoapp.dom.domain.actions.progmodel.TvCharacter;
+
+import lombok.RequiredArgsConstructor;
+import lombok.Value;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+import java.util.Set;
+
+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;
+
+//tag::class[]
+@Action
+@RequiredArgsConstructor
+public class ActionVetoPage_selectTvCharactersIfNotHidden {
+
+ private final ActionVetoPage page;
+
+ @MemberSupport public ActionVetoPage act(
+ @Parameter(optionality = Optionality.OPTIONAL)
+ final List<TvCharacter> tvCharacters
+ ) {
+ page.getSelectedTvCharacters().addAll(tvCharacters);
+ return page;
+ }
+
+ @MemberSupport public boolean hideAct() { // <.>
+ return page.isActionHidden();
+ }
+ @MemberSupport public Set<TvCharacter> choicesTvCharacters() {
+ return page.getTvCharacters();
+ }
+}
+//end::class[]
+
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 3cc84f93f5..5d176a537e 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
@@ -86,15 +86,15 @@ For latest we use:
https://raw.githubusercontent.com/apache/causeway/master/anto
</mb3:section>
<mb3:section>
<mb3:named>Prog Model</mb3:named>
- <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.ActionAutoCompleteMenu"
id="autoComplete"/>
<mb3:serviceAction objectType="demo.ActionDefaultsMenu"
id="defaults"/>
<mb3:serviceAction objectType="demo.ActionValidateMenu"
id="validate"/>
- <mb3:serviceAction objectType="demo.ActionDependentArgsMenu"
id="dependentArgsActions">
- <cpt:named>Dependent Arguments</cpt:named>
+ <mb3:serviceAction objectType="demo.ActionVetoMenu" id="veto">
+ <cpt:named>Hide & Disable</cpt:named>
+ </mb3:serviceAction>
+ <mb3:serviceAction objectType="demo.BulkActionMenu"
id="bulkActions">
+ <cpt:named>Bulk Actions</cpt:named>
</mb3:serviceAction>
</mb3:section>
</mb3:menu>
diff --git a/examples/demo/domain/src/main/resources/static/css/application.css
b/examples/demo/domain/src/main/resources/static/css/application.css
index ccc92ee0e0..92e474e008 100644
--- a/examples/demo/domain/src/main/resources/static/css/application.css
+++ b/examples/demo/domain/src/main/resources/static/css/application.css
@@ -352,7 +352,7 @@ tr.odd.custom2 > td,
.navbar-nav.primary ul.dropdown-menu,
.navbar-nav.secondary ul.dropdown-menu,
.navbar-nav.tertiary ul.dropdown-menu {
- max-height: 850px;
+ max-height: 900px;
}
div.sect1 > h2 {