i m在新应用程序上使用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);
,您需要更改面板东侧显示的小部件。
这可以通过多种方式完成,其中之一就是通过将面板作为类的字段(而不是类的构造函数中的局部变量)或作为一个构造函数中的最终局部变量。
另一种方法是通过事件处理来执行此操作。MVP设计模式上的EventBus方法是在此处进行所有这些信息的正确方法。