0

I have an abstract class extending Composite (AbstractWhiteBoard). Then I have a concrete class extending AbstractWhiteBoard. When I instantiate the concrete class and try to add it to the RootPanel, the program simply stops executing. There is no error or any output to direct me to a log file. I have no idea what is going wrong.

Here is my abstract class:

public abstract class AbstractWhiteBoard extends Composite {
     /*
      * FIELDS
      */
     protected HorizontalPanel WhiteBoardWrapperPanel;

     public AbstractWhiteBoard( ) {
          WhiteBoardWrapperPanel = new HorizontalPanel();
          WhiteBoardWrapperPanel.setStyleName("WhiteBoard-Wrapper");
          initWidget(WhiteBoardWrapperPanel);
     }

     /*
      * ABSTRACT PUBLIC METHODS
      */
     abstract public void addNotecard( Notecard nc );
     abstract public void addPostit( Postit postit );

     /*
      * ABSTRACT PROTECTED HELPER METHODS
      */
     abstract protected void registerDragDropControllers();
 }

And here is my concrete implementation class:

public class ConcreteWhiteBoard extends AbstractWhiteBoard {

/*
 * CONTSTRUCTORS
 */
public ConcreteWhiteBoard() {
    super();
}


/*
 * PUBLIC METHOD OVERRIDES
 */
@Override
public void addNotecard(Notecard nc) {
    // TODO Auto-generated method stub

}

@Override
public void addPostit(Postit postit) {
    // TODO Auto-generated method stub

}


/*
 * PRIVATE HELPER METHOD OVERRIDES
 */
@Override
protected void registerDragDropControllers() {
    // TODO Auto-generated method stub
}
}

So, what is happening, is I have this code:

AbstractWhiteBoard wb = new ConcreteWhiteBoard();
RootPanel.get().add(wb);
Window.alert("wb added!");

But after I add wb to the RootPanel, execution stops. The alert statement never even gets called. There is no error and I don't see anything in the log.

Is there something wrong with having an abstract class that extends Composite? Or is it something entirely different that I am just not seeing? any help is greatly appreciated!

2
  • Oh, I guess I may want to add that the last code snippet is taking place outside of my EntryPoint module. I don't think that matters though. Commented Nov 7, 2011 at 22:02
  • Also, the this inside the last code snippet was a typo. It isn't actually there. Commented Nov 7, 2011 at 22:04

2 Answers 2

1

take a look at the uncaught exception handler in gwt. if a runtime exception occurs it is called. Think of it as a global try catch around your code.

But if your code is inside your entrypoint on module load make sure to set the uncaught exception handler and call the next function within a timer (so that the uncaught exception handler is active.

For a quick example take a look here:

http://code.google.com/p/mgwt/source/browse/src/main/java/com/googlecode/mgwt/examples/showcase/client/ShowCaseEntryPoint.java?repo=showcase

In web mode you can turn on emulated stack (and get meaningful stacktraces). YOu need to add this to your gwt.xml file (only for debug purposes because it is quite slow):

<set-property name="compiler.emulatedStack" value="true" />

<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true" />
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true" />
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for the feed back, Daniel. I added in an uncaught exception handler and this is the error that it is reporting: <br/>class.com.google.gwt.core.client.JavaScriptException(TypeError): Unable to get value of the property 'a': object is null or undefined Unknown.si(StackTraceCreator.java:168) Unknown.Ph(StackTraceCreator.java:421) Unknown.zu(Exceptions.java:29) Unknown.Vd(AgileProject.java:57)
The bottom stack trace is on the line that I try to add the ConcreteWhiteBoard to the RootPanel.
Are you not developing in DevMode? That exception won't be much help as it is all just obfuscated javasctipt.
This means that you are producing a null pointer exception somewhere in your code. does this only happen in web mode or also in dev mode. if its only happens in web mode, enable emulated stack traces in web mode to see what is happening (you have to disable them afterwards, because they are really slow). I ve updated the answer to cover web mode exceptions
Are you using Chrome? There's a bug in the DevMode plugin for Chrome: code.google.com/p/google-web-toolkit/issues/detail?id=5778 Try in another browser to confirm.
0

So, this is one of those times that you feel like the most retarded developers of all time. What happened is that I was running several async calls all at the same time and I tried to refer to an object that was returned by one of those calls before it was actually created. Dunce cap on me, I got confused with async threads.

Major thanks to Daniel. Your input lead me straight to the problem!

1 Comment

glad i could help, maybe you want to reward me by accepting the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.