0

onDrop="move(event.dragged)" code equivelant

asked 2010-05-29 21:39:44 +0800

clueless gravatar image clueless
62 1 4

In a zul file I can add to a component onDrop="move(event.dragged)" which will call the method "move"

I am dynamically building a component and want to do the equivelant in code. However, I do not see a comparable way. I know I can do the following:
someComponent.addEventListener("onDrop", new EventListener())
but how do I specify the method to call e.g. "move(event.dragged)

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2010-05-30 13:27:20 +0800

clueless gravatar image clueless
62 1 4

Anyone have any advice/solutions for me

link publish delete flag offensive edit

answered 2010-05-31 11:51:46 +0800

iantsai gravatar image iantsai
2755 1

where are you declaring your move() method?

link publish delete flag offensive edit

answered 2010-05-31 13:58:34 +0800

clueless gravatar image clueless
62 1 4

I declare my move() method inside a Composer class, which is referenced (via apply="myComposer") at the borderlayout definition within the .zul file.

link publish delete flag offensive edit

answered 2010-05-31 21:07:47 +0800

clueless gravatar image clueless
62 1 4

bumping as i hope to get an answer

link publish delete flag offensive edit

answered 2010-05-31 21:11:59 +0800

iantsai gravatar image iantsai
2755 1

if your composer was extended GenericFrowardComposer, then you can:

1. override doAfterCompose() method, and don't forget to call super.doAfterCompose() at first line.

2. in doAfterCompose() method body, do someComponent.addEventListener("onDrop", new EventListener())

that's it.

link publish delete flag offensive edit

answered 2010-05-31 23:02:48 +0800

clueless gravatar image clueless
62 1 4

iansti - thanks for your reply, but I guess I did not make myself clear. I want to know, via code, how I can attach the method 'move(event dragged)'. In otherwords, through the zul file I can state onDrop="move(event.dragged)" which, somehow adds the method call to move. is there a code equivelant that will allow me to someComponent.addEventListener("onDrop", new EventListener()) and then attach the method call "move(event dragged")??

link publish delete flag offensive edit

answered 2010-06-01 05:22:35 +0800

iantsai gravatar image iantsai
2755 1

You mean your method is inside GenericForwardComposer and you want to use it in ZUL?
if that so, it's easy, because:

composerid = id + _separator + "composer";

The default separator is '$', so to access it in zscript is to call: id+"$composer" in your event Listener.
then, you can make your method to public and use it in Zscript.

link publish delete flag offensive edit

answered 2010-06-01 10:50:51 +0800

clueless gravatar image clueless
62 1 4

that is not what I mean - another try:

In most of the examples for drag and drop there is an entry in the component description of the *.zul file like this:
onDrop="move(event.dragged)", which will call the method "move" passing the event dragged. This I understand completely.

Here is my situation - I am not creating the component within the *.zul file, instead I am creating the component dynamically. I do not see any api that allows me to set the move(event.dragged).

I tried someComponent.addEventListener("onDrop=move(event.dragged)", new EventListener()) but got an error.

Hope this is clearer. Forget about the *.zul file, I only mention it because it has the behavior I want to mimin dynamically in code onDrop="move(event.dragged)"

link publish delete flag offensive edit

answered 2010-06-01 11:04:32 +0800

iantsai gravatar image iantsai
2755 1

updated 2010-06-01 11:09:30 +0800

Oh, okay then try this:



someComponent.addEventListener(Events.ON_DROP, new EventListener(){
	public void onEvent(DropEvent event) throws Exception {
		move(event.getDragged());
}});


link publish delete flag offensive edit

answered 2012-08-05 23:28:00 +0800

btorres gravatar image btorres
6

I have worked out this way

someComponent.addEventListener(Events.ON_DROP, new EventListener<Event>(){

public void onEvent(Event event) throws Exception {
Component dragged = ((DropEvent) event).getDragged();
move(dragged);
}
});

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: 2010-05-29 21:39:44 +0800

Seen: 743 times

Last updated: Aug 05 '12

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