子頁面列表 |
切換頁面的方法
//功能比較多,例如開新視窗
Window.open(A_URL, "_self", "");
//單純切換網址
Window.Location.assign(A_URL);
取得外部 javascript 的變數值
//in javascript
var value = "foo"
//in GWT
public native String getValue()/*-{
return $wnd.value;
}-*/;
Dynamic Loading
在程式碼當中隨意插入一個或多個GWT.runAsync()
,GWT compiler 會自動幫你處理。自訂 module 使用法
假設 package 名稱為pt2.util.gwt
、要給 client 用的 class 都必須放在 pt2.util.gwt.client
下。另外必須要有一個檔案,假設叫做 tool.gwt.xml
,必須放在 pt2.util.gwt
下,內容至少要是
<module>
<inherits name='com.google.gwt.user.User' />
</module>
<!-- 亂 try 出來的,不明究理 Orz -->
<!-- 記得把 inherits 的 theme 拿掉,以免套用至使用此 module 的 project -->
<inherits name='pt2.util.gwt.tool' />
即可使用。另外,pt2.util.gwt.client 必須提供 source code,否則無法 compile。
FileUpload 要成功,必須...
FormPanel
裡頭只能有一個 widget,裡頭有一個FileUpload
(廢話)FormPanel
有setMethod(FormPanel.METHOD_POST)
、setEncoding(FormPanel.ENCODING_MULTIPART)
、setAction(ACTION_URL)
FileUpload
有setName(INPUT_NAME)
。(死在這條,卡很久 Orz)
GWT RPC debug memo
測試環境:GWT 2.4.0假設 RPC 要傳遞 Foo 這個 class
- Foo 必須要 implements IsSerializable
- Foo 的 field,其 class 也必須 implements IsSerializable
- Foo 如果有自訂的 parent class,parent class 也必須要 implements IsSerializable
第三項不會有 error,但是 parent class 定義的 field(當然也要 implements IsSerializable)值完全無法傳遞,會都是預設值。
GWT.create()
只能傳入 *.class,不能傳入 Class 變數GWT.create(Foo.class);
//It's OK
Class foo = Foo.class;
GWT.create(foo);
//GWT Compile error