I’m tryin to debug an existing app with some sort of login page already designed. However, when I go to ‘Run as Java application’ in Eclipse I receive an error:
01:18:30.207 [ERROR] [pzflex_test] Unable to load module entry point class com.wai.pzflex.client.PZFlex_Test (see associated exception for details)
java.lang.AssertionError: null
at com.google.gwt.user.client.ui.TextBox.wrap(TextBox.java:63)
at com.wai.pzflex.client.PZFlex_Test.onModuleLoad(PZFlex_Test.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
Here is the code that I’m trying to debug using Eclipse.
public void onModuleLoad()
{
try
{
HTMLPanel panel = new HTMLPanel("<table align='center'><tr>" +
"<td colspan='2' style='font-weight:bold;'>Please enter your username and password:</td>" +
"</tr><tr><td>Username: </td><td><input type='text' id='loginuser'></td></tr>" +
"<tr><td>Password: </td><td><input type='password' id='loginpass'></td></tr>" +
"<tr><td colspan='2' align='right'><button id='loginbutton'>Login</button></td>" +
"</tr></table>");
//final - entity that cannot be changed later
final TextBox username = TextBox.wrap(panel.getElementById("loginuser"));
final TextBox pass = TextBox.wrap(panel.getElementById("loginpass"));
RootPanel.get("content").add(panel);
The application seems to runs up until the ‘final Textbox..’ line of code but when I press resume, I get the errors.
The odd thing is that I can do a GWT Compile and the login page seems to load fine. I don’t understand why this happens just when I go to debug it.
Again I am new to Java and the whole GWT/GAE so any advice would be greatly appreciated.
Look at what the failing assertion is:
(source: https://code.google.com/p/google-web-toolkit/source/browse/tags/2.5.0/user/src/com/google/gwt/user/client/ui/TextBox.java#61 )
This means you’d need to
RootPanel.get("content").add(panel);before youTextBox.wrap().Except that it won’t work either. It’ll fail later because the wrapped element is within a widget (the
HTMLPanel).What you need to do is remove the
<input>from the HTML string and add IDs to the<td>, build yourTextBoxandPasswordBoxlike regular widgets, and then useadd(Widget,String)to put them in the<td>s in theHTMLPanel.Depending on what you need to do, maybe you don’t need the
<input>s as widgets though, in which case, just usegetElementByIdon theHTMLPaneland possiblecast()the result to anInputElement.