6. GWT 歷史回顧
GWT 1.0 (2006)
GWT 1.3 (2007) First Open Source Release, OSX support
GWT 1.4 (2007) JUnit and ImageBundle
GWT 1.5 (2008) Java 1.5 support, Overlay Types, DOM API, CSS
Themes, Linkers
GWT 1.6 (2009) EventHandlers, EMMA Support, WAR support,
Parallelized Builds
GWT 1.7 (2009) Newer browser support, IE8, GPE and AppEngine
GWT 2.0 (2009) DevMode, DraftCompile, UIBinder, LayoutPanel,
CodeSplitter, ClientBundle, CssResource
GWT 2.1 (2010) RequestFactory, Editor Framework, Validation, MVP,
Cell Widgets
GWT 2.2 (2011) GWT Designer, HTML5 support
GWT 2.3 (2011) Better AppEngine integration
GWT 2.4 (2011) Maven and RequestFactory enhancements
GWT 2.5 (2012) Super Dev Mode、Elemental (experimental)
6
7. GWT 亮眼事蹟
SDK downloaded over 1 million times
100,000+ Active Developers
Deep Integration with Eclipse, IntelliJ, Spring STS/Roo
Used by Google products such as AdWords, Flights, Wallet
Fun things: GwtQuake, Angry Birds for the Web
GWT Today is a mature, high quality, code base.
7
8. 分頁 Grid
介紹如何使用EventBus從後端拿資料後,餵給Grid 呈現
public class dejcGridBean {
List data = new ArrayList();
{for (int i = 1; i <= 500; i++) {
data.add(createVO("使用者" + i, "000" + i));}}
// 取得指定起始和限定筆數
public List page(Map info) {
int offset = Integer.parseInt(info.get("offset")+"");
int limit = Integer.parseInt(info.get("limit")+"");
List list = new ArrayList();
Map rtn = new HashMap();
rtn.put(" totalSize" , data.size());
list.add(rtn); //放入回傳筆數
for (int i = offset; i < (offset + limit); i++)
{list.add(data.get(i));} Spring Bean
GWT Client return list;
}}
EventBus 8
9. 分頁 Grid 原理說明
Grid 分頁元件提供PageToolBar,可點選下頁,進行指定頁數的限定筆數
讀取,和先前Grid差異就在DataLoader物件不同
private BasePagingLoader createDataLoader() { 傳給Spring的參數
RpcProxy proxy = new RpcProxy() {
public void load(Object loadConfig, final AsyncCallback callback) {
page = (PagingLoadConfig) loadConfig;
para.put("offset", page.getOffset()+"");
para.put("limit", page.getLimit()+""); Spring回傳資料
EventBus.get().publishRemote(new EventObject(eventId, para),
new EventProcess() {
public void execute(String eventId, EventObject eo) {
List resp = eo.getInfoList();
totalSize = Integer.parseInt((String) resp.remove(0)); 改從Map取得totalSize
BasePagingLoadResult b = read(page, resp);
callback.onSuccess(b);
}});
}};
toolbar = new PagingToolBar(pageSize);
BasePagingLoader loader = new BasePagingLoader(proxy);
toolbar.bind(loader);
return loader;
} 9