View Full Version : [FIXED] [CLOSED] BaseEvent type is null

4 Mar 2009, 6:24 AM
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

4 Mar 2009, 6:28 AM
use component and not source. Also please read the javadocs for component event / button event etc.

4 Mar 2009, 6:53 AM
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.



4 Mar 2009, 6:55 AM
The javadocs tell you that not all fields are set.

if(be instanceof ComponentEvent) {
source = be.component

4 Mar 2009, 7:12 AM
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.

4 Mar 2009, 7:14 AM
And i can only suggest you again to read the ajvadocs. It tell you what fields are set.

4 Mar 2009, 7:24 AM
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!

4 Mar 2009, 9:01 AM
We did a change that makes source filled everytime.

1 Apr 2009, 4:44 AM
Fixed in SVN.