简体   繁体   中英

ext-gwt (gxt) onRender entry point class

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);
    }
}

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, eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM