Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with multiple entry Points in the same module

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!

like image 290
JohnIdol Avatar asked May 30 '09 12:05

JohnIdol


1 Answers

The correct way is to have a single entry point per module, that sticks the appropriate widgets in the appropriate divs:

RootPanel panel = RootPanel.get("someHomeWidget");
if (panel) panel.add(new HomeWidget());

panel = RootPanel.get("adminWidget");
if (panel) panel.add(new AdminWidget());

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.

like image 190
rustyshelf Avatar answered Sep 24 '22 21:09

rustyshelf