-
FEATURED COMPONENTS
First time here? Check out the FAQ!
HI,
i'm trying use drag and drop with a listbox in MVVM.
The ListBox is following:
<listbox model="@bind(vm.example)" >
<template name="model">
<listitem draggable="true" droppable="true" label="@load(each.example.displayName)" attributes.item="@load(each)"
onDrop="@command('moveExample', item=event.dragged.attributes.item, base=each)" />
</template>
</listbox>
and in the relative java file there is method:
@Command
public void moveExample(@BindingParam("base") ExampleType base,
@BindingParam("item") ExampleType item) {
/* Something */
}
my problem is that in the moveExample the ExampleType item is always null.
Hi,
I think event.dragged is the listitem you want to drag.
@command('moveExample', item=event.dragged, base=each)
Have you got this working, I'm having the same issue handling this in a ModelView as well.
<listbox id="userSelectionsList" width="350px" multiple="true" model="@bind(vm.productGroupComponents)" selectedItems="@bind(vm.productGroupComponentsSelected)" onDrop="@command('onCharacteristicDropped', item=event.dragged)" droppable="true"> </listbox>
In my MV
@Command public void onCharacteristicDropped(@BindingParam("item") Object item) { logger.debug("On Characteristic Dropped item: {}", item); }
Item is always null? Ideally eventually I want to get the actual java object backing the item in the zk list, but for now I'm just trying to get access to anything that is dragged.
Hi,
according to http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM/Advance/Parameters#Retrieve_Event_Object
After 6.0.1 you can use implicit variable "event" in command binding.
@Hawk... but according to that same doc I should be able to just pass the param in the command like I showed above? onDrop="@command('onCharacteristicDropped', item=event.dragged)"
Unless I'm missing something, I shouldn't have to get the event with @ContextParam in my VM ?
Hi,
Do you use ZK EE 6.0.1 ?
I'm using 6.0.1 but wasn't using the EE version so I switched to that but still not having much luck... is there a dependency I'm missing in my pom?
<properties> <maven.build.timestamp.format>MM.dd.yyyy.HH:mm</maven.build.timestamp.format> <zk.version>6.0.1</zk.version> <zkspring.version>3.0</zkspring.version> </properties> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkspring-core</artifactId> <version>${zkspring.version}</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkspring-webflow</artifactId> <version>${zkspring.version}</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkplus</artifactId> <version>${zk.version}</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zhtml</artifactId> <version>${zk.version}</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkbind</artifactId> <version>${zk.version}</version> </dependency>
Using this repo to pull from
<repository> <id>ZK EE</id> <url>https://maven.zkoss.org/repo/zk/ee</url> </repository>
<repository> <id>ZK PE/EE Evaluation</id> <url>http://mavensync.zkoss.org/eval/</url> </repository>
<dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkmax</artifactId> <version>6.0.1</version> </dependency>
Hi,
implicit variable "event" in data binding only supports after 6.0.1 EE .
could you provide a sample for reproduce it ?
Asked: 2012-05-21 16:07:36 +0800
Seen: 830 times
Last updated: Aug 02 '12