如何更改 gwt 面板的內容? (How to change the content of a gwt panel?)


問題描述

如何更改 gwt 面板的內容? (How to change the content of a gwt panel?)

假設我有一個名為 A 的視圖,它的 xml 類似於:

<g:HTMLPanel>
  <my:widgetA>
    ....
  </my:widgetA>
</g:HTMLPanel>

另外,我還有另一個名為 widgetB 的小部件。我想根據某些條件更改視圖 A 的內容,例如:

if (...is true) {
   A.clear();
   A.add(widgetA);
} else {
   A.clear();
   A.add(widgetB);
}

現在的問題是視圖 A 無法正確顯示 widgetA。視圖 A 在添加 widgetA 時變為空白。上面的實現有什麼問題?


參考解法

方法 1:

You might be adding a widget, that implements RequiresResize or at least needs to be given a fixed size.

To find out if that is the case, just call [setSize](http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/UIObject.html#setSize(java.lang.String, java.lang.String)) on that widget with a fixed size like that: widgetA.setSize('50px','50px);'

If that works, you either need to provide a size or use a panel, which implements ProvidesResize.

(by injoySebastian Baumhekel)

參考文件

  1. How to change the content of a gwt panel? (CC BY‑SA 2.5/3.0/4.0)

#gwt #widget






相關問題

通過 GWT-RPC 發送持久的 JDO 實例 (Sending persisted JDO instances over GWT-RPC)

GWT:帶有 db 變量的屬性文件的安全位置 (GWT: Safe place for properties file with db variables)

paket khusus dalam toples eksternal GWT (specific packages in a external jar GWT)

在 gwt 框架中使用參數更改 url (Changing url with parameters in gwt framework)

通過 JavaScript 在標題或 HTML 中動態包含腳本元素 (Dynamically include script element in header or HTML by JavaScript)

Java如何在構造函數中將接口作為參數傳遞? (Java How do I pass interface as parameter in Constructor?)

如何更改 gwt 面板的內容? (How to change the content of a gwt panel?)

內容類型是“應用程序/x-www-form-urlencoded”。預期的“文本/x-gwt-rpc” (Content-Type was 'application/x-www-form-urlencoded'. Expected 'text/x-gwt-rpc')

如何從谷歌應用引擎調用我的應用網址 (How to call my app url from google app engine)

GXT NumberField 不可編輯 (GXT NumberField not editable)

在碼頭上部署 gwt Web 應用程序 (deploying gwt web application on jetty)

在 gwt 中使用 html5 畫布畫一個圓圈? (draw a circle using html5 canvas in gwt?)







留言討論