Scrolling CellList sample?

2,966 views
Skip to first unread message

Jim Douglas

unread,
Jun 10, 2011, 2:57:55 PM6/10/11
to Google Web Toolkit
I thought it would be a trivial matter to build a scrolling CellList
like the one in the showcase:

http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList

But I need to work with hand-coded GWT Widgets, and that sample is
based on UiBinder. Can anyone point me to a sample like the one in
the showcase (a large scrolling list) that does not use UiBinder? The
documentation isn't helpful; it's all based on trivial samples like
days-of-the-week that don't require scrolling.

Qian Qiao

unread,
Jun 10, 2011, 8:26:06 PM6/10/11
to google-we...@googlegroups.com

The idea's the same regardless of the usage of uibinder isn't it? the
basic idea is to put the celllist inside a scrollpanel, and then
listen to scroll events on the scrollpanel, once you reach the bottom,
load more data.

-- Joe

Jim Douglas

unread,
Jun 10, 2011, 8:54:34 PM6/10/11
to Google Web Toolkit
Thanks for the response, Joe.

I'm sure the general idea is the same, but the UiBinder stuff is
gibberish to me; translating UiBinder code to traditional code is
making my head hurt.

I *think* I copied all of the relevant pieces out of the sample, but
I'm clearly missing something. I get a page of items, but the
ScrollPanel doesn't appear to be working. Does anything in this jump
out at you as obviously wrong?

package com.sample.client;

import java.util.Arrays;
import java.util.List;

import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ScrollEvent;
import com.google.gwt.event.dom.client.ScrollHandler;
import com.google.gwt.user.cellview.client.AbstractPager;
import com.google.gwt.user.cellview.client.CellList;
import
com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy.KeyboardPagingPolicy;
import
com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.HasRows;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SingleSelectionModel;

public class Sample implements EntryPoint
{
private static final List<String> LIST = Arrays.asList(getList());

public void onModuleLoad()
{
final Label message = new Label();

CellList<String> cellList = new CellList<String>(new
TextCell());

cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);

cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);

final SingleSelectionModel<String> selectionModel = new
SingleSelectionModel<String>();
cellList.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new
SelectionChangeEvent.Handler()
{
public void onSelectionChange(SelectionChangeEvent
event)
{
String selected =
selectionModel.getSelectedObject();
message.setText(selected == null ? "" :
selected);
}
});

cellList.setPageSize(20);
cellList.setRowCount(LIST.size(), true);
cellList.setRowData(0, LIST);

ScrollingPager pager = new ScrollingPager();
pager.setDisplay(cellList);

RootPanel.get("list").add(pager);
RootPanel.get("message").add(message);
}

/**
* A scrolling pager that automatically increases the range every
time the
* scroll bar reaches the bottom.
*/
public class ScrollingPager extends AbstractPager
{
private int incrementSize = 20;
private int lastScrollPos = 0;
private final ScrollPanel scrollable = new ScrollPanel();

public ScrollingPager()
{
initWidget(scrollable);
scrollable.setPixelSize(250, 350);
scrollable.getElement().getStyle().setBorderWidth(1,
Style.Unit.PX);
scrollable.getElement().getStyle().setBorderColor("red");
scrollable.getElement().setTabIndex(-1);

// Handle scroll events.
scrollable.addScrollHandler(new ScrollHandler()
{
public void onScroll(ScrollEvent p_event)
{
// If scrolling up, ignore the event.
int oldScrollPos = lastScrollPos;
lastScrollPos =
scrollable.getVerticalScrollPosition();
if (oldScrollPos >= lastScrollPos)
{
return;
}
HasRows display = getDisplay();
if (display == null)
{
return;
}
int maxScrollTop =
scrollable.getWidget().getOffsetHeight()
- scrollable.getOffsetHeight();
if (lastScrollPos >= maxScrollTop)
{
// We are near the end, so increase the page
size.
int newPageSize =
Math.min(display.getVisibleRange()
.getLength()
+ incrementSize,
display.getRowCount());
display.setVisibleRange(0, newPageSize);
}
}
});
}

public int getIncrementSize()
{
return incrementSize;
}

@Override
public void setDisplay(HasRows display)
{
assert display instanceof Widget : "display must extend
Widget";
scrollable.setWidget((Widget)display);
super.setDisplay(display);
}

public void setIncrementSize(int incrementSize)
{
this.incrementSize = incrementSize;
}

@Override
protected void onRangeOrRowCountChanged()
{
}
}

private static String[] getList()
{
return new String[] { "ABBOTT", "ACEVEDO", "ACOSTA", "ADAMS",
"ADKINS",
"AGUILAR", "AGUIRRE", "ALEXANDER", "ALI", "ALLEN",
"ALLISON",
"ALVARADO", "ALVAREZ", "ANDERSEN", "ANDERSON",
"ANDRADE",
"ANDREWS", "ANTHONY", "ARCHER", "ARELLANO", "ARIAS",
"ARMSTRONG", "ARNOLD", "ARROYO", "ASHLEY", "ATKINS",
"ATKINSON", "AUSTIN", "AVERY", "AVILA", "AYALA",
"AYERS",
"BAILEY", "BAIRD", "BAKER", "BALDWIN", "BALL",
"BALLARD",
"BANKS", "BARAJAS", "BARBER", "BARKER", "BARNES",
"BARNETT",
"BARR", "BARRERA", "BARRETT", "BARRON", "BARRY",
"BARTLETT",
"BARTON", "BASS", "BATES", "BAUER", "BAUTISTA",
"BAXTER",
"BEAN", "BEARD", "BEASLEY", "BECK", "BECKER", "BELL",
"BELTRAN", "BENDER", "BENITEZ", "BENJAMIN", "BENNETT",
"BENSON", "BENTLEY", "BENTON", "BERG", "BERGER",
"BERNARD",
"BERRY", "BEST", "BIRD", "BISHOP", "BLACK",
"BLACKBURN",
"BLACKWELL", "BLAIR", "BLAKE", "BLANCHARD",
"BLANKENSHIP",
"BLEVINS", "BOLTON", "BOND", "BONILLA", "BOOKER",
"BOONE",
"BOOTH", "BOWEN", "BOWERS", "BOWMAN", "BOYD", "BOYER",
"BOYLE",
"BRADFORD", "BRADLEY", "BRADSHAW", "BRADY", "BRANCH",
"BRANDT",
"BRAUN", "BRAY", "BRENNAN", "BREWER", "BRIDGES",
"BRIGGS",
"BRIGHT", "BROCK", "BROOKS", "BROWN", "BROWNING",
"BRUCE",
"BRYAN", "BRYANT", "BUCHANAN", "BUCK", "BUCKLEY",
"BULLOCK",
"BURCH", "BURGESS", "BURKE", "BURNETT", "BURNS",
"BURTON",
"BUSH", "BUTLER", "BYRD", "CABRERA", "CAIN",
"CALDERON",
"CALDWELL", "CALHOUN", "CALLAHAN", "CAMACHO",
"CAMERON",
"CAMPBELL", "CAMPOS", "CANNON", "CANTRELL", "CANTU",
"CARDENAS", "CAREY", "CARLSON", "CARNEY", "CARPENTER",
"CARR",
"CARRILLO", "CARROLL", "CARSON", "CARTER", "CASE",
"CASEY",
"CASTANEDA", "CASTILLO", "CASTRO", "CERVANTES",
"CHAMBERS",
"CHAN", "CHANDLER", "CHANEY", "CHANG", "CHAPMAN",
"CHARLES",
"CHASE", "CHAVEZ", "CHEN", "CHERRY", "CHOI",
"CHRISTENSEN",
"CHRISTIAN", "CHUNG", "CHURCH", "CISNEROS", "CLARK",
"CLARKE",
"CLAY", "CLAYTON", "CLEMENTS", "CLINE", "COBB",
"COCHRAN",
"COFFEY", "COHEN", "COLE", "COLEMAN", "COLLIER",
"COLLINS",
"COLON", "COMBS", "COMPTON", "CONLEY", "CONNER",
"CONRAD",
"CONTRERAS", "CONWAY", "COOK", "COOKE", "COOLEY",
"COOPER",
"COPELAND", "CORDOVA", "CORTEZ", "COSTA", "COWAN",
"COX",
"CRAIG", "CRANE", "CRAWFORD", "CROSBY", "CROSS",
"CRUZ",
"CUEVAS", "CUMMINGS", "CUNNINGHAM", "CURRY", "CURTIS",
"DALTON", "DANIEL", "DANIELS", "DAUGHERTY",
"DAVENPORT",
"DAVID", "DAVIDSON", "DAVIES", "DAVILA", "DAVIS",
"DAWSON",
"DAY", "DEAN", "DECKER", "DELACRUZ", "DELEON",
"DELGADO",
"DENNIS", "DIAZ", "DICKERSON", "DICKSON", "DILLON",
"DIXON",
"DODSON", "DOMINGUEZ", "DONALDSON", "DONOVAN",
"DORSEY",
"DOUGHERTY", "DOUGLAS", "DOWNS", "DOYLE", "DRAKE",
"DUARTE",
"DUDLEY", "DUFFY", "DUKE", "DUNCAN", "DUNLAP", "DUNN",
"DURAN",
"DURHAM", "DYER", "EATON", "EDWARDS", "ELLIOTT",
"ELLIS",
"ELLISON", "ENGLISH", "ERICKSON", "ESCOBAR",
"ESPARZA",
"ESPINOZA", "ESTES", "ESTRADA", "EVANS", "EVERETT",
"EWING",
"FARLEY", "FARMER", "FARRELL", "FAULKNER", "FERGUSON",
"FERNANDEZ", "FERRELL", "FIELDS", "FIGUEROA",
"FINLEY",
"FISCHER", "FISHER", "FITZGERALD", "FITZPATRICK",
"FLEMING",
"FLETCHER", "FLORES", "FLOWERS", "FLOYD", "FLYNN",
"FOLEY",
"FORBES", "FORD", "FOSTER", "FOWLER", "FOX",
"FRANCIS",
"FRANCO", "FRANK", "FRANKLIN", "FRAZIER", "FREDERICK",
"FREEMAN", "FRENCH", "FREY", "FRIEDMAN", "FRITZ",
"FROST",
"FRY", "FRYE", "FUENTES", "FULLER", "GAINES",
"GALLAGHER",
"GALLEGOS", "GALLOWAY", "GALVAN", "GAMBLE", "GARCIA",
"GARDNER", "GARNER", "GARRETT", "GARRISON", "GARZA",
"GATES",
"GAY", "GENTRY", "GEORGE", "GIBBS", "GIBSON",
"GILBERT",
"GILES", "GILL", "GILLESPIE", "GILMORE", "GLASS",
"GLENN",
"GLOVER", "GOLDEN", "GOMEZ", "GONZALES", "GONZALEZ",
"GOOD",
"GOODMAN", "GOODWIN", "GORDON", "GOULD", "GRAHAM",
"GRANT",
"GRAVES", "GRAY", "GREEN", "GREENE", "GREER",
"GREGORY",
"GRIFFIN", "GRIFFITH", "GRIMES", "GROSS", "GUERRA",
"GUERRERO",
"GUTIERREZ", "GUZMAN", "HAAS", "HAHN", "HALE",
"HALEY", "HALL",
"HAMILTON", "HAMMOND", "HAMPTON", "HANCOCK", "HANEY",
"HANNA",
"HANSEN", "HANSON", "HARDIN", "HARDING", "HARDY",
"HARMON",
"HARPER", "HARRELL", "HARRINGTON", "HARRIS",
"HARRISON",
"HART", "HARTMAN", "HARVEY", "HATFIELD", "HAWKINS",
"HAYDEN",
"HAYES", "HAYNES", "HAYS", "HEATH", "HEBERT",
"HENDERSON",
"HENDRICKS", "HENDRIX", "HENRY", "HENSLEY", "HENSON",
"HERMAN",
"HERNANDEZ", "HERRERA", "HERRING", "HESS", "HESTER",
"HICKMAN",
"HICKS", "HIGGINS", "HILL", "HINES", "HINTON", "HO",
"HOBBS",
"HODGE", "HODGES", "HOFFMAN", "HOGAN", "HOLDEN",
"HOLDER",
"HOLLAND", "HOLLOWAY", "HOLMES", "HOLT", "HOOD",
"HOOPER",
"HOOVER", "HOPKINS", "HORN", "HORNE", "HORTON",
"HOUSE",
"HOUSTON", "HOWARD", "HOWE", "HOWELL", "HUANG",
"HUBBARD",
"HUBER", "HUDSON", "HUERTA", "HUFF", "HUFFMAN",
"HUGHES",
"HULL", "HUMPHREY", "HUNT", "HUNTER", "HURLEY",
"HURST",
"HUTCHINSON", "HUYNH", "IBARRA", "INGRAM", "IRWIN",
"JACKSON",
"JACOBS", "JACOBSON", "JAMES", "JARVIS", "JEFFERSON",
"JENKINS", "JENNINGS", "JENSEN", "JIMENEZ", "JOHNS",
"JOHNSON",
"JOHNSTON", "JONES", "JORDAN", "JOSEPH", "JOYCE",
"JUAREZ",
"KAISER", "KANE", "KAUFMAN", "KEITH", "KELLER",
"KELLEY",
"KELLY", "KEMP", "KENNEDY", "KENT", "KERR", "KEY",
"KHAN",
"KIDD", "KIM", "KING", "KIRBY", "KIRK", "KLEIN",
"KLINE",
"KNAPP", "KNIGHT", "KNOX", "KOCH", "KRAMER", "KRAUSE",
"KRUEGER", "LAM", "LAMB", "LAMBERT", "LANDRY", "LANE",
"LANG",
"LARA", "LARSEN", "LARSON", "LAWRENCE", "LAWSON",
"LE",
"LEACH", "LEBLANC", "LEE", "LEON", "LEONARD",
"LESTER",
"LEVINE", "LEVY", "LEWIS", "LI", "LIN", "LINDSEY",
"LITTLE",
"LIU", "LIVINGSTON", "LLOYD", "LOGAN", "LONG",
"LOPEZ", "LOVE",
"LOWE", "LOWERY", "LOZANO", "LUCAS", "LUCERO", "LUNA",
"LUTZ",
"LYNCH", "LYNN", "LYONS", "MACDONALD", "MACIAS",
"MACK",
"MADDEN", "MADDOX", "MAHONEY", "MALDONADO", "MALONE",
"MANN",
"MANNING", "MARKS", "MARQUEZ", "MARSH", "MARSHALL",
"MARTIN",
"MARTINEZ", "MASON", "MASSEY", "MATA", "MATHEWS",
"MATHIS",
"MATTHEWS", "MAXWELL", "MAY", "MAYER", "MAYNARD",
"MAYO",
"MAYS", "MCBRIDE", "MCCALL", "MCCANN", "MCCARTHY",
"MCCARTY",
"MCCLAIN", "MCCLURE", "MCCONNELL", "MCCORMICK",
"MCCOY",
"MCCULLOUGH", "MCDANIEL", "MCDONALD", "MCDOWELL",
"MCFARLAND",
"MCGEE", "MCGRATH", "MCGUIRE", "MCINTOSH", "MCINTYRE",
"MCKAY",
"MCKEE", "MCKENZIE", "MCKINNEY", "MCKNIGHT",
"MCLAUGHLIN",
"MCLEAN", "MCMAHON", "MCMILLAN", "MCNEIL",
"MCPHERSON",
"MEADOWS", "MEDINA", "MEJIA", "MELENDEZ", "MELTON",
"MENDEZ",
"MENDOZA", "MERCADO", "MERCER", "MERRITT", "MEYER",
"MEYERS",
"MEZA", "MICHAEL", "MIDDLETON", "MILES", "MILLER",
"MILLS",
"MIRANDA", "MITCHELL", "MOLINA", "MONROE", "MONTES",
"MONTGOMERY", "MONTOYA", "MOODY", "MOON", "MOONEY",
"MOORE",
"MORA", "MORALES", "MORAN", "MORENO", "MORGAN",
"MORRIS",
"MORRISON", "MORROW", "MORSE", "MORTON", "MOSES",
"MOSLEY",
"MOSS", "MOYER", "MUELLER", "MULLEN", "MULLINS",
"MUNOZ",
"MURILLO", "MURPHY", "MURRAY", "MYERS", "NASH",
"NAVARRO",
"NEAL", "NELSON", "NEWMAN", "NEWTON", "NGUYEN",
"NICHOLS",
"NICHOLSON", "NIELSEN", "NIXON", "NOBLE", "NOLAN",
"NORMAN",
"NORRIS", "NORTON", "NOVAK", "NUNEZ", "OBRIEN",
"OCHOA",
"OCONNELL", "OCONNOR", "ODOM", "ODONNELL", "OLIVER",
"OLSEN",
"OLSON", "ONEAL", "ONEILL", "OROZCO", "ORR", "ORTEGA",
"ORTIZ",
"OSBORN", "OSBORNE", "OWEN", "OWENS", "PACE",
"PACHECO",
"PADILLA", "PAGE", "PALMER", "PARK", "PARKER",
"PARKS",
"PARRISH", "PARSONS", "PATEL", "PATRICK", "PATTERSON",
"PATTON", "PAUL", "PAYNE", "PEARSON", "PECK", "PENA",
"PENNINGTON", "PEREZ", "PERKINS", "PERRY", "PETERS",
"PETERSEN", "PETERSON", "PETTY", "PHAM", "PHELPS",
"PHILLIPS",
"PIERCE", "PINEDA", "PITTMAN", "PITTS", "POLLARD",
"PONCE",
"POOLE", "POPE", "PORTER", "POTTER", "POTTS",
"POWELL",
"POWERS", "PRATT", "PRESTON", "PRICE", "PRINCE",
"PROCTOR",
"PRUITT", "PUGH", "QUINN", "RAMIREZ", "RAMOS",
"RAMSEY",
"RANDALL", "RANDOLPH", "RANGEL", "RASMUSSEN", "RAY",
"RAYMOND",
"REED", "REESE", "REEVES", "REID", "REILLY", "REYES",
"REYNOLDS", "RHODES", "RICE", "RICH", "RICHARD",
"RICHARDS",
"RICHARDSON", "RICHMOND", "RIDDLE", "RIGGS", "RILEY",
"RIOS",
"RITTER", "RIVAS", "RIVERA", "RIVERS", "ROACH",
"ROBBINS",
"ROBERSON", "ROBERTS", "ROBERTSON", "ROBINSON",
"ROBLES",
"ROCHA", "RODGERS", "RODRIGUEZ", "ROGERS", "ROJAS",
"ROLLINS",
"ROMAN", "ROMERO", "ROSALES", "ROSARIO", "ROSE",
"ROSS",
"ROTH", "ROWE", "ROWLAND", "ROY", "RUBIO", "RUIZ",
"RUSH",
"RUSSELL", "RUSSO", "RYAN", "SALAS", "SALAZAR",
"SALINAS",
"SAMPSON", "SANCHEZ", "SANDERS", "SANDOVAL",
"SANFORD",
"SANTANA", "SANTIAGO", "SANTOS", "SAUNDERS", "SAVAGE",
"SAWYER", "SCHAEFER", "SCHMIDT", "SCHMITT",
"SCHNEIDER",
"SCHROEDER", "SCHULTZ", "SCHWARTZ", "SCOTT",
"SELLERS",
"SERRANO", "SEXTON", "SHAFFER", "SHAH", "SHANNON",
"SHARP",
"SHAW", "SHEA", "SHELTON", "SHEPARD", "SHEPHERD",
"SHEPPARD",
"SHERMAN", "SHIELDS", "SHORT", "SILVA", "SIMMONS",
"SIMON",
"SIMPSON", "SIMS", "SINGH", "SINGLETON", "SKINNER",
"SLOAN",
"SMALL", "SMITH", "SNOW", "SNYDER", "SOLIS",
"SOLOMON", "SOSA",
"SOTO", "SPARKS", "SPEARS", "SPENCE", "SPENCER",
"STAFFORD",
"STANLEY", "STANTON", "STARK", "STEELE", "STEIN",
"STEPHENS",
"STEPHENSON", "STEVENS", "STEVENSON", "STEWART",
"STOKES",
"STONE", "STOUT", "STRICKLAND", "STRONG", "STUART",
"SUAREZ",
"SULLIVAN", "SUMMERS", "SUTTON", "SWANSON", "SWEENEY",
"TANNER", "TAPIA", "TATE", "TAYLOR", "TERRELL",
"TERRY",
"THOMAS", "THOMPSON", "THORNTON", "TODD", "TORRES",
"TOWNSEND",
"TRAN", "TRAVIS", "TREVINO", "TRUJILLO", "TUCKER",
"TURNER",
"TYLER", "UNDERWOOD", "VALDEZ", "VALENCIA",
"VALENTINE",
"VALENZUELA", "VANCE", "VANG", "VARGAS", "VASQUEZ",
"VAUGHAN",
"VAUGHN", "VAZQUEZ", "VEGA", "VELASQUEZ", "VELAZQUEZ",
"VELEZ",
"VILLA", "VILLANUEVA", "VILLARREAL", "VILLEGAS",
"VINCENT",
"WADE", "WAGNER", "WALKER", "WALL", "WALLACE",
"WALLER",
"WALLS", "WALSH", "WALTER", "WALTERS", "WALTON",
"WANG",
"WARD", "WARE", "WARNER", "WARREN", "WASHINGTON",
"WATERS",
"WATKINS", "WATSON", "WATTS", "WEAVER", "WEBB",
"WEBER",
"WEBSTER", "WEEKS", "WEISS", "WELCH", "WELLS",
"WERNER",
"WEST", "WHEELER", "WHITAKER", "WHITE", "WHITEHEAD",
"WHITNEY",
"WIGGINS", "WILCOX", "WILEY", "WILKERSON", "WILKINS",
"WILKINSON", "WILLIAMS", "WILLIAMSON", "WILLIS",
"WILSON",
"WINTERS", "WISE", "WOLF", "WOLFE", "WONG", "WOOD",
"WOODARD",
"WOODS", "WOODWARD", "WRIGHT", "WU", "WYATT", "YANG",
"YATES",
"YODER", "YORK", "YOUNG", "YU", "ZAMORA", "ZAVALA",
"ZHANG",
"ZIMMERMAN", "ZUNIGA" };
}
}


