1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    67
    Vote Rating
    0
    treblereel is on a distinguished road

      0  

    Question Unanswered: Somethings wrong with a custom event

    Unanswered: Somethings wrong with a custom event


    Hi all, plz help me to find out whats wrong with my custome event SimpleEvents.AlertEvent, coz nothing happens

    Here is a test EntryPoint:


    PHP Code:
    public class EventsTest implements EntryPoint {
        private 
    SimpleWindow simpleWindow3;
        private 
    SimpleWindow simpleWindow2;
        private 
    Button btn;
        private 
    Observable Observable;
        
        
        public 
    void onModuleLoad() {
            
    RootPanel rootPanel RootPanel.get();
       
            
            
    SimpleWindow simpleWindow = new SimpleWindow();
            
            
    btn = new Button("Process");
            
    btn.addListener(Events.Select,new Listener<ButtonEvent>() {
                 @
    Override public void handleEvent(ButtonEvent be) {


    // Here i am trying to fire event SimpleEvents.AlertEvent

                     
    EventBus.getInstance().fireEvent(SimpleEvents.AlertEvent);
      
                   }  
                });
            
            
        
            
    simpleWindow.addButton(btn);
            
            
    rootPanel.add(simpleWindow);
            
            
            
    simpleWindow2 = new SimpleWindow("First");

    // i have add listener SimpleEvents.AlertEvent to catch Event from above

            
    simpleWindow2.addListener(SimpleEvents.AlertEvent,new Listener<BaseEvent>(){
                @
    Override    public void handleEvent(BaseEvent be) {
                    
    System.out.println("Event First");
                    
    simpleWindow2.setHeading("changed ");
                }
                
            });
            
            
    rootPanel.add(simpleWindow2);
       
        }



    EventBus:

    PHP Code:

    public class EventBus  extends BaseObservable{
        private static 
    EventBus instance;
        
        
        protected 
    EventBus(){
            
    super();
            
        }
        
        
        public static 
    EventBus getInstance(){
            
    instance = (instance == null ? (instance = new EventBus()) :
                    
    instance);
            return 
    instance;
            
        }


    SimpleEvents:

    PHP Code:
    public class SimpleEvents {
        
        public static final 
    EventType AlertEvent = new EventType(); 


    Thanks for any help

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,717
    Vote Rating
    107
    Answers
    60
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    What is SimpleWindow? Is simpleevent listening to the EventBus? Because else you add the listener to the wrong Observable.

Tags for this Thread