OK, I've committed ISIS-559 [1], which implements the above pattern. Anyone... feel free to resurrect this thread if you take great exception to this implementation...
Dan [1] https://issues.apache.org/jira/browse/ISIS-559 On 8 October 2013 20:43, Dan Haywood <[email protected]> wrote: > > > > On 8 October 2013 19:16, Ezequiel Celiz <[email protected]> wrote: > >> Hi community >> >> > Hi Ezequiel, > I'm cc'ing dev on this reply, since some of the committers might want to > remark on my proposed solution here :-) > > > > >> When using the annotation @Bulk in action, you can apply changes to the >> list of selected objects. >> >> I would be interested to use this list of items to send to a service >> function entity and to apply the data supplied by the user (in the >> WebForm) >> to this. >> >> Is it possible? >> > I hope I was clear on what I need >> >> > yes, the request makes sense, but unfortunately right now there's way to > get this information. > > Arguably the "right" thing to do would be for bulk actions to be > implemented as an action on a domain service that takes a list of object. > However, making this change would be a big deal, and isn't one that I want > to embark at the moment. > > What would be easy (though I'm not sure if it's reasonable or not) would > be to define a ThreadLocal in the applib, and use this as a means to pass > context information. > > I've just spiked this, it works well enough: > > > @Bulk > public ToDoItem completed() { > ... > > final BulkInteractionContext ctxt = Bulk.interactionContext.get(); > > @SuppressWarnings("unused") > List<Object> allObjects = ctxt.getDomainObjects(); > > LOG.debug("completed: " > + ctxt.getIndex() + > " [" + ctxt.getSize() + "]" > + (ctxt.isFirst() ? " (first)" : "") > + (ctxt.isLast() ? " (last)" : "")); > > ... > } > > when I run this with 3 todo items selected, my log prints out: > > 20:36:30,351 [ToDoItem 2091197094@qtp-722659319-1 DEBUG] > completed: 0 [3] (first) > 20:36:30,371 [ToDoItem 2091197094@qtp-722659319-1 DEBUG] > completed: 1 [3] > 20:36:30,373 [ToDoItem 2091197094@qtp-722659319-1 DEBUG] > completed: 2 [3] (last) > > The idea, then, is that you could write the action to be a no-op except > for when called for the first (or last) time, in which case it could work > on all the objects provided via ctxt.getDomainObjects(). > > ~~~ > I'm not sure if using a ThreadLocal in this way is just too hacky for > words... but if no-one objects, I'll check it in anyway.... > > > > >> Thanks as always! >> regards >> Ezequiel >> > > Cheers > Dan > >
