Populating CellTable using ListDataProvider?

Skip to first unread message

Slava Imeshev

Sep 24, 2021, 7:44:10 PM9/24/21
to GWT Users
So, I'm following basic examples, and I just cannot get it to work. The populate() method below using ListDataProvider leaves the table empty. populateWorking() works. Any hints?

public class GapAnalysisListTable extends CellTable<GapAnalysisVO> {

public GapAnalysisListTable() {

// Create a data provider.
dataProvider = new ListDataProvider<>(GapAnalysisVO::getId);

// Connect the table to the data provider.

public void populate(final GapAnalysisVO[] gapAnalysisVOList) {

final List<GapAnalysisVO> list = dataProvider.getList();

public void populateWorks(final GapAnalysisVO[] gapAnalysisVOList) {


Slava Imeshev

Oct 18, 2021, 11:36:28 PM10/18/21
to GWT Users

Just following up on what turned to be my own blunder. Using ListDataProvider doesn't work when the CellTable is created using pageSize = 0. 

super(0, resources, keyProvider);

It still works when using setRowCount(); setRowData();.

So I fixed it for the time being by setting a meaningfully large pageSize.

Here is the question: would it make sense to add a bit more to the Javadoc for pageSize. Or maybe checking for 0 and throwing IllegalArgumentException?

Craig Mitchell

Oct 20, 2021, 10:15:59 PM10/20/21
to GWT Users
GWT does many great things.  Implementation of lists and tables wasn't one of them (IMHO).

If GWT 3 ever comes out.  It will be great to have separation of this stuff.

However, to answer your question, yes, it would make sense, I just don't know what the likelihood of a 2.9.1 release is.

Slava Imeshev

Oct 21, 2021, 12:32:24 AM10/21/21
to GWT Users
Hey, hey, hey,

I'm one of us Javascript-deaf. With GWT I'm back to my a screen-a-day in pure Java. Just loving it.

Still, would GWT team be accepting of some PRs to update Javadocs? Took me a day of Googling to figure out how to make use of custom widgets in UI Binder templates.


Thomas Broyer

Oct 21, 2021, 7:20:49 AM10/21/21
to GWT Users
Is this not enough? Buried too deep? Lacking examples and/or a step-by-step?

In order to use a set of widgets in a ui.xml template file, you need to tie their package to an XML namespace prefix. That’s what’s happening in this attribute of the root <ui:uibinder> element: xmlns:g='urn:import:com.google.gwt.user.client.ui'. This says that every class in the com.google.gwt.user.client.ui package can be used as an element with prefix g and a tag name matching its Java class name, like <g:ListBox>.

See how the g:ListBox element has a visibleItemCount='1' attribute? That becomes a call to ListBox#setVisibleItemCount(int). Every one of the widget’s methods that follow JavaBean-style conventions for setting a property can be used this way.

Slava Imeshev

Oct 21, 2021, 11:37:14 AM10/21/21
to GWT Users
Hi Tomas,

First, pls. let me thank you and the team for the amazing work on GWT.

As for the documentation, I'd say it's lacking an example for importing custom widgets  because the way some of use read the XML. Personally I just automatically skip over the xmls section because it contains "standard" GWT namespaces. 

I think the docs would benefit from explicitly stating

 "To import your own widget com.example.gwt.client.SampeTextField, use the xmlns to add a package with your own packages and then use the prefix in the body of the template. For example:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'

  <e:SampeTextField displaySize=10/>


Craig Mitchell

Oct 22, 2021, 1:38:17 AM10/22/21
to GWT Users
Just to clarify my comment.  I find it easier to use pure HTML + CSS then GWT's built in CellTable etc.

<table ui:field="myTable"></table>
@UiField TableElement myTable;
TableRowElement row = myTable.insertRow(...);

Then you can use all the fancy CSS styles, that others have written to make tables look pretty.  No need to mangle them into what GWT wants.

Adding GWT widgets into the table is a little annoying that you need to call onAttach to get their events to work, but that's a minor inconvience.

Anyhow, I wasn't suggesting writing any JavaScript.  :)

Also not saying don't use CellTable.  Maybe you have a massive amount of data, and all the fancy databinding will save you time in the long run.

Slava Imeshev

Oct 22, 2021, 12:09:40 PM10/22/21
to GWT Users

Yep. <table> makes sense for "show-and-forget" use pattern.

The challenge with <table> is that things become complicated when there is a need to receive and act on events on row selection/de-section, pagination, getting the entire data object out of the row etc. I tried that but discovered that I'm reinventing CellTable.

At any rate, the only snag I had with CellTable is unexpected behavior with pageSize set to 0. It would be great to have better Javadoc for that, or throwing IllegalArgumentException for 0 size.
Reply all
Reply to author
0 new messages