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
commit 20fca23141d1f0d80bd627ee2b189ad1f373bfff Author: danhaywood <[email protected]> AuthorDate: Mon May 15 06:44:42 2023 +0100 CAUSEWAY-2485: adds an action autoComplete example --- .../autocomplete/ActionAutoCompleteMenu.java | 51 ++++++++++++ ...letePage-dependentAutoCompleteDescription.adoc} | 6 +- .../ActionAutoCompletePage-description.adoc} | 57 +++++++------ ...pletePage-multipleAutoCompleteDescription.adoc} | 4 +- ...CompletePage-parameterMatchingDescription.adoc} | 4 +- ...ompletePage-singleAutoCompleteDescription.adoc} | 4 +- .../autocomplete/ActionAutoCompletePage.java | 96 ++++++++++++++++++++++ .../autocomplete/ActionAutoCompletePage.layout.xml | 82 ++++++++++++++++++ .../ActionAutoCompletePage_selectTvCharacter.java} | 24 +++--- ...nAutoCompletePage_selectTvCharacterByShow.java} | 20 +++-- ...ActionAutoCompletePage_selectTvCharacters.java} | 22 +++-- ...AutoCompletePage_selectTvCharactersByShow.java} | 19 +++-- ...utoCompletePage_selectTvCharactersByShows.java} | 28 +++---- ...tionChoicesPage-dependentChoiceDescription.adoc | 6 +- .../choices/ActionChoicesPage-description.adoc | 22 ++--- ...tionChoicesPage-multipleChoicesDescription.adoc | 4 +- .../ActionChoicesPage-singleChoiceDescription.adoc | 4 +- .../ActionChoicesPage_selectTvCharacterByShow.java | 2 +- .../ActionChoicesPage_selectTvCharacters.java | 2 +- ...ActionChoicesPage_selectTvCharactersByShow.java | 6 +- ...ctionChoicesPage_selectTvCharactersByShows.java | 6 +- .../src/main/java/demoapp/dom/menubars.layout.xml | 1 + 22 files changed, 356 insertions(+), 114 deletions(-) diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompleteMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompleteMenu.java new file mode 100644 index 0000000000..94a6cffcb4 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompleteMenu.java @@ -0,0 +1,51 @@ +/* + * 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.autocomplete; + +import demoapp.dom.domain.actions.progmodel.TvCharacterPopulator; + +import lombok.RequiredArgsConstructor; +import lombok.val; + +import javax.annotation.Priority; +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.causeway.applib.annotation.*; +import org.apache.causeway.applib.services.factory.FactoryService; + +@Named("demo.ActionAutoCompleteMenu") +@DomainService(nature=NatureOfService.VIEW) +@Priority(PriorityPrecedence.EARLY) +@RequiredArgsConstructor(onConstructor_ = { @Inject }) +public class ActionAutoCompleteMenu { + + final FactoryService factoryService; + final TvCharacterPopulator tvCharacterPopulator; + + @Action + @ActionLayout(cssClassFa="fa-bolt") + public ActionAutoCompletePage autoComplete(){ + val page = factoryService.viewModel(new ActionAutoCompletePage()); + tvCharacterPopulator.populate(page.getTvCharacters()); + return page; + } + +} + diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-dependentAutoCompleteDescription.adoc similarity index 69% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-dependentAutoCompleteDescription.adoc index c2d7267e72..a3cf301c75 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-dependentAutoCompleteDescription.adoc @@ -1,7 +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 [...] -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*. +The actions in this section illustrate how to implement an action where the candidate arguments of one parameter are dependent upon the value of an earlier parameter. +The first action has a scalar parameter type, with the supporting "autoComplete" method associated to the parameter by *number*. +The second action has a collection parameter type, with the supporting "autoComplete" method associated to the parameter by *name*. 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/autocomplete/ActionAutoCompletePage-description.adoc similarity index 53% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-description.adoc copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-description.adoc index 316dbdd5c4..bc61c31531 100644 --- 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/autocomplete/ActionAutoCompletePage-description.adoc @@ -4,18 +4,20 @@ Before an action can be invoked, the end-user has to provide an argument for eac 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). +An "autoComplete" supporting method provides a set of candidate arguments for the parameter type, rendered in the UI as a drop-down list. +A search criteria is used to filter from an initial larger list (typically used in repository query); if there is only a smaller initial list then use the simpler "choices" supporting method instead. + +The method should also (if possible) only proffer candidates that would also pass any validation rules, to avoid an otherwise 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. +* the parameter for which candidates are being supplied can be either a scalar or a collection +* the supporting "autoComplete" method can be associated with the parameter by number, or by name +* the list of candidates for a parameter can depend upon the value already selected for an earlier parameter. +** The preceding N-1 parameters are supplied to the Nth "autoComplete" 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. +As noted above, a supporting method to return a list of candidate arguments is _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 @@ -29,59 +31,64 @@ 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. +It matches the supporting "autoComplete" method with the parameter by number. + [source,java] -.ActionChoicesPage_selectTvCharacter.java +.ActionAutoCompletePage_selectTvCharacter.java ---- -include::ActionChoicesPage_selectTvCharacter.java[tags=class] +include::ActionAutoCompletePage_selectTvCharacter.java[tags=class] ---- <.> defines the 0th-param -<.> provides the choices for the 0-th parameter. +<.> provides the candidate arguments for the 0-th parameter. The collection's element type must match that of the parameter. +<.> prompts for a search string, which is then used to limit the candidate arguments from an original larger list * 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 +.ActionAutoCompletePage_selectTvCharacters.java ---- -include::ActionChoicesPage_selectTvCharacters.java[tags=class] +include::ActionAutoCompletePage_selectTvCharacters.java[tags=class] ---- -<.> provides the choices for the "tvCharacters" parameter +<.> provides the candidate arguments for the "tvCharacters" parameter +<.> prompts for a search string, which is then used to limit the candidate arguments from an original larger list * 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 +.ActionAutoCompletePage_selectTvCharacterByShow.java ---- -include::ActionChoicesPage_selectTvCharacterByShow.java[tags=class] +include::ActionAutoCompletePage_selectTvCharacterByShow.java[tags=class] ---- <.> this parameter is used to filter the TV characters -<.> the choices method is matched by number ... +<.> the "autoComplete" method is matched by number ... <.> \... and has a subset of the parameters of the action itself ("N-1" of them). +<.> prompts for a search string, which is then used to limit the candidate arguments from an original larger list -* the next example is similar; dependent arguments but with a multiple selection, and using names to match the choices method: +* the next example is similar; dependent arguments but with a multiple selection, and using names to match the "autoComplete" method: + [source,java] -.ActionChoicesPage_selectTvCharactersByShows.java +.ActionAutoCompletePage_selectTvCharactersByShows.java ---- -include::ActionChoicesPage_selectTvCharactersByShows.java[tags=class] +include::ActionAutoCompletePage_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 "autoComplete" 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 +<.> prompts for a search string, which is then used to limit the candidate arguments from an original larger list * the final example also demonstrates dependent arguments, but using a "Parameters" record. + [source,java] -.ActionChoicesPage_selectTvCharactersByShow.java +.ActionAutoCompletePage_selectTvCharactersByShow.java ---- -include::ActionChoicesPage_selectTvCharactersByShow.java[tags=class] +include::ActionAutoCompletePage_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 +<.> the framework will set the fields of `Parameters` object as appropriate +<.> prompts for a search string, which is then used to limit the candidate arguments from an original larger list + In a small action like this, there is little to be gained by introducing a "Parameters" record class. diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-multipleAutoCompleteDescription.adoc similarity index 78% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-multipleAutoCompleteDescription.adoc index ada51b0622..db1a79d953 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-multipleAutoCompleteDescription.adoc @@ -1,5 +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 [...] -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`). +The action above illustrates how to implement an action with a collection parameter type. +The action associates the supporting "autoComplete" method with the parameter by *name* (`autoCompleteTvCharacters`). diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-parameterMatchingDescription.adoc similarity index 74% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-parameterMatchingDescription.adoc index ada51b0622..3db3a3c8d0 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-parameterMatchingDescription.adoc @@ -1,5 +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 [...] -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`). +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. diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-singleAutoCompleteDescription.adoc similarity index 78% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-singleAutoCompleteDescription.adoc index ada51b0622..4e2c73a8f0 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage-singleAutoCompleteDescription.adoc @@ -1,5 +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 [...] -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`). +The action above illustrates how to implement an action with a scalar (reference) parameter type. +The action associates the supporting "autoComplete" method with the parameter by *number* (`autoCompleteNAct`). diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage.java new file mode 100644 index 0000000000..7749ce78d9 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage.java @@ -0,0 +1,96 @@ +/* + * 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.autocomplete; + +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.Property; +import org.apache.causeway.applib.annotation.PropertyLayout; +import org.apache.causeway.valuetypes.asciidoc.applib.value.AsciiDoc; + +import lombok.Getter; + +import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; +import demoapp.dom._infra.resources.AsciiDocReaderService; +import demoapp.dom.domain.actions.progmodel.TvCharacter; + +@XmlRootElement(name = "Demo") +@XmlType +@XmlAccessorType(XmlAccessType.FIELD) +@Named("demo.ActionAutoComplete") +@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED) +public class ActionAutoCompletePage implements HasAsciiDocDescription { + + @ObjectSupport public String title() { + return "Action Auto-complete"; + } + + + @Property + @PropertyLayout(labelPosition=LabelPosition.NONE) + public AsciiDoc getSingleAutoCompleteDescription() { + return asciiDocReaderService.readFor(this, "singleAutoCompleteDescription"); + } + @Property + @PropertyLayout(labelPosition=LabelPosition.NONE) + public AsciiDoc getMultipleAutoCompleteDescription() { + return asciiDocReaderService.readFor(this, "multipleAutoCompleteDescription"); + } + @Property + @PropertyLayout(labelPosition=LabelPosition.NONE) + public AsciiDoc getDependentAutoCompleteDescription() { + return asciiDocReaderService.readFor(this, "dependentAutoCompleteDescription"); + } + @Property + @PropertyLayout(labelPosition=LabelPosition.NONE) + public AsciiDoc getParameterMatchingDescription() { + return asciiDocReaderService.readFor(this, "parameterMatchingDescription"); + } + + + @Collection + @CollectionLayout + @Getter + 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/autocomplete/ActionAutoCompletePage.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage.layout.xml new file mode 100644 index 0000000000..9d0394b7fb --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage.layout.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- 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. --> +<bs3:grid + xsi:schemaLocation="https://causeway.apache.org/applib/layout/component https://causeway.apache.org/applib/layout/component/component.xsd https://causeway.apache.org/applib/layout/grid/bootstrap3 https://causeway.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd" + xmlns:bs3="https://causeway.apache.org/applib/layout/grid/bootstrap3" + xmlns:cpt="https://causeway.apache.org/applib/layout/component" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <bs3:row> + <bs3:col span="10" unreferencedActions="true"> + <cpt:domainObject /> + </bs3:col> + <bs3:col span="2"> + <cpt:fieldSet name="" id="sources" /> + </bs3:col> + </bs3:row> + <bs3:row> + + <bs3:col span="6"> + <bs3:row> + <bs3:col span="12"> + <bs3:row> + <bs3:col span="6"> + <cpt:collection id="tvCharacters"/> + <cpt:collection id="selectedTvCharacters"/> + </bs3:col> + <bs3:col span="6"> + <cpt:fieldSet name="Single Auto-complete" id="single-auto-complete"> + <cpt:action id="selectTvCharacter"/> + <cpt:property id="singleAutoCompleteDescription"/> + </cpt:fieldSet> + <cpt:fieldSet name="Multiple Auto-complete" id="multi-auto-complete"> + <cpt:action id="selectTvCharacters"/> + <cpt:property id="multipleAutoCompleteDescription"/> + </cpt:fieldSet> + <cpt:fieldSet name="Dependent Auto-complete" id="dependent-auto-complete"> + <cpt:action id="selectTvCharacterByShow"/> + <cpt:action id="selectTvCharactersByShows"/> + <cpt:property id="dependentAutoCompleteDescription"/> + </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"/> + </bs3:col> + + <bs3:col span="6"> + <cpt:fieldSet name="Description" id="description" > + <cpt:action id="clearHints" position="PANEL" /> + <cpt:action id="rebuildMetamodel" position="PANEL"/> + <cpt:action id="downloadLayout" position="PANEL_DROPDOWN"/> + <cpt:action id="inspectMetamodel" position="PANEL_DROPDOWN"/> + <cpt:action id="downloadMetamodelXml" position="PANEL_DROPDOWN"/> + <cpt:action id="downloadJdoMetamodel" position="PANEL_DROPDOWN"/> + <cpt:action id="recentCommands" position="PANEL_DROPDOWN"/> + <cpt:action id="recentExecutions" position="PANEL_DROPDOWN"/> + <cpt:action id="recentAuditTrailEntries" position="PANEL_DROPDOWN"/> + <cpt:action id="impersonateWithRoles" position="PANEL_DROPDOWN"/> + <cpt:action id="openRestApi" position="PANEL_DROPDOWN" /> + <cpt:property id="description"/> + </cpt:fieldSet> + </bs3:col> + + </bs3:row> + <bs3:row> + <bs3:col span="12" unreferencedCollections="true"/> + </bs3:row> + +</bs3:grid> 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/autocomplete/ActionAutoCompletePage_selectTvCharacter.java similarity index 69% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacterByShow.java copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage_selectTvCharacter.java index 9899f09ef9..54acefb573 100644 --- 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/autocomplete/ActionAutoCompletePage_selectTvCharacter.java @@ -16,49 +16,45 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.domain.actions.progmodel.choices; +package demoapp.dom.domain.actions.progmodel.autocomplete; 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.MinLength; 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 { +public class ActionAutoCompletePage_selectTvCharacter { - private final ActionChoicesPage page; + private final ActionAutoCompletePage page; - @MemberSupport public ActionChoicesPage act( + @MemberSupport public ActionAutoCompletePage act( @Parameter(optionality = Optionality.MANDATORY) - final TvShow tvShow, // <.> - @Parameter(optionality = Optionality.MANDATORY) - final TvCharacter tvCharacter + final TvCharacter tvCharacter // <.> ) { page.getSelectedTvCharacters().clear(); page.getSelectedTvCharacters().add(tvCharacter); return page; } - @MemberSupport public Collection<TvCharacter> choices1Act( // <.> - TvShow tvShow // <.> + @MemberSupport public Collection<TvCharacter> autoComplete0Act( // <.> + @MinLength(1) + final String search // <.> ) { return page.getTvCharacters() .stream() - .filter(tvCharacter -> tvShow == null || - tvShow == tvCharacter.getTvShow()) + .filter(x -> x.getName().contains(search)) // <3> .collect(Collectors.toList()); } } 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/autocomplete/ActionAutoCompletePage_selectTvCharacterByShow.java similarity index 76% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacterByShow.java copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage_selectTvCharacterByShow.java index 9899f09ef9..4c9e6285ca 100644 --- 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/autocomplete/ActionAutoCompletePage_selectTvCharacterByShow.java @@ -16,20 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.domain.actions.progmodel.choices; +package demoapp.dom.domain.actions.progmodel.autocomplete; 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.MinLength; 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; @@ -37,13 +36,13 @@ import demoapp.dom.domain.actions.progmodel.TvShow; //tag::class[] @Action(semantics = SemanticsOf.IDEMPOTENT) @RequiredArgsConstructor -public class ActionChoicesPage_selectTvCharacterByShow { +public class ActionAutoCompletePage_selectTvCharacterByShow { - private final ActionChoicesPage page; + private final ActionAutoCompletePage page; - @MemberSupport public ActionChoicesPage act( + @MemberSupport public ActionAutoCompletePage act( @Parameter(optionality = Optionality.MANDATORY) - final TvShow tvShow, // <.> + final TvShow tvShow, // <.> @Parameter(optionality = Optionality.MANDATORY) final TvCharacter tvCharacter ) { @@ -52,13 +51,16 @@ public class ActionChoicesPage_selectTvCharacterByShow { return page; } - @MemberSupport public Collection<TvCharacter> choices1Act( // <.> - TvShow tvShow // <.> + @MemberSupport public Collection<TvCharacter> autoComplete1Act( // <.> + final TvShow tvShow, // <.> + @MinLength(1) + final String search // <.> ) { return page.getTvCharacters() .stream() .filter(tvCharacter -> tvShow == null || tvShow == tvCharacter.getTvShow()) + .filter(x -> x.getName().contains(search)) // <4> .collect(Collectors.toList()); } } 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/autocomplete/ActionAutoCompletePage_selectTvCharacters.java similarity index 67% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharacters.java copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage_selectTvCharacters.java index 84cffe0ce4..76f4985634 100644 --- 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/autocomplete/ActionAutoCompletePage_selectTvCharacters.java @@ -16,13 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.domain.actions.progmodel.choices; +package demoapp.dom.domain.actions.progmodel.autocomplete; import java.util.Collection; import java.util.List; +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.MinLength; import org.apache.causeway.applib.annotation.Optionality; import org.apache.causeway.applib.annotation.Parameter; import org.apache.causeway.applib.annotation.SemanticsOf; @@ -34,21 +36,27 @@ import demoapp.dom.domain.actions.progmodel.TvCharacter; //tag::class[] @Action(semantics = SemanticsOf.IDEMPOTENT) @RequiredArgsConstructor -public class ActionChoicesPage_selectTvCharacters { +public class ActionAutoCompletePage_selectTvCharacters { - private final ActionChoicesPage page; + private final ActionAutoCompletePage page; - @MemberSupport public ActionChoicesPage act( + @MemberSupport public ActionAutoCompletePage act( @Parameter(optionality = Optionality.MANDATORY) - List<TvCharacter> tvCharacters // <.> + final List<TvCharacter> tvCharacters // <.> ) { page.getSelectedTvCharacters().clear(); page.getSelectedTvCharacters().addAll(tvCharacters); return page; } - @MemberSupport public Collection<TvCharacter> choicesTvCharacters() { // <1> - return page.getTvCharacters(); + @MemberSupport public Collection<TvCharacter> autoCompleteTvCharacters( // <1> + @MinLength(1) + final String search // <.> + ) { + return page.getTvCharacters() + .stream() + .filter(x -> x.getName().contains(search)) // <2> + .collect(Collectors.toList()); } } //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/autocomplete/ActionAutoCompletePage_selectTvCharactersByShow.java similarity index 80% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShow.java copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage_selectTvCharactersByShow.java index e89cda4522..57361f013f 100644 --- 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/autocomplete/ActionAutoCompletePage_selectTvCharactersByShow.java @@ -16,19 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.domain.actions.progmodel.choices; +package demoapp.dom.domain.actions.progmodel.autocomplete; 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.MinLength; 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; @@ -41,11 +39,11 @@ import demoapp.dom.domain.actions.progmodel.TvShow; //tag::class[] @Action(semantics = SemanticsOf.SAFE) @RequiredArgsConstructor -public class ActionChoicesPage_selectTvCharactersByShow { +public class ActionAutoCompletePage_selectTvCharactersByShow { - private final ActionChoicesPage page; + private final ActionAutoCompletePage page; - @MemberSupport public ActionChoicesPage act( + @MemberSupport public ActionAutoCompletePage act( @Parameter(optionality = Optionality.MANDATORY) TvShow tvShow, // <.> @Parameter(optionality = Optionality.MANDATORY) @@ -62,13 +60,16 @@ public class ActionChoicesPage_selectTvCharactersByShow { List<TvCharacter> tvCharacters; } - @MemberSupport public List<TvCharacter> choicesTvCharacters( - Parameters params // <2> + @MemberSupport public List<TvCharacter> autoCompleteTvCharacters( + final Parameters params, // <2> + @MinLength(1) + final String search // <.> ) { val tvShowSelected = params.tvShow(); // <.> return page.getTvCharacters() .stream() .filter(tvCharacter -> tvShowSelected == tvCharacter.getTvShow()) + .filter(x -> x.getName().contains(search)) // <4> .collect(Collectors.toList()); } } 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/autocomplete/ActionAutoCompletePage_selectTvCharactersByShows.java similarity index 73% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage_selectTvCharactersByShows.java copy to examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/autocomplete/ActionAutoCompletePage_selectTvCharactersByShows.java index bbf15f37c4..7f2f440d08 100644 --- 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/autocomplete/ActionAutoCompletePage_selectTvCharactersByShows.java @@ -16,26 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.domain.actions.progmodel.choices; +package demoapp.dom.domain.actions.progmodel.autocomplete; -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.MinLength; 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; @@ -43,28 +36,31 @@ import demoapp.dom.domain.actions.progmodel.TvShow; //tag::class[] @Action(semantics = SemanticsOf.SAFE) @RequiredArgsConstructor -public class ActionChoicesPage_selectTvCharactersByShows { +public class ActionAutoCompletePage_selectTvCharactersByShows { - private final ActionChoicesPage page; + private final ActionAutoCompletePage page; - @MemberSupport public ActionChoicesPage act( + @MemberSupport public ActionAutoCompletePage act( @Parameter(optionality = Optionality.MANDATORY) - List<TvShow> tvShows, + final List<TvShow> tvShows, @Parameter(optionality = Optionality.MANDATORY) - List<TvCharacter> tvCharacters + final List<TvCharacter> tvCharacters ) { page.getSelectedTvCharacters().clear(); page.getSelectedTvCharacters().addAll(tvCharacters); return page; } - @MemberSupport public List<TvCharacter> choicesTvCharacters( // <.> - List<TvShow> tvShows // <.> + @MemberSupport public List<TvCharacter> autoCompleteTvCharacters( // <.> + final List<TvShow> tvShows, // <.> + @MinLength(1) + final String search // <.> ) { return page.getTvCharacters() .stream() .filter(tvCharacter -> tvShows != null && tvShows.contains(tvCharacter.getTvShow())) + .filter(x -> x.getName().contains(search)) // <3> .collect(Collectors.toList()); } } diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc index c2d7267e72..a4e0cade60 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-dependentChoiceDescription.adoc @@ -1,7 +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 [...] -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*. +The actions in this section illustrate how to implement an action where the candidate arguments of one parameter are dependent upon the value of an earlier parameter. +The first action has a scalar parameter type, with the supporting "choices" method associated to the parameter by *number*. +The second action has a collection parameter type, with the supporting "choices" method associated to the parameter by *name*. 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 index 316dbdd5c4..8d040dcef2 100644 --- 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 @@ -5,17 +5,19 @@ If the parameter is a value (String, number, date etc.) then they can just enter 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). +The list of candidates is expected to be small; if there is a larger list then instead use an "autoComplete" supporting method instead. + +The method should also (if possible) only proffer candidates that would also pass any validation rules, to avoid an otherwise frustrating user experience. There are several variations: -* the parameter itself maybe either a scalar or a collection +* the parameter for which candidates are being supplied can be 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 list of candidates for a parameter can depend upon the value already selected for an earlier parameter. ** 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. +As noted above, a supporting method to return a list of candidate arguments is _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 @@ -37,7 +39,7 @@ It matches the supporting "choices" method with the parameter by number. include::ActionChoicesPage_selectTvCharacter.java[tags=class] ---- <.> defines the 0th-param -<.> provides the choices for the 0-th parameter. +<.> provides the candidate arguments 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. @@ -48,7 +50,7 @@ This time, it matches the supporting "choices" method with the parameter by name ---- include::ActionChoicesPage_selectTvCharacters.java[tags=class] ---- -<.> provides the choices for the "tvCharacters" parameter +<.> provides the candidate arguments 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. + @@ -58,17 +60,17 @@ include::ActionChoicesPage_selectTvCharacters.java[tags=class] include::ActionChoicesPage_selectTvCharacterByShow.java[tags=class] ---- <.> this parameter is used to filter the TV characters -<.> the choices method is matched by number ... +<.> 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: +* 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 ... +<.> 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. @@ -81,7 +83,7 @@ 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 +<.> 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. diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc index ada51b0622..41a4084cf5 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-multipleChoicesDescription.adoc @@ -1,5 +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 [...] -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`). +The action above illustrates how to implement an action with a collection parameter type. +The action associates the supporting "choices" method with the parameter by *name* (`choicesTvCharacters`). diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-singleChoiceDescription.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-singleChoiceDescription.adoc index d4099d2d01..7eace25f6b 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-singleChoiceDescription.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/actions/progmodel/choices/ActionChoicesPage-singleChoiceDescription.adoc @@ -1,5 +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 [...] -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`). +The action above illustrates how to implement an action with a scalar (reference) parameter type. +The action associates the supporting "choices" method with the parameter by *number* (`choicesNAct`). 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 index 9899f09ef9..7b4b009a55 100644 --- 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 @@ -53,7 +53,7 @@ public class ActionChoicesPage_selectTvCharacterByShow { } @MemberSupport public Collection<TvCharacter> choices1Act( // <.> - TvShow tvShow // <.> + final TvShow tvShow // <.> ) { return page.getTvCharacters() .stream() 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 index 84cffe0ce4..82e53f79ff 100644 --- 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 @@ -40,7 +40,7 @@ public class ActionChoicesPage_selectTvCharacters { @MemberSupport public ActionChoicesPage act( @Parameter(optionality = Optionality.MANDATORY) - List<TvCharacter> tvCharacters // <.> + final List<TvCharacter> tvCharacters // <.> ) { page.getSelectedTvCharacters().clear(); page.getSelectedTvCharacters().addAll(tvCharacters); 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 index e89cda4522..e02ff5f1ba 100644 --- 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 @@ -47,9 +47,9 @@ public class ActionChoicesPage_selectTvCharactersByShow { @MemberSupport public ActionChoicesPage act( @Parameter(optionality = Optionality.MANDATORY) - TvShow tvShow, // <.> + final TvShow tvShow, // <.> @Parameter(optionality = Optionality.MANDATORY) - List<TvCharacter> tvCharacters + final List<TvCharacter> tvCharacters ) { page.getSelectedTvCharacters().clear(); page.getSelectedTvCharacters().addAll(tvCharacters); @@ -63,7 +63,7 @@ public class ActionChoicesPage_selectTvCharactersByShow { } @MemberSupport public List<TvCharacter> choicesTvCharacters( - Parameters params // <2> + final Parameters params // <2> ) { val tvShowSelected = params.tvShow(); // <.> return page.getTvCharacters() 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 index bbf15f37c4..9d8d63821e 100644 --- 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 @@ -49,9 +49,9 @@ public class ActionChoicesPage_selectTvCharactersByShows { @MemberSupport public ActionChoicesPage act( @Parameter(optionality = Optionality.MANDATORY) - List<TvShow> tvShows, + final List<TvShow> tvShows, @Parameter(optionality = Optionality.MANDATORY) - List<TvCharacter> tvCharacters + final List<TvCharacter> tvCharacters ) { page.getSelectedTvCharacters().clear(); page.getSelectedTvCharacters().addAll(tvCharacters); @@ -59,7 +59,7 @@ public class ActionChoicesPage_selectTvCharactersByShows { } @MemberSupport public List<TvCharacter> choicesTvCharacters( // <.> - List<TvShow> tvShows // <.> + final List<TvShow> tvShows // <.> ) { return page.getTvCharacters() .stream() 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 35f5346e81..eda36ca9b9 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 @@ -90,6 +90,7 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <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.ActionDependentArgsMenu" id="dependentArgsActions"> <cpt:named>Dependent Arguments</cpt:named> </mb3:serviceAction>
