Revision history [back]

click to hide/show revision 1
initial version

asked 2015-07-17 13:17:53 +0800

javiut gravatar image javiut flag of Venezuela, Bolivarian Republic of

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event){
    log.info("OnOpen");
    return;
        }
    };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired once..

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event){
event)
    {
    log.info("OnOpen");
    return;
 }
event.stopPropagation();
  return;
 }
 };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired once..

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event)
    {
    log.info("OnOpen");
            event.stopPropagation();
    return;
 }
 };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired once..twice..

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event)
    {
    log.info("OnOpen");
            event.stopPropagation();
popup.removeEventListener(Events.ON_OPEN,this);     
    event.stopPropagation();                    
    log.info("OnOpen");             
    popup.addEventListener(Events.ON_OPEN,this);
    return;
 }
 };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired twice..

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event)
    {
    popup.removeEventListener(Events.ON_OPEN,this);     
    event.stopPropagation();                    
    log.info("OnOpen");             
    popup.addEventListener(Events.ON_OPEN,this);
    return;
 }
 };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired twice..

Another weird fact is the first time Hbox is clicked only one onOpen is call but from the second time the onopen method is called twice always.

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event)
    {
    popup.removeEventListener(Events.ON_OPEN,this);     
    event.stopPropagation();                    
    log.info("OnOpen");             
    popup.addEventListener(Events.ON_OPEN,this);
    return;
 }
 };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired twice..

Another weird fact is the first time Hbox is clicked only one onOpen is call but from the second time the onopen method is called twice always.

My more specific code

ZUL.

<listcell>
<div align='center'>
   <hbox onCreate='myController.onCreateHBox(self);'>
    <label value="Actions"/>                                        
   </hbox>                              
</div>
</listcell>

In Java

public void onCreateHBox(final Hbox box)
{
 final Popup pop = new Popup();
 pop.appendChild(new Label("Bon Jovi"));
 final EventListener<Event> onOpen = new EventListener<Event>(){public void onEvent(final Event event){log.info("called"); return;}};
 pop.addEventListener(Events.ON_OPEN,onOpen);
 pop.setWidth("200px");                                     
 box.setPopup(pop);
 pop.setParent(box);                    
}

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event)
    {
    popup.removeEventListener(Events.ON_OPEN,this);     
    event.stopPropagation();                    
    log.info("OnOpen");             
    popup.addEventListener(Events.ON_OPEN,this);
    return;
 }
 };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired twice..

Another weird fact is the first time Hbox is clicked only one onOpen is call but from the second time the onopen method is called twice always.

My more specific code

ZUL.

<listcell>
<div align='center'>
   <hbox onCreate='myController.onCreateHBox(self);'>
    <label value="Actions"/>                                        
   </hbox>                              
</div>
</listcell>

In Java

public void onCreateHBox(final Hbox box)
{
 final Popup pop = new Popup();
 pop.appendChild(new Label("Bon Jovi"));
 final EventListener<Event> onOpen = new EventListener<Event>(){public void onEvent(final Event event){log.info("called"); return;}};
 pop.addEventListener(Events.ON_OPEN,onOpen);
 pop.setWidth("200px");                                     
 box.setPopup(pop);
 pop.setParent(box);                    
}

CODE TO TEST I THINK IS A BUG.

<?xml version="1.0" encoding="UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?page id="pageID" language="xul/html" ?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" root="./win"?>
<?taglib uri="/WEB-INF/tld/web/core.dsp.tld" prefix="c" ?>
<window id="win">
<zscript><![CDATA[
   private void hysteria(Hbox box)
   {
       Popup pop = new Popup();
   pop.appendChild(new Label("Bon Jovi"));
   org.zkoss.zk.ui.event.EventListener  onOpen = new org.zkoss.zk.ui.event.EventListener(){public void onEvent(Event event){System.out.println("called");return;}};
   pop.addEventListener(Events.ON_OPEN,onOpen);
   pop.setWidth("200px");                                       
   box.setPopup(pop);
   pop.setParent(box);                      
   }
]]></zscript>
<hbox sclass="encargo-popup" onCreate='hysteria(self);'><label value="Acciones"/></hbox>                
</window>

zk popup menu EventListener onOpen fire twice

I have a Hbox like this which is attached to a Menu PopUp.

final Hbox box = ....................
final Popup pop = this.createPopUp(box);
final EventListener<Event> onOpen = new EventListener<Event>()
{
public void onEvent(final Event event)
    {
    popup.removeEventListener(Events.ON_OPEN,this);     
    event.stopPropagation();                    
    log.info("OnOpen");             
    popup.addEventListener(Events.ON_OPEN,this);
    return;
 }
 };
popup.addEventListener(Events.ON_OPEN,onOpen);
box.setPopup(pop);
pop.setParent(box);

That's ok i have set a onOpen event listener to my popup everything works like a expected the problem is when i click in the Hbox the onOpen event is firing twice i mean i can see 2 OnOpen message this is worring because i have some DB operations in that method my question is how avoid the eventListener onOpen only fired twice..

Another weird fact is the first time Hbox is clicked only one onOpen is call but from the second time the onopen method is called twice always.

My more specific code

ZUL.

<listcell>
<div align='center'>
   <hbox onCreate='myController.onCreateHBox(self);'>
    <label value="Actions"/>                                        
   </hbox>                              
</div>
</listcell>

In Java

public void onCreateHBox(final Hbox box)
{
 final Popup pop = new Popup();
 pop.appendChild(new Label("Bon Jovi"));
 final EventListener<Event> onOpen = new EventListener<Event>(){public void onEvent(final Event event){log.info("called"); return;}};
 pop.addEventListener(Events.ON_OPEN,onOpen);
 pop.setWidth("200px");                                     
 box.setPopup(pop);
 pop.setParent(box);                    
}

CODE TO TEST I THINK IS A BUG.

<?xml version="1.0" encoding="UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?page id="pageID" language="xul/html" ?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" root="./win"?>
<?taglib uri="/WEB-INF/tld/web/core.dsp.tld" prefix="c" ?>
<window id="win">
<zscript><![CDATA[
   private void hysteria(Hbox box)
   {
       Popup pop = new Popup();
   pop.appendChild(new Label("Bon Jovi"));
   org.zkoss.zk.ui.event.EventListener  onOpen = new org.zkoss.zk.ui.event.EventListener(){public void onEvent(Event event){System.out.println("called");return;}};
   pop.addEventListener(Events.ON_OPEN,onOpen);
   pop.setWidth("200px");                                       
   box.setPopup(pop);
   pop.setParent(box);                      
   }
]]></zscript>
<hbox sclass="encargo-popup" onCreate='hysteria(self);'><label value="Acciones"/></hbox>                
</window>
What i see and i dont understand and i think is a bug suppose you have a popup open and you change the browser window or pick another popup maybe windows popup and your zk popup closes that's ok but i see when my popup closes their ONOPEN event is called why is onOpen not on_close this is some confussing...

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