Posting composer event [closed]

asked 2015-04-08 04:44:33 +0800

echarish gravatar image echarish flag of Japan
1809 7


I have a window that extends GenericForwardComposer and has a method updateCart(Event event), now the problem is when this window is part of zul like

  <window apply="com.hksys.CartComposer" id="carComposerWin">

and I try to execute the event updateCart by using Events.postEvent(new Event("updateCart", null, cartObject));

everything works fine but when i include this window into some other component like hbox or may be in border layout like

    <window apply="com.hksys.CartComposer" id="carComposerWin">

the posing of event is not working, i am all out of clues, what i am missing, one thing i can guess is when included in other component, Event queue is not able to find the method of composer but i don't know as of yet how to expose it.

any help or suggestions are welcome.


delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by echarish
close date 2015-04-09 02:32:51

1 Answer

Sort by ยป oldest newest most voted

answered 2015-04-08 05:48:00 +0800

echarish gravatar image echarish flag of Japan
1809 7

I was able to resolve the issue by changing the way i was posting the event

I was using


instead of this i had to use

EventQueues.lookup("cartEventQueue", EventQueues.APPLICATION, true).publish(event);

and in my composer i had to subscribe to this event queue by using

eventQueue=EventQueues.lookup("cartEventQueue", EventQueues.APPLICATION, true);
    eventQueue.subscribe(new EventListener<Event>() {
        public void onEvent(Event event) throws Exception {
link publish delete flag offensive edit


even you found a workaround here an explanation why the previous could not work, and how it should work using this constructor for an event. http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/event/Event.html#Event%28java.lang.String,%20org.zkoss.zk.ui.Component,%20java.lang.Object%29

cor3000 ( 2015-04-09 02:43:12 +0800 )edit

If you do not define the target component the event will only be sent to the ROOTcomponents (the <hbox> in your case) see the documentation link above. the simplest and most efficient usage is: Events.postEvent(new Event("updateCart", carComposerWin, cartObject)); No need for using an Eventqueue.

cor3000 ( 2015-04-09 02:46:08 +0800 )edit

An event queue with APPLICATION scope is dangerous, as it will notify ALL concurrent users in all sessions, about the same event. If still needed use the DESKTOP SCOPE for this case instead (http://books.zkoss.org/wiki/ZKDeveloper%27sReference/EventHandling/EventQueues)

cor3000 ( 2015-04-09 02:49:08 +0800 )edit

Question tools

1 follower



Asked: 2015-04-08 04:44:33 +0800

Seen: 15 times

Last updated: Apr 08 '15

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