ext-gwt (gxt) onRender 入口点类
我有一个基本类,它使用 onRender
方法扩展了 LayoutContainer
。如何将其指定为我的 EntryPoint
?传统上,我会定义一个实现 EntryPoint
的类,重写 onModuleLoad
?
public class TheRoarChronicles extends LayoutContainer {
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setSize(600, 400);
setLayout(new CenterLayout());
ContentPanel panel = new ContentPanel();
panel.setBodyStyle("padding: 6px");
panel.setFrame(true);
panel.setHeading("CenterLayout");
panel.addText("I should be centered");
panel.setWidth(200);
add(panel);
}
}
I have a basic class that extends LayoutContainer
with the method onRender
. How can I assign this as my EntryPoint
? Traditionally I would define a class that implements EntryPoint
, overriding onModuleLoad
?
public class TheRoarChronicles extends LayoutContainer {
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setSize(600, 400);
setLayout(new CenterLayout());
ContentPanel panel = new ContentPanel();
panel.setBodyStyle("padding: 6px");
panel.setFrame(true);
panel.setHeading("CenterLayout");
panel.addText("I should be centered");
panel.setWidth(200);
add(panel);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您会因此而恨我,但您不想让此类成为
EntryPoint
。您问这个问题表明您对 GWT 还很陌生。此类定义视图
的特定组件——这不应该是EntryPoint
。EntryPoint
应该被视为普通 Java 应用程序的main
方法,它是程序所有执行的开始。您不想将特定的视图组件分配给该角色。简单地定义一个
EntryPoint
会更清晰,它唯一负责将这个单个组件添加到 RootPanel,例如You're going to hate me for this, but you do not want to make this class an
EntryPoint
. The fact that you're asking this question indicates that you are very new to GWT. This class defines a particular Component of yourview
--this should not be anEntryPoint
. AnEntryPoint
should be thought of like amain
method for a normal Java application, it is the beginning of all execution of your program. You do not want to assign a particular view Component to this role.It'd be much cleaner to simply define an
EntryPoint
that has the sole responsibility of adding this single Component to the RootPanel, e.g.