ext-gwt (gxt) onRender 入口点类

发布于 2024-10-31 07:30:10 字数 696 浏览 0 评论 0原文

我有一个基本类,它使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪痕残 2024-11-07 07:30:10

您会因此而恨我,但您不想让此类成为 EntryPoint。您问这个问题表明您对 GWT 还很陌生。此类定义视图的特定组件——这不应该是EntryPointEntryPoint 应该被视为普通 Java 应用程序的 main 方法,它是程序所有执行的开始。您不想将特定的视图组件分配给该角色。

简单地定义一个 EntryPoint 会更清晰,它唯一负责将这个单个组件添加到 RootPanel,例如

RootPanel.get().add(new TheRoarChronicles());

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 your view--this should not be an EntryPoint. An EntryPoint should be thought of like a main 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.

RootPanel.get().add(new TheRoarChronicles());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文