0

Multiple windows cannot listen to one event

asked 2014-05-13 11:34:30 +0800

Antoc gravatar image Antoc
21 4

updated 2014-05-13 11:38:08 +0800

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

I have created a ZK application which, as expected, contains several windows and dialogs. One window, say window1, contains a grid with values and buttons. The renderer class of this grid, say GridRenderer.java, contains code for handling the click of a specific button:

final Button myButton = new Button(buttonName);
    myButton.setWidth("70px");

    myButton.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
        public void onEvent(Event event) throws Exception {
            EventQueues.lookup("applicationqueue", EventQueues.DESKTOP, true)
                    .publish(new Event("buttonClicked", null, data));
        }
    });

I want two windows, window1(where the grid is placed) and window2, to subscribe to this event. In the controller classes of both windows I have inserted the following code:

 EventQueues.lookup("applicationqueue", EventQueues.DESKTOP, true).subscribe(
            new EventListener() {
                public void onEvent(Event evt) {
                    if (evt.getName().equals("buttonClicked")) {
                         //do something
                    }
                }
            });

My problem is the following: window1 can 'listen' to the subscribed event, but window2 cannot. Does anyone know a way to solve this problem.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-05-14 10:37:00 +0800

Bobzk gravatar image Bobzk
444 1 8

Not quite sure this is what you are after, we would probably do it all differently (not that I am saying your way is wrong of course). So have a look at "forward" - here is how we use it in one of our zul's on an anchor:

<a id="nb_grid_1d" forward="onClick=onNearbyFromClick">None</a>

Or maybe put all windows in a "border" and have a border controller?

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-05-13 11:34:30 +0800

Seen: 13 times

Last updated: May 14 '14

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