1

a Self Listening to events

asked 2014-04-30 15:21:13 +0800

aktejo gravatar image aktejo
155 3

updated 2014-04-30 16:24:34 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

Dear

We know in zkoss 6++ SelectorComposer we can annotate a method to listen to any component. The syntax rule is @Listen( event-name = ids / classes / component tags )

what if i want to listen to the self component? I Tried @Listen("onMyEvent=self") and it doesn't work.

I Have fired this event using Events.echoEvent("onMyEvent",getSelf(),null);

please help. manythanks

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-04-30 17:44:14 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

I am not sure but i suppose that you are creating some components dynamically and you need to assign an event listener to these components. Maybe something like this would do the trick:

@Listen("onClick = #buttonsDiv > button")

Assuming that the 'buttonsDiv' is the id of the parent component containing the dynamically created buttons.

Hope that helps

Costas

link publish delete flag offensive edit

Comments

Thanks for quick response. but that is what really I mean, we know a self component is a root component of a zul, this component can be refered with 'getSelf()' method of a SelectorComposer subclass. I want to send event to this root comp (the self), don't know how to refer to this 'self' in @Liste

aktejo ( 2014-04-30 21:21:25 +0800 )edit
0

answered 2014-05-02 11:18:09 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

updated 2014-05-02 11:23:20 +0800

Then why don't you just post the event to the parent component:

@Listen("onClick = #childWindowButton")
public void onClick_childWindowButton(Event event) {
   Component parentComponent = event.getTarget().getParent()...getParent();
   Events.postEvent("onChildButtonClicked", parentComponent)
}

And then assign a listener for this event to the root component:

@Listen("onChildButtonClicked=#rootWindow")
public void onChildButtonClicked() {
   ...do what you have to do...
}

Hope that helps.

Costas

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2014-04-30 15:21:13 +0800

Seen: 23 times

Last updated: May 02 '14

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