hello everyone, i am using the second milestone of gwt 2.1 mostly because of the new list view related classes (e.g. ListViewAdapter, SimplePager, PagingListView, SingleSelectionModel, etc.). based on these new classes i implemented my own ListView class. i retrieve a couple of dto objects from the server side and insert them into the list view using ListViewAdapter.setList and CellTable.setDataSize. i also found the following example that shows pagination should work like charm in gwt 2.1 m2: see http://gwt-bikeshed.appspot.com/Scaffold.html and source here http://google-web-toolkit.googlecode.com/svn/trunk/bikeshed/
unfortunately, in my own ListView class that is using all the new gwt classes the pagination does not work at all (see code here lines 293-324 of http://code.google.com/p/honeycrm/source/browse/branches/honeycrm_r134_gwt2.1m2/src/honeycrm/client/view/ListView.java). the values are not inserted into the listview and the item count (page count) is not properly updated (or set at all). everytime the pager receives a onRangeOrSizeChanged event I call refreshPage(newPage) if the page number really has changed. this does an RPC call retrieving the values from the server and inserting them by calling refreshListViewValues(). this is how it looks like: protected void initListView() { pager = new SimplePager<Dto>(ct = new CellTable<Dto>(), TextLocation.CENTER) { @Override public void onRangeOrSizeChanged(final PagingListView<Dto> listView) { super.onRangeOrSizeChanged(listView); /** * only do something if items have already been loaded */ if (itemsHaveBeenLoadedOnce) { final int newPage = 1 + listView.getPageStart() / listView.getPageSize(); final boolean changedPage = newPage != currentPage; if (changedPage) { refreshPage(newPage); // this does a RPC calling refreshListViewValues on sucess } } }; }; .... } protected void refreshListViewValues(ListQueryResult result) { if (!itemsHaveBeenLoadedOnce) { initListView(); itemsHaveBeenLoadedOnce = true; } ArrayList<Dto> values = new ArrayList<Dto>(); for (final Dto dto : result.getResults()) { values.add(dto); } ct.setDataSize(result.getItemCount(), true); // ct is the cell table instance // give the ListViewAdapter our data lva.setList(values); lva.refresh(); } does anyone have a very simple working example explaining the principle? i do not really understand the bikeshed code. i "learned" the use of the new API from here http://stackoverflow.com/questions/2891803/how-to-use-gwt-2-1-data-presentation-widgets. currently i do not understand how to put all those new classes together in a small, concise and working example. kind regards, ingo -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