On Jun 10, 5:26 pm, Qian Qiao <qian.q...@gmail.com> wrote:

Qian Qiao

unread,
Jun 11, 2011, 12:13:35 AM6/11/11
to google-we...@googlegroups.com
On Fri, Jun 10, 2011 at 20:54, Jim Douglas <jdo...@basis.com> wrote:
> Thanks for the response, Joe.
>
> I'm sure the general idea is the same, but the UiBinder stuff is
> gibberish to me; translating UiBinder code to traditional code is
> making my head hurt.
>
> I *think* I copied all of the relevant pieces out of the sample, but
> I'm clearly missing something.  I get a page of items, but the
> ScrollPanel doesn't appear to be working.  Does anything in this jump
> out at you as obviously wrong?
>
>[snip]

>
> On Jun 10, 5:26 pm, Qian Qiao <qian.q...@gmail.com> wrote:
>> On Fri, Jun 10, 2011 at 14:57, Jim Douglas <jdou...@basis.com> wrote:
>> > I thought it would be a trivial matter to build a scrolling CellList
>> > like the one in the showcase:
>>
>> >http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList
>>
>> > But I need to work with hand-coded GWT Widgets, and that sample is
>> > based on UiBinder.  Can anyone point me to a sample like the one in
>> > the showcase (a large scrolling list) that does not use UiBinder?  The
>> > documentation isn't helpful; it's all based on trivial samples like
>> > days-of-the-week that don't require scrolling.
>>
>> The idea's the same regardless of the usage of uibinder isn't it? the
>> basic idea is to put the celllist inside a scrollpanel, and then
>> listen to scroll events on the scrollpanel, once you reach the bottom,
>> load more data.
>>
>> -- Joe

You haven't given the cellist a data provider, that's why :)

Jim Douglas

unread,
Jun 11, 2011, 1:00:40 AM6/11/11
to Google Web Toolkit
Can you elaborate on that a bit? How would you change that sample?

On Jun 10, 9:13 pm, Qian Qiao <qian.q...@gmail.com> wrote:

Jim Douglas

unread,
Jun 11, 2011, 1:20:04 AM6/11/11
to Google Web Toolkit
Ahh, thanks for the hint, Joe. I can't say I understand this yet, but
it looks like this is what needed to be changed:

From this:

cellList.setRowData(0, LIST);

to this:

ListDataProvider<String> dataProvider =
new ListDataProvider<String>(LIST);
dataProvider.addDataDisplay(cellList);

http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/view/client/ListDataProvider.html

Now I need to try to understand why that made the difference. I think
I'll need to study the source code; the documentation for the cell
widgets is sparse.

Qian Qiao

unread,
Jun 11, 2011, 1:21:49 AM6/11/11
to google-we...@googlegroups.com
Just had another look at your example, it shouldn't even need a data
provider, could you be a bit more specific on what the problem is?

-- Joe

Jim Douglas

unread,
Jun 11, 2011, 1:36:46 AM6/11/11
to Google Web Toolkit
The original version doesn't show a vertical scrollbar and doesn't
load new data when I attempt to move past the bottom of the first
page, so all I ever see is a single page of names out of the 1000
names in the list. The tiny change I posted appears to have fixed
that, although I have no clue what difference it made or why.

On Jun 10, 10:21 pm, Qian Qiao <qian.q...@gmail.com> wrote:

Qian Qiao

unread,
Jun 11, 2011, 2:39:04 AM6/11/11
to google-we...@googlegroups.com

Ah. The lack of scrollbar explained why the first version didn't work.

The logic was that it loads more data when the scrollbar reaches the
bottom, but for that to happen, first of all you need a scrollbar. The
solution is fairly simple, give your list a larger initial page size
or user a smaller scrollpanel.

-- Joe

Jim Douglas

unread,
Jun 11, 2011, 3:16:31 AM6/11/11
to Google Web Toolkit
That was my first thought (set the initial size to 50 items), and that
did give me a scrollbar ... but scrolling to the bottom didn't cause
it to load more data.

On Jun 10, 11:39 pm, Qian Qiao <qian.q...@gmail.com> wrote:

roberto...@hotmail.fr

unread,
Jul 5, 2013, 10:36:57 AM7/5/13
to google-we...@googlegroups.com
I FOUND AN EASIER SOLUTION WITH THE SimplePager

I take my data from a database

    public void init() {
        htmlPanel.clear();
       
        ProvidesKey<GwtUser> keyProvider = new ProvidesKey<GwtUser>() {
            public Object getKey(GwtUser item) {
                return (item == null) ? null : item.getUserId();
            }
        };

        CellList<GwtUser> cellList = new CellList<GwtUser>(new GwtUserCell(),     
                keyProvider);

        cellList.setRowCount(liste.size(), true);
        cellList.setRowData(0, liste);

        final SelectionModel<GwtUser> selectionModel
        = new SingleSelectionModel<GwtUser>(
                keyProvider);

        selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
            public void onSelectionChange(SelectionChangeEvent event) {
                user = ((SingleSelectionModel<GwtUser>) selectionModel).getSelectedObject();
                fireEvent(new ValidEvent("change"));
            }
        });

            final ListDataProvider<GwtUser> dataProvider =
                    new ListDataProvider<GwtUser>(liste);

          SimplePager pager;
          SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
          pager = new SimplePager(TextLocation.CENTER, pagerResources, true, 0,true);
          pager.setDisplay(cellList);
          dataProvider.addDataDisplay(cellList);
          dataProvider.setList(liste);
          pager.setPageSize(10);
         
        cellList.setSelectionModel(selectionModel);
        htmlPanel.add(cellList);
        htmlPanel.add(pager);
    }

AND THAT WORK!!!!!!!!!!!!!!!!!!!!!!!

Олег Рачаев

unread,
Feb 13, 2018, 10:56:58 PM2/13/18
to GWT Users
I've also spend an hour to understand how to make vertical scrolls available.

The solution is simple: cellList.setPageSize(9999999)

This solution is for cases there is no too many elements. Because big amount of cellList's data can reduce performance.
Reply all
Reply to author
Forward
0 new messages