Results 1 to 9 of 9

Thread: [FIXED] [CLOSED] BaseEvent type is null

  1. #1
    Ext User
    Join Date
    Mar 2009
    Posts
    6
    Vote Rating
    0
      0  

    Default [FIXED] [CLOSED] BaseEvent type is null

    I have a listener for a tree and button where the listener is the same for both. I am trying to avoid inner classes so that I can do incremental debug updates in GWT. Doing the classic inline class override for a "Listener" creates an inner class which cause the VM to view the incremental update as a schema change and fails.

    For both a button and tree on a Events.Select listen the BaseEvent.source is null so you can't detect the source of the original event. My assumption is that this is a bug. I am using gxt-1.2.3

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    use component and not source. Also please read the javadocs for component event / button event etc.

  3. #3
    Ext User
    Join Date
    Mar 2009
    Posts
    6
    Vote Rating
    0
      0  

    Post Component

    Not sure if you followed my original post so here is some code

    public class Foo extends Window implements Listener{

    public Foo(){
    newProjectButton = new Button("New Project");
    newProjectButton.addListener(Events.Select, this);
    .... rest of code

    }

    public void handleEvent(BaseEvent te) {
    if(te.source == null){
    // this should not be null
    }
    }

    }


    If I check the instance of BaseEvent as a instanceof ButtonEvent then I can cast and get the be.button as the source of the event.

    The assumption is that BaseEvent.source should not be null in the base class.

    Thanks

    Scooter

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    The javadocs tell you that not all fields are set.

    Code:
    if(be instanceof ComponentEvent) {
      source = be.component
    }

  5. #5
    Ext User
    Join Date
    Mar 2009
    Posts
    6
    Vote Rating
    0
      0  

    Default source

    I understand the challenges associated with a base class and subclasses that are appropriate for the specific "Component" and the corresponding subclass event.

    In the case of BaseEvent the source should be a common or global attribute of all subclasses. If source can be null in BaseEvent and has only three attributes then source probably shouldn't be in BaseEvent. It doesn't make sense to have source as an object in BaseEvent and not have it set as the source of the event.

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    And i can only suggest you again to read the ajvadocs. It tell you what fields are set.

  7. #7
    Ext User
    Join Date
    Mar 2009
    Posts
    6
    Vote Rating
    0
      0  

    Default Response

    I can only reply that having Docs that explains bad design or a bug is ok but that doesn't excuse having code that can be improved or follow the original intent of a base class in the design.

    No need to reply!

  8. #8
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    We did a change that makes source filled everytime.

  9. #9
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    Fixed in SVN.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •