【发布时间】:2013-01-17 10:57:02
【问题描述】:
我现在正在努力适应 GWT 和 UiBinder。但我无法解决这个问题。 一个例子来告诉你我的意思:
MainMenu.ui.xml
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:gwt="urn:import:com.google.gwt.user.client.ui" xmlns:my="urn:import:com.wn.webapp.client.UiBinder">
<gwt:VerticalPanel>
<my:TopMenu/>
<gwt:VerticalPanel>
<gwt:HTMLPanel>
<gwt:TextBox/>
</gwt:HTMLPanel>
<my:ItemList/>
<my:PageMenu/>
</gwt:VerticalPanel>
</gwt:VerticalPanel>
</ui:UiBinder
我创建了一个 MainMenu 并将一些 ui.xml 文件嵌入其中。这工作正常。网站看起来不错。
但是我该怎么做呢? 这是我嵌入到 MainMenu.ui.xml 中的 PageMenu.ui.xml 文件的代码。
public class PageMenu extends Composite{
private static PageMenuUiBinder uiBinder = GWT.create(PageMenuUiBinder.class);
interface PageMenuUiBinder extends UiBinderWidget, PageMenu{}
public PageMenu(){
initWidget(uiBinder.createAndBindUi(this));
}
public void setButtonText(ArrayListString textIds){
//doessomething
}
}
现在我想打电话给前任。 onModuleLoad() 中的 setButtonText() 方法。
public void onModuleLoad()
{
MainMenu mainmenu = new MainMenu();
RootPanel.get().add(this.mainmenu);
// call it here (setButtonText())
}
我该怎么做?
问候 劳拉(我还不是一个经验丰富的程序员。所以当你尝试回答时请注意这一点:D)THX
【问题讨论】:
-
请也发布 PageMenu.ui.xml。
-
这只是一个简单的例子。不是我的代码本身,因为我不能发布公司的代码。^^ 可能看起来像...
-
但这与内容无关。这只是关于调用方法。
标签: gwt methods widget call uibinder