views:

180

answers:

1

I'm getting into Google Web Toolkit, and am a little confused about the Entry Points in GWT. Google's docs say:

If you have multiple EntryPoints (the interface that defines onModuleLoad()) within a module, they will all be called in sequence as soon as that module (and the outer document) is ready. If you are loading multiple GWT modules within the same page, each module's EntryPoint will be called as soon as both that module and the outer document is ready. Two modules' EntryPoints are not guaranteed to fire at the same time, or in the same order in which their selection scripts were specified in the host page.

So does each page in your website need an Entry Point defined for it?

Do you only really NEED an entry point when you have javascript generated based on your Java classes?

Are you able to combine multiple auto-generated-js definitions into a single *.gwt.xml file?

EDIT: Link to quoted source: http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html

Thanks!

+1  A: 

The most straightforward way to make a GWT app is to have a single page for the entire application, and a single top-level module (defined in a .gwt.xml file). Each module has a single EntryPoint class. Then all of your different "pages" are sub-sections of the same page, ideally using GWT's history mechanism to keep track of state changes that in a non-AJAX web app would be new pages. So if you set things up this way you'll need one EntryPoint for your whole app.

The bit of the docs that you quoted (link?) discuss what I think is an advanced use case, where you've got more than one module that you're loading on a single page.

aem
Interesting, I can see how this would work where your navigation menu determines what gets displayed in the main content panel (in a "standard" page layout), but then if some pages break this layout (i.e. the login page) do you need a separate Entry Point for such pages?
Adam
Ok, so after thinking about my Login page question, does the following setup seem to make sense:- Login page - User enters their OpenID criteria, presses the form-submit, which calls back to an authentication servlet. Upon successful authentication, it directs the user towards the app's EntryPoint (we'll say its a Dashboard of some sort); if the auth fails, then the servlet returns a message to the login page for display.I figure this makes sense as you wouldn't want to load the app's js file unless you were sure the user could authenticate. Authentication itself is pretty 1-dimensional.
Adam
That would be a fine way to do it. Another way is to have the whole thing, including the Login page, be part of your GWT app and use Code Splitting to ensure that only the login functionality gets loaded to start with (see http://code.google.com/webtoolkit/doc/latest/DevGuideCodeSplitting.html)
aem