Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://www.youtube.com/watch?v=g2XclEOJdIc&amp;feature=PlayList&amp;p=F01F46882D8A90AF&amp;playnext_from=PL&amp;index=0" rel="noreferrer">Google I/O 2010 - GWT's UI overhaul</a></p> <p><a href="http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/index.html?com/google/gwt/cell/client/package-summary.html" rel="noreferrer" title="title">javadocs package com.google.gwt.cell.client in 2.1</a></p> <p><a href="http://google-web-toolkit.googlecode.com/svn/2.1.0.M2/eclipse/plugin/3.5" rel="noreferrer">Eclipse update site for milestone 2</a></p> <p>While the code is in bikeshed, add this line to your gwt.xml file:</p> <pre><code>&lt;inherits name='com.google.gwt.requestfactory.RequestFactory'/&gt; </code></pre> <p>The following examples follow: </p> <ul> <li>CellList of TextCells with PageSizePager</li> <li>CellList of TextCells with a SimplePager</li> <li>CellList of TextCells with a SimplePager and PageSizePager(buggy) and</li> <li>CellTable with String header and TextCell header</li> </ul> <hr> <pre><code>package dpw.client; import java.util.ArrayList; import com.google.gwt.cell.client.TextCell; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.cellview.client.CellList; import com.google.gwt.user.cellview.client.CellTable; import com.google.gwt.user.cellview.client.PageSizePager; import com.google.gwt.user.cellview.client.SimplePager; import com.google.gwt.user.cellview.client.TextColumn; import com.google.gwt.user.cellview.client.Header; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.view.client.ListViewAdapter; public class Index implements EntryPoint { public void onModuleLoad() { // create some data ArrayList&lt;String&gt; values = new ArrayList&lt;String&gt;(); values.add("one"); values.add("two"); values.add("three"); values.add("four"); values.add("five"); values.add("six"); // create a ListViewAdapter ListViewAdapter&lt;String&gt; lva = new ListViewAdapter&lt;String&gt;(); // give the ListViewAdapter our data lva.setList(values); { // CellList of TextCells with PageSizePager CellList&lt;String&gt; cl = new CellList&lt;String&gt;(new TextCell()); // set the initial pagesize to 2 cl.setPageSize(2); // add the CellLists to the adaptor lva.addView(cl); // create a PageSizePager, giving it a handle to the CellList PageSizePager&lt;String&gt; psp = new PageSizePager&lt;String&gt;(cl, 2); // add the CellList to the page RootPanel.get().add(cl); // add the PageSizePager to the page RootPanel.get().add(psp); } RootPanel.get().add(new HTML("&lt;hr /&gt;")); { // CellList of TextCells with a SimplePager CellList&lt;String&gt; cl = new CellList&lt;String&gt;(new TextCell()); // set the initial pageSize to 2 cl.setPageSize(2); // add the CellLists to the adaptor lva.addView(cl); // create a pager, giving it a handle to the CellList SimplePager&lt;String&gt; pager = new SimplePager&lt;String&gt;(cl, SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(cl); // add the Pager to the page RootPanel.get().add(pager); } RootPanel.get().add(new HTML("&lt;hr /&gt;")); { // CellList of TextCells with a SimplePager and PageSizePager CellList&lt;String&gt; cl = new CellList&lt;String&gt;(new TextCell()); // set the initial pageSize to 2 cl.setPageSize(2); // add the CellLists to the adaptor lva.addView(cl); // create a PageSizePager, giving it a handle to the CellList PageSizePager&lt;String&gt; psp = new PageSizePager&lt;String&gt;(cl, 1); // create a pager, giving it a handle to the CellList SimplePager&lt;String&gt; pager = new SimplePager&lt;String&gt;(cl, SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(cl); // add the Pager to the page RootPanel.get().add(pager); // add the PageSizePager to the page RootPanel.get().add(psp); } RootPanel.get().add(new HTML("&lt;hr /&gt;")); { // CellTable CellTable&lt;String&gt; ct = new CellTable&lt;String&gt;(); ct.setPageSize(2); lva.addView(ct); // add a column with a simple string header ct.addColumn(new TextColumn&lt;String&gt;() { @Override public String getValue(String object) { return object; } }, "String Header"); //add a column with a TextCell header ct.addColumn(new TextColumn&lt;String&gt;() { @Override public String getValue(String object) { return "%" + object + "%"; } }, new Header&lt;String&gt;(new TextCell()) { @Override public String getValue() { return "TextCell Header"; } }); // create a pager, giving it a handle to the CellTable SimplePager&lt;String&gt; pager = new SimplePager&lt;String&gt;(ct, SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(ct); // add the Pager to the page RootPanel.get().add(pager); } } } </code></pre>
 

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