栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何使用GWT 2.1数据表示小部件

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何使用GWT 2.1数据表示小部件

Google I / O
2010-GWT的UI大修

2.1中的javadocs包com.google.gwt.cell.client

里程碑2的Eclipse更新站点

当代码在Bikeshed中时,将此行添加到gwt.xml文件中:

<inherits name='com.google.gwt.requestfactory.RequestFactory'/>

以下示例如下:

  • 具有PageSizePager的TextCells的CellList
  • 具有SimplePager的TextCells的CellList
  • 具有SimplePager和PageSizePager(buggy)的TextCell的CellList
  • 带字符串标题和TextCell标题的CellTable

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<String> values = new ArrayList<String>();        values.add("one");        values.add("two");        values.add("three");        values.add("four");        values.add("five");        values.add("six");        // create a ListViewAdapter        ListViewAdapter<String> lva = new ListViewAdapter<String>();        // give the ListViewAdapter our data        lva.setList(values);        { // CellList of TextCells with PageSizePager CellList<String> cl = new CellList<String>(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<String> psp = new PageSizePager<String>(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("<hr />"));        { // CellList of TextCells with a SimplePager CellList<String> cl = new CellList<String>(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<String> pager = new SimplePager<String>(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("<hr />"));        { // CellList of TextCells with a SimplePager and PageSizePager CellList<String> cl = new CellList<String>(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<String> psp = new PageSizePager<String>(cl, 1); // create a pager, giving it a handle to the CellList SimplePager<String> pager = new SimplePager<String>(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("<hr />"));        { // CellTable CellTable<String> ct = new CellTable<String>(); ct.setPageSize(2); lva.addView(ct); // add a column with a simple string header        ct.addColumn(new TextColumn<String>() { @Override public String getValue(String object) {     return object; }        }, "String Header");        //add a column with a TextCell header        ct.addColumn(new TextColumn<String>() { @Override public String getValue(String object) {     return "%" + object + "%"; }        }, new Header<String>(new TextCell()) { @Override public String getValue() {     return "TextCell Header"; }        }); // create a pager, giving it a handle to the CellTable SimplePager<String> pager = new SimplePager<String>(ct,         SimplePager.TextLocation.CENTER); // add the CellList to the page RootPanel.get().add(ct); // add the Pager to the page RootPanel.get().add(pager);        }    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/486543.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号