假設我有我的頁面佈局如下:如何模塊化面板在GWT
vertical panel mainbody = new VerticalPanel;
//beginning of 1st sub-vertical panel
VerticalPanel first_panel = new verticalPanel();
first_panel.add(...);
//other such stuff, end of first_panel
mainbody.add(first_panel);
//beginning of 2nd sub-vertical panel
VerticalPanel second_panel = new verticalPanel();
second_panel.add(...);
//other such stuff, end of first_panel
mainbody.add(second_panel);
//beginning of 3rd sub-vertical panel
VerticalPanel third_panel = new verticalPanel();
third_panel.add(...);
//other such stuff, end of first_panel
mainbody.add(third_panel);
//end of mainbody
RootPanel.get().add(mainbody);
我想模塊化它,使得每個子板(first_panel
,second_panel
和third_panel
)屬於單個文件,所以一些進口後,我就可以在主要頁面代碼這做的伎倆:
vertical panel mainbody = new VerticalPanel;
mainbody.add(first_panel);
mainbody.add(second_panel);
mainbody.add(third_panel);
//end of mainbody
RootPanel.get().add(mainbody);
子板本身可以使用其他子板,爲其模塊化應該級聯。現在我需要做些什麼來實現這個功能? Google文檔對我來說不是很清楚。具體而言,
如何在單個文件(包或文件夾)中定義這些面板,以便它們可以導入到主文件中?
如何導入它們(有點像使用PHP中的
include
)?我需要對
xml
文件做什麼更改(如果有的話)?如何爲導入的文件定義相同的一組規則,以便導入級聯?也就是說,如果
a
進口b
,b
進口c
和d
構建自己,c
和d
導入到主文件dutring導入?在主CSS文件中的
CSS
規則是否足以適用於所有導入的面板?
如果有人可以從默認的StockWatcher應用程序,它自帶的GWT
包裝(使我們可以有一些共同點理解的目錄結構)的觀點解釋了這一點,這將是容易的,我理解。
有一件事。我已經開發了基於面板的一切。那麼現在如果我使用小部件,爲面板定義的任何功能(比如'click','mouseup'等事件處理程序)是否會受到干擾? – SexyBeast
順便說一句,我編輯了我的第4點,看看現在是否清楚.. :) – SexyBeast
而我不明白的目錄結構。如果你想到StockWatcher應用程序,有一個名爲'com.google.gwt.sample.stockwatcher.client'的包,它本身包含3個''java'文件,'StockWatcher.java','GreetingService.java'和'GreetingServiceAsync.java' 。我是否應該將組件面板放在這個包中,以便我可以像import「import com.google.gwt.sample.stockwatcher.client.subpanel_1」一樣導入它? – SexyBeast