0

MVVM how to call command with the "dropped" component from drag/drop?

asked 2012-06-06 15:40:01 +0800

rickcr gravatar image rickcr
704 7

I'm trying to call a method in my ViewModel that has access to the item that was dropped into a listbox. I'm not sure how to achieve this though.

I have my backing list of objects in my VM and I was trying to send the command as such:

<listbox id="userSelectionsList"  multiple="true"
			onDrop="@command('onCharacteristicDropped', item=event.draggable)" droppable="true">

In my controller, I can get onCharacteristicDropped to be fired, but I can't seem to get access to the item that was dropped.

 
	@Command
	public void onCharacteristicDropped(@BindingParam("item") Component item) {  
                  logger.debug("On Characteristic Dropped item: {}", item); //item is always null

What's the best way to handle this?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-06-12 03:36:39 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

Hi rickcr,

You can get trigger event in command function as below:

@Command
public void onCharacteristicDropped(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
    DropEvent event = (DropEvent)ctx.getTriggerEvent();
        ...
}

Regards,
Ben

link publish delete flag offensive edit

answered 2012-06-12 12:33:53 +0800

rickcr gravatar image rickcr
704 7

I got it working with my first approach.. but I had to use the EE edition (6.0.1) with zkmax dependency. (Seems somewhat odd that you'd need the EE for what I'd think would be pretty common behavior for a UI using a ModelView approach.)

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-06-06 15:40:01 +0800

Seen: 170 times

Last updated: Jun 12 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More