前台(Drop.zul)
Unique Visitors of ZK: void move(Component dragged) { self.parent.insertBefore(dragged, self); }
后台(DropCtrl.java)
package test;import org.zkoss.zk.ui.Component;import org.zkoss.zk.ui.event.DropEvent;import org.zkoss.zk.ui.event.Event;import org.zkoss.zk.ui.event.EventListener;import org.zkoss.zk.ui.event.Events;import org.zkoss.zk.ui.util.GenericForwardComposer;import org.zkoss.zul.Div;import org.zkoss.zul.Image;import org.zkoss.zul.Listitem;import org.zkoss.zul.Menupopup;import org.zkoss.zul.Window;public class DropCtrl extends GenericForwardComposer{ private Listitem listItem1; private Div hlayout; private Menupopup editPopup; private Window dropWin; @Override public void doAfterCompose(Component comp) throws Exception { // TODO Auto-generated method stub super.doAfterCompose(comp); listItem1 = (Listitem) dropWin.getFellow("listItem1"); listItem1.addEventListener(Events.ON_DROP, new EventListener () { @Override public void onEvent(Event event) throws Exception { // TODO Auto-generated method stub DropEvent dropEvent = (DropEvent)event; System.out.println(dropEvent.getDragged().getId()); } }); hlayout.addEventListener(Events.ON_DROP, new EventListener () { @Override public void onEvent(Event event) throws Exception { // TODO Auto-generated method stub DropEvent dropEvent = (DropEvent)event; if (!dropEvent.getDragged().getId().equals("")) { Image image = new Image(); image.setSrc("/images/02.png"); image.setDraggable("true"); image.setContext(editPopup); //System.out.println(self.getId());//self指当前窗口 hlayout.insertBefore(image, hlayout); } } }); }}