You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Joshua Lim <li...@gmail.com> on 2009/07/11 10:39:46 UTC

Re: Drag & Drop

Hi Pierre,

I think I need to explain a little the state of Yui Integration with wicket.


If you're using the "sortable" package, with it's "Droppable" and
"SortableList". Then don't use the YuiDDTarget.

If you want to use YuiDDTarget, then work with the YuiDDList / YuiDDListView
/ YuiDDListViewPanel.

The reason being I wrote the YuiDD* not knowing that Janne had already a
"sortable" package, it turned out to be interestingly similar in some way
(since we had taken the same example form yui), but I adapted some of her
stuff into mine as I needed for the DynamicAjaxTabbedPanel to be nested
within itself.

So. If you're using the YuiDD*...

Add YuiDDList behaviour to make your List ("<li">"'s) reorderable

YuiDDTarget is really needed for an empty list to allow it to accept a drop
when there's nothing to start with. Just don't add this behaviour if you
dont want to accept a drop.

Is that what you want? or you can try the examples

HTH
Josh

2009/6/22 Pierre Goupil <go...@gmail.com>

> Hello,
>
> I'm currently playing with AJAX in Wicket using WicketStuff YUI
> integration.
>
> Is there any way to refuse a drop ? There's a behavior called Droppable
> which includes an accept() method but I can't figure out how to add it to
> my
> component tree / call it.
>
> Here's a working code snippet :
>
> -----
> final WebMarkupContainer list1;
>
>        final List<String> list1items = new ArrayList<String>();
>        list1items.add("1.1");
>        list1items.add("1.2");
>
>        add(list1 = new WebMarkupContainer("list1"));
>        list1.setOutputMarkupId(true);
>
> list1.add(new YuiDDTarget("LIST") {
>            private static final long serialVersionUID =
> -62687283825213344L;
>
>            @Override
>            public void onDrop(AjaxRequestTarget target, Component
> component) {
>                String newItem = ((ListItem<String>)
> component).getModelObject();
>                list1items.add(newItem);
>                target.addComponent(list1);
>            }
>
>        });
>
> -----
>
> But then, I'm trying to add a new Droppable() to my list1 component but
> neither onDrop() nor accept() are called :
>
> -----
> Droppable d = new Droppable() {
>
>       private static final long serialVersionUID = -3647700662771836452L;
>            @Override
>            protected boolean accept(Draggable draggable) {
>                return super.accept(draggable);
>            }
>
>            @Override
>            public void onDrop(AjaxRequestTarget target, Component
> component, int index) {
>            }
>
>        };
> list1.add(d);
> -----
>
>
> A clue, anyone ?
>
> Regards,
>
> Pierre
>
>
> --
> Sans amis était le grand maître des mondes,
> Eprouvait manque, ce pour quoi il créa les esprits,
> Miroirs bienveillants de sa béatitude.
> Mais au vrai, il ne trouva aucun égal,
> Du calice du royaume total des âmes
> Ecume jusqu'à lui l'infinité.
>
> (Schiller, "l'amitié")
>