Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

gwt - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...