[英]GWT work with widgets and events
我米,GWT 2.4的新應用程序的工作。 我做了一個docklayoutpanel,並在它的西段插入了一個單元格列表。 我需要創建一個事件,每次用戶單擊頁面西側的單元格列表元素時,都會在docklayoutpanel的內容中加載特定的小部件。
有什么建議么?
謝謝
以下示例應為自我解釋
// Create a cell to render each value.
TextCell textCell = new TextCell();
// Create a CellList that uses the cell.
CellList<String> cellList = new CellList<String>(textCell);
cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
// Add a selection model to handle user selection.
final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
cellList.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
public void onSelectionChange(SelectionChangeEvent event) {
String selected = selectionModel.getSelectedObject();
if (selected != null) {
Window.alert("You selected: " + selected);
}
}
});
代替Window.alert("You selected: " + selected);
您將需要更改面板東部顯示的小部件。
這可以通過多種方式完成,其中一種方式是通過將Panel聲明為類的字段(而不是類的構造函數中的局部變量)或作為最終的局部變量,使Dockpanel暴露於Selection Change事件。在構造函數中。
另一種方法是通過事件處理來實現。 在MVP的設計模式的eventBus方法是做所有thesee有道這里了解更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.