Quick follow-up on this ; Deepak contacted me offlist to say that the code
below throws a ClassCastException.  It seems that Isis assumes that
standalone collections are of type java.util.List, not Sets.

The workaround is therefore:

    @ActionSemantics(Of.SAFE)
    public SortedSet<B> bulkDelete() { return new ArrayList<B>(children); }


Deepak's gonna raise a ticket for this so that the original code I posted
would also work.

Dan



On 20 December 2013 08:05, Dan Haywood <[email protected]> wrote:

> Hi Deepak,
> the best you can do at the moment (other than providing a patch :-) is to
> "export" the parented collection as a standalone collection:
>
> public class A {
>
>     private SortedSet<B> children = ...
>     public SortedSet<B> getChildren() { return children; }
>     public void setChildren(SortedSet<B> children) { this.children =
> children; }
>
>     // simply exposes (a copy of) the parented collection as a standalone
> collection
>     @ActionSemantics(Of.SAFE)
>     public SortedSet<B> bulkDelete() { return new TreeSet<B>(children); }
>
> }
>
> and then:
>
> public class B {
>
>     private A parent;
>     public A getParent() { return parent; }
>     public void setParent(A parent) { this.parent= parent; }
>
>     @Bulk
>     public SortedSet<B> delete() {
>        A parent = getParent();
>        container.removeIfNotAlready(this);
>        TreeSet<B> remainingChildren = parent.bulkDelete();
>        remainingChildren.remove(this);
>        return remainingChildren;
>     }
> }
>
> It might also work simply as:
>
>     @Bulk
>     public void delete() {
>        container.removeIfNotAlready(this);
>     }
>
> I have a feeling that if the bulk action returns void, then the standalone
> collection is refreshed.
>
> Hope that helps.  If the user experience isn't good enough, though, then
> do go ahead and raise a ticket if you wish for @Bulk being supported on
> parented collections.  No guarantees when it'll be implemented, though...
>
> Cheers
> Dan
>
>
> [1]
> https://github.com/apache/isis/blob/isis-1.3.0/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java#L569
>
>
>
>
>
> On 20 December 2013 00:13, Deepak Gopalakrishnan <[email protected]> wrote:
>
>> Hello,
>>
>> I have a dom class A which contains a datamember List<B>. I need to be
>> able
>> to select and delete multiple items in list B in one go. The issue I'm
>> facing is that @Bulk does work only work with standalone collections. Can
>> someone gimme an example of how to do this?
>>
>>
>> -Deepak
>>
>
>

Reply via email to