Note that there are some explanatory texts on larger screens.

plurals
  1. POGWT UiBinder CellTable is not rendered with AsyncDataProvider
    primarykey
    data
    text
    <p>I want to have on my page created with <code>UIBinder</code> a <code>CellTable</code> with data, received from server. I think I dont quite understand the logic of <code>UiBinder</code>. What steps should I do before calling <code>initWidget()</code>, and what I shouldn't ? <br> When I remove the call to <code>configureDataProvider()</code> the table appears, but it is empty, with progress bar running. When I include <code>configureDataProvider()</code>, the table is not rendered at all.</p> <p><strong>Please can you explain what is happening here?</strong></p> <pre class="lang-java prettyprint-override"><code>@UiField(provided = true) VerticalPanel tableSelection; @UiField(provided = true) Anchor productTableAnchor; @UiField(provided = true) Anchor ordersTableAnchor; @UiField(provided = true) Anchor staffTableAnchor; List&lt;ProductDTO&gt; products; @UiField(provided = true) CellTable&lt;ProductDTO&gt; productTable; @UiField(provided = true) SimplePager pager; public TableSelectionWidget() { SimplePager.Resources pagerResources = GWT .create(SimplePager.Resources.class); tableSelection = new VerticalPanel(); productTableAnchor = new Anchor(); ordersTableAnchor = new Anchor(); staffTableAnchor = new Anchor(); productTable = new CellTable&lt;ProductDTO&gt;(); productTable.setPageSize(10); configureTable(); pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(productTable); initWidget(uiBinder.createAndBindUi(this)); } private void configureTable() { Column&lt;ProductDTO, String&gt; nameColumn = new Column&lt;ProductDTO, String&gt;( new TextCell()) { @Override public String getValue(ProductDTO object) { return object.getName(); } }; Column&lt;ProductDTO, String&gt; priceColumn = new Column&lt;ProductDTO, String&gt;( new TextCell()) { @Override public String getValue(ProductDTO object) { return object.getPrice().toString(); } }; Column&lt;ProductDTO, String&gt; quantityColumn = new Column&lt;ProductDTO, String&gt;( new TextCell()) { @Override public String getValue(ProductDTO object) { return String.valueOf(object.getQuantity()); } }; productTable.addColumn(nameColumn, "Name"); productTable.addColumn(priceColumn, "Price"); productTable.addColumn(quantityColumn, "Qty"); configureDataProvider(); } private void configureDataProvider() { AsyncDataProvider&lt;ProductDTO&gt; provider = new AsyncDataProvider&lt;ProductDTO&gt;() { @Override protected void onRangeChanged(HasData&lt;ProductDTO&gt; display) { final int start = display.getVisibleRange().getStart(); int length = display.getVisibleRange().getLength(); AsyncCallback&lt;List&lt;ProductDTO&gt;&gt; callback = new AsyncCallback&lt;List&lt;ProductDTO&gt;&gt;() { public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } public void onSuccess(List&lt;ProductDTO&gt; result) { products = result; updateRowData(start, result); } }; productService.getAllProducts(callback); } }; provider.addDataDisplay(productTable); provider.updateRowCount(products.size(), true); } </code></pre> <p>EDIT Added 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" xmlns:ct="urn:import:com.ooo1sk.client.widgets"&gt; &lt;ui:style&gt; &lt;/ui:style&gt; &lt;g:HTMLPanel&gt; &lt;g:VerticalPanel styleName="" ui:field="tableSelection"&gt; &lt;g:Anchor ui:field="ordersTableAnchor" text="Orders"&gt;&lt;/g:Anchor&gt; &lt;g:Anchor ui:field="productTableAnchor" text="Product"&gt;&lt;/g:Anchor&gt; &lt;g:Anchor ui:field="staffTableAnchor" text="Staff"&gt;&lt;/g:Anchor&gt; &lt;/g:VerticalPanel&gt; &lt;g:HTMLPanel&gt; &lt;table cellspacing='0' cellpadding='0' style='width:100%;'&gt; &lt;tr&gt; &lt;td valign='top'&gt; &lt;c:CellTable addStyleNames='infoTable' pageSize='15' ui:field='productTable' /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align='center'&gt; &lt;c:SimplePager ui:field='pager' /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/g:HTMLPanel&gt; &lt;/g:HTMLPanel&gt; &lt;/ui:UiBinder&gt; </code></pre> <p>UPD: after changes it works, but keeps showing me only the first 15 rows, however Pager shows all 91 rows and changes number after clicking.</p> <pre><code> private void configureDataProvider() { AsyncDataProvider&lt;ProductDTO&gt; provider = new AsyncDataProvider&lt;ProductDTO&gt;() { @Override protected void onRangeChanged(HasData&lt;ProductDTO&gt; display) { final int start = display.getVisibleRange().getStart(); final int length = display.getVisibleRange().getLength(); productService .getAllProducts(new AsyncCallback&lt;List&lt;ProductDTO&gt;&gt;() { public void onSuccess(List&lt;ProductDTO&gt; result) { label.setText("start " + start + " " + "resultsize " + result.size() + " " + "length " + length); products = result; updateRowCount(result.size(), true); updateRowData(start, result); } public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } }); } }; provider.addDataDisplay(productTable); } </code></pre> <p>Ok, playing with numbers fixed the issue. in <code>updateRowData(start, result);</code> I changed <code>start</code> to <code>0</code> and it works fine now. Still, I would greatly appreciate any comment of experts on this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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