Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to get GWT DataGrid to work in UiBinder
    text
    copied!<p>I am trying to get the hang of UI Binder in GWT.</p> <p>So far, I have a basic application to display a DataGrid with some sample data, and it can be easily switched between traditional GWT and UIBinder. It works correctly in traditional GWT but not in UiBinder.</p> <p>Here's the main EntryPoint class:</p> <pre><code>public class Main implements EntryPoint { public void onModuleLoad() { uiBinder(); //call either uiBinder() or gwt() here } /* Use UiBinder to display grid */ public void uiBinder() { HelloWorld hello = new HelloWorld(); RootPanel.get("myid").add(hello); } /* Use traditional GWT to display grid */ public void gwt() { DataGrid&lt;Contact&gt; grid = new DataGrid&lt;Contact&gt;(); GridInitializer.init(grid); RootLayoutPanel.get().add(grid); } } </code></pre> <p>Here's the HelloWorld.java used by UiBinder:</p> <pre><code>public class HelloWorld extends Composite { interface MyUiBinder extends UiBinder&lt;Widget, HelloWorld&gt; {} private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); @UiField DataGrid&lt;Contact&gt; grid; public HelloWorld() { GridInitializer.init(grid); initWidget(uiBinder.createAndBindUi(this)); } } </code></pre> <p>The GridInitializer class sets up grid columns and sample data. I there's nothing wrong there because it renders correctly if I use traditional GWT.</p> <p>Here is HelloWorld.ui.xml:</p> <pre><code>&lt;!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"&gt; &lt;ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:c="urn:import:com.google.gwt.user.cellview.client"&gt; &lt;g:DockLayoutPanel unit="EM"&gt; &lt;g:center&gt; &lt;c:DataGrid ui:field='grid' /&gt; &lt;/g:center&gt; &lt;/g:DockLayoutPanel&gt; &lt;/ui:UiBinder&gt; </code></pre> <p>If I use UI Binder, nothing displays at all. I'm at a loss. Any suggestions?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload