gwt - how to stop firing unrelated event of event bus -


my problem how stop firing unrelated event of event bus. got this solution dialog box. not work in case of 1 instance initialize , try create new instance of same class.

just example: below scroll panel has handler initialized. used document preview.

 class testscroll extends scrollpanel       {          public testscroll(){           }          implemented onload()           {              // eventbus.addhandler code here.            //here preview related code           }              unload() method             {                //eventbus remove handler code             }       } 

this preview has data contains links open different preview same class , different data structure, problem onunload ( which contains code of remove handler) event not load , because other panel opened. not mean previous panel unload. in case, twice event handler registered. when 1 event fired other event fired.

due that, preview 1 data shows properly, after preview2 opened , when close it, find preview1=preview2.

so how can handle such situation?

as per no of instance created each event fired. have check unique document id if condition in event itself. there other ways stop unrelated event firing?

edit:

public class gwteventbus implements entrypoint {    int i=0;   @override   public void onmoduleload() {    testapp panel=new testapp();     button button=new button("test event");    button.addclickhandler(new clickhandler() {     @override    public void onclick(clickevent event) {         testapp panel=new testapp();         int j=i;         new apputils().event_bus.fireeventfromsource(new authenticationevent(),""+(j));         i++;     }    });    panel.add(button);    rootpanel.get().add(panel);    }         } public class apputils {     public static eventbus event_bus = gwt.create(simpleeventbus.class);  }  public class testapp extends verticalpanel{   string teststring="";    public testapp( ) {     apputils.event_bus.addhandler(authenticationevent.type, new authenticationeventhandler()     {      @override      public void onauthenticationchanged(authenticationevent authenticationevent) {         system.out.println("helloworld"+authenticationevent.getsource());     }   });    }   } 

these wild guesses it's difficult answer without code , clear description.

i'm guessing have 1 eventbus panels. when register handler registered 1 eventbus. in case fire event 1 of panels eventbus panels receive event.

to fix can either create new eventbus per panel or check fired event event.getsource().

if doesn't make sense reusing variable or use static variable should new instance or none static variable.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -