GWT FileUpload: Adding Widgets to a FormPanel

If you build your first GWT form, for example something like that:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<g:FormPanel ui:field="form"> 
<g:FileUpload ui:field="uploadField" name="file"/>
<g:SubmitButton ui:field="submitButton">Upload</g:SubmitButton>
</g:FormPanel>
</g:HTMLPanel>
</ui:UiBinder>

And your console keeps telling you during runtime something like this: “java.lang.IllegalStateException: SimplePanel can only contain one child widget”. Instead of writing a long page of explanations and complaints like I did before, it’s simply like that:

“Just put all your widgets in a panel (like HorizontalPanel) and add that panel to the FormPanel.” (Jake − cf. comment below)

Thanks Jake! 🙂

3 Replies to “GWT FileUpload: Adding Widgets to a FormPanel”

    1. Thanks for your comment Jake!

      You are completely right! For some reason, It did not come to my mind to put in the form panel another panel first. That’s it. I will update the post accordingly, however, there will not be much left afterwards. 😉

      Thanks again,
      Sven

Leave a Reply

Your email address will not be published. Required fields are marked *