How to wrap a “submit button” with GWT?

623 views
Skip to first unread message

Xybrek

unread,
Jan 30, 2012, 2:51:51 AM1/30/12
to Google-We...@googlegroups.com
I am getting an error when I try to wrap a submit button with GWT:

Caused by: java.lang.AssertionError: Child cannot be null
at com.google.gwt.dom.client.Node$.isOrHasChild$(Node.java:278)
at com.google.gwt.user.client.ui.Button.wrap(Button.java:55)
HTML Code:

<div style="display:none">
<form id="login_form" action="javascript:;">
<input id="username" type="text">
<input id="password" type="password">
<button type="button" id="submit" name="submit" value="Submit">
</form>
</div>
Java Code (GWT):

loginButton = Button.wrap(Document.get().getElementById("submit"));
Is there any way to wrap a submit button?

Thomas Broyer

unread,
Jan 30, 2012, 3:33:02 AM1/30/12
to google-we...@googlegroups.com, Google-We...@googlegroups.com


On Monday, January 30, 2012 8:51:51 AM UTC+1, Xybrek wrote:
I am getting an error when I try to wrap a submit button with GWT:

Caused by: java.lang.AssertionError: Child cannot be null
     at com.google.gwt.dom.client.Node$.isOrHasChild$(Node.java:278)
     at com.google.gwt.user.client.ui.Button.wrap(Button.java:55)


That means the argument to Button.wrap() is 'null' (debug 101: step into the code; it's open source, so read the source!), i.e. in your case Document.get().getElementById("submit") returns 'null'.

Xybrek

unread,
Jan 30, 2012, 10:13:06 PM1/30/12
to Google-We...@googlegroups.com
> --
> You received this message because you are subscribed to the Google
> Groups "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/kfpbwteUkHoJ.
> To post to this group, send email to
> google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.

Yes I debug it. And yes, I see that
Document.get().getElementById("submit") returns null. However, it should
not be null since there is a <button> in the HTML file that has that id.

Thomas Broyer

unread,
Jan 31, 2012, 7:13:34 AM1/31/12
to google-we...@googlegroups.com, Google-We...@googlegroups.com
Document.get().getElementById() simply maps to document.getElementById(), so you'll have to use your browser's debugging tools to debug it.

First, I'd try to change the ID of the button.
Reply all
Reply to author
Forward
0 new messages