I have multiple entry points in the same module.
For example I have an Home entry point for the home page and an Admin entry point for the admin page.
<entry-point class='com.company.project.client.HomeModule'/>
<entry-point class='com.company.project.client.AdminModule'/>
The way I am setup now - I need to check somt like this in my OnModuleLoad:
if((RootPanel.get("someHomeWidget")!=null)&&
(RootPanel.get("someOtherHomeWidget")!=null))
{
// do the stuff
}
in order the the Admin Entrypoint not to be executed when the Home page gets open and the other way around.
Not doing the check above also involves that if I have a div with the same name in both the Home and Admin page whatever I am injecting in it shows up twice on each of them.
This stinks 1000 miles away and is obviously wrong: what's the correct way to do this in people experience?
Any help appreciated!
I also wanted to use multiple pages in a GWT toy app and I think I figured it out. It took some massaging of the deployment descriptor (myApp.gwt.xml), but here's what I did.
It worked. Just duplicate the gwt.xml and provide a new name for the module to go along with the new app page. I looked at some of the other links and I may have actually done what was described, but there were too many words and redirects and such (i.e. I didn't really read anything). I am using the latest GWT plugin for Galileo so maybe IJWs now.
The correct way is to have a single entry point per module, that sticks the appropriate widgets in the appropriate divs:
That way it just scans the page looking for any divs you have and inserts the appropriate widget. So your HTML page determines what widgets are displayed when and the GWT code is ready to handle any situation. There's nothing about the above that stinks, it's the way your entry point should be written.
The alternative is if your admin area and normally area are totally different (eg: you want to load them at separate times) then they should be separate modules, with separate entry points.
There is a simple (tricky) way to achieve this:
Make a Main class Your entry point.
Create this Main.java to work like a dispatcher:
Now the different classes Application, Admin and Install work like seperate units.
Here is for example a simple Install:
You don't need the Singleton stuff (getInstance), but it is very handy in big applications.
Now in the /war-directory create directories named install and admin and in very of them create an HTML page like this:
So when the user directs his Brower to http://www.example.com/install he will be redirected to http://www.example.com/index?install and index.html is bound to Main.java which will dispatch the request and load Install.java
It's usually better to only have one EntryPoint. Multiple EntryPoints in one module all start at the same time and that can sometimes do things you did not expect.
You have plenty of options in how to handle it separately: - Have 2 different compilations one for Admin and one for the Home application. - Use the history tokens to indicate that you want Admin or Home - Check a JS variable to show one or the other - Check the presence of a specific DIV id to show Admin or Home (RootPanel.get(id)) - Use URL parameters to indicate the application. - ... etc
Did you try this framework yet? http://gwtmultipage.org/ Claudius
I have a solution for this on my blog. You can download a sample maven project that has multiple entry points and uses url-rewriting. Take a look: http://zenoconsulting.wikidot.com/blog:16