我想要實現在GWT界面如圖本網站上:GWT菜單實施方案
我創建菜單系統,我能夠顯示使用下面的代碼從菜單提醒:
Command cmd = new Command() {
public void execute() {
Window.alert("Menu item have been selected");
}
}
我想擺脫window.alert()並從菜單中顯示我的應用程序頁面。
我想要實現在GWT界面如圖本網站上:GWT菜單實施方案
我創建菜單系統,我能夠顯示使用下面的代碼從菜單提醒:
Command cmd = new Command() {
public void execute() {
Window.alert("Menu item have been selected");
}
}
我想擺脫window.alert()並從菜單中顯示我的應用程序頁面。
首先創建視圖一個數組列表
public List<UIObject> viewsList = new ArrayList<UIObject>();
添加視圖到該列表
viewsList.add(addMovieView);
發送要選擇輔助方法
public void changeView(UIObject selectedView) {
for(UIObject view : viewsList) {
if(selectedView.equals(view)) {
view.setVisible(true);
} else {
view.setVisible(false);
}
}
}
創建視圖並加載相應的頁面。例如,如果你使用UiBinder的則:
MyPage selectedPage = new MyPage(); // creating of your panel RootPanel.get().clear(); // cleaning of rhe RootPanel RootPanel.get().add(selectedPage); // adding the panel to the RootPanel
你試圖讓整個頁面GWT,或只是菜單?如果只是在菜單中,您將需要一個GWT元素從相應的菜單項,這將導航到另一個頁面嵌入到你的整體HTML,然後調用類似
Window.open(linkURL, "_self", "");
。