Ok, what I wrote in the previous mail does not help ...

I looked in the class ToDoItem.java in the github's repository [1]
and found:

org.apache.isis.applib.annotation.Bulk import;
org.apache.isis.applib.annotation.Bulk.InteractionContext import;

I'll have to update my applib to implement the solution ...

[1]
https://github.com/apache/isis/blob/master/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java


2013/10/8 Ezequiel Celiz <[email protected]>

> Dan, thanks for the interest
>
> When I try to implement the solution that you suggest, I find that
> InteractionContext is an interface, and this can be found in the package
> org.apache.isis.core.metamodel.interactions. * ......
>
> Then add in the pom.xml of "project-dom" this dependency:
>
> <dependency>
>        <groupId> org.apache.isis.progmodels </ groupId>
>        <artifactId> wrapper-metamodel </ artifactId>
>        <version> 0.2.0-incubating </ version>
> </ dependency>
>
> Now I can use InteractionContext.java
>
> However, I can't make use of:
> final InteractionContext ctxt = InteractionContext.current.get();
> because InteractionContext.current.get() does not exist.
>
> Apologies Dan, that's what I can be doing wrong?
>
> regards
> Ezequiel
>
>
> 2013/10/8 Dan Haywood <[email protected]>
>
>> 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
>> >
>> >
>>
>
>

Reply via email to