This in effect deprecates the concept of bulk actions... instead use a view model as a wrapper around a collection returned by an action.
Currently we have the concept of a "bulk" action; this is one that operates only on a standalone collection of objects (ie as returned by an action invocation). When one or bulk actions are defined, then the viewer renders the bulk actions' buttons above the collection.
There's an example in the todoapp . Run the app with the ToDoAppAppManifestWithFixtures, then run ToDos > Not Yet Complete. You'll see , with "Not Yet Completed" as one of the actions. This is because of the code in , by way of @Action(invokeOn=OBJECT_AND_COLLECTION) 
There are however some restrictions to this:
- bulk actions cannot take parameters
- it isn't possible to invoke actions on parented collections, only on standalone collections.
In 1.14.0-SNAPSHOT I recently added support for actions that accept collections as parameters. This hasn't yet been released, but will be the "headline" feature in 1.14.0. Building on that I see an opportunity to build upon it to (a) lift both restrictions and (b) remove some code from the framework.
So, my idea is:
- add the ability to have selections on parented collections too
- for actions that are "associated" with a parented collection and that have a collection parameter taking the type of that list, have the framework automatically use the selected objects as the argument values.
- we deprecate the whole concept of bulk actions (ie @Action#invokeOn=...) to remove in the future. Instead, the replacement would simply be a parented collection of a view model.
We currently associate actions with collections using @MemberOrder(...); or this can be done using the .layout.xml file. So the coding model would be something like:
and ideally this is all that would be needed. The user would select items using checkboxes on the "notYetCompleted" collection, and the would be able to invoke the "markAsCompleted" action with the first parameter already populated/defaulted.
Under the covers, the selected items would correspond to a DefaultedFacet for the parameter, and there would be a DisabledFacet on the entire action if no objects has been selected.
I can see several steps to implement this. As well as the actual UI changes to the Wicket viewer (CollectionAsContentsTable or something like that), there will also be some metamodel stuff to add in, ie new FacetFactories.
The support we currently have for lists of objects as parameters requires that there's a ChoicesFacet for the parameter type. So initially the framework would need to generate this facet behind the scenes; it's implementation would be equivalent to:
For the actual selected items, I am thinking it would be useful to introduce an internal domain service for use by the framework, called something like SelectedItemService. You'll see that the framework has a whole bunch defined in the metamodel module , and a bunch more in the runtime module . (Many of these are also exposed as formal API in the applib , but not all; see also ).
Anyway, so SelectedItemService (annotated with @RequestScoped, "obviously") could be a way to provide the list of items currently selected. The generated DefaultedFacet would be equivalent to:
As I say, these choices and defaults methods wouldn't actually be written by the developer, I'm just writing them here to explain what the framework would do automatically.
- if the action takes only a single list of parameters, then there should be no prompt, simply invoke the action.
- as a refinement, rather than (in the action prompt) render the actual list of selected items in a multi-select field, the Wicket viewer could instead just render an unmodifiable label, eg: "5 items selected". This would be a matter of having a new ComponentFactory for the parameter/property that takes precedence over multi-select for those cases when the parameter has been defaulted from the selection.
- we might need an additional annotation/attribute to handle the edge case of an action that takes two or more lists of parameters of the same type (in which case there would be ambiguity as to which it should contribute to).. But as a simplification, in such a case probably ok to automatically default just the first such list.