0

Problem in short: I have two modules inheriting a common module (without entrypoint) and one host page for each. Whichever it loads, it loads both at the same time on the page. I just want them to load and show themselves separately, not together in all pages..

When I start Login.html, it starts these both modules (they share the browser space vertically) and loads the correct entrypoint (Login extends Entrypoint) twice.

When I start Main.html, it starts these both modules each with the Main entrypoint...

I suspect to problem to be in the project structure, but we do not want to split one project/app into several projects just because of the modules.

Login:

 <?xml version="1.0" encoding="UTF-8"?>
      <module rename-to='Login'>
      <inherits name='fqdn.Common' />
      <stylesheet src='../Common.css' />  
      <!-- Specify the app entry point class. -->
      <entry-point class='fqdn.Login' />
   <module>

Main:

 <?xml version="1.0" encoding="UTF-8"?>
      <module rename-to='Main>
      <inherits name='fqdn.Common' />
      <stylesheet src='../Common.css' />  
      <!-- Specify the app entry point class. -->
      <entry-point class='fqdn.Main' />
    <module>

Login.html:

<html>
  <head>        
    <link type="text/css" rel="stylesheet" href="css/Common.css">
    <script type="text/javascript" language="javascript" src="Login/Login.nocache.js"></script>
  </head>
  <body>
    ...
  </body>
</html>

Main.html:

<html>
  <head>        
    <link type="text/css" rel="stylesheet" href="css/Common.css">
    <script type="text/javascript" language="javascript" src="Main/Main.nocache.js"></script>
  </head>
  <body>
    ...
  </body>
</html>

I have to admit, that both entrypoints share the same dir and lots of classes, but not the same Ginjector stuff. They are named myproject.client.Login and myproject.client.Main.

Is that a reason for GWT to fail? I would be happy to know a good fix or workaround for that situation :)

Update: added Main.java snippets

public class Main implements EntryPoint {

    private Logger logger = Logger.getLogger(Main.class.getName());
    private final GinMainInjector injector = GinMainInjector.INSTANCE;
    private Place defaultPlace = GWT.create(TicketPlace.class);        
    private SimplePanel appWidget;
    private EventBus eventBus;

    public void onModuleLoad() {
            logger.finest("Starting Main...");
            eventBus = injector.getEventBus();                
            MainActivityMapper activityMapper = GWT.create(MainActivityMapper.class);
            activityMapper.insertInjector(injector);
            PlaceController placeController = injector.getPlaceController();
            createAppWidgetPanel();
            startActivityManager(activityMapper, eventBus);
            startHistoryHandler(placeController, eventBus);
    }

    private void startActivityManager(ActivityMapper activityMapper, EventBus eventBus) {
            ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
            activityManager.setDisplay(appWidget);
            RootLayoutPanel.get().clear();

            RootLayoutPanel.get().add(appWidget);
    }
}
FloHin
  • 41
  • 1
  • 7
  • Please can you share some piece of code of `fqdn.Main` and `fqdn.Login` where you are adding top component. I want to know I are you adding/displaying the `Composite/SimplePanel` on the page? – Braj Apr 07 '14 at 18:42
  • I updated it and added Main.java (Main and Login look exatly the same) – FloHin Apr 09 '14 at 09:43

2 Answers2

0

If you see both modules on the same screen side by side, this means you have added both of them to your RootPanel. More over, this means you have a VerticalPanel or something similar as your app container - a SimplePanel will not accept more than one widget, and other panels will display one on top of the other, or one under the other.

Check your code in Main.java and Login.java entry points.

Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
  • I do not want them to show together (updated my question if it was misleading). I do not have a RootPanel, just a fresh instance of SimplePanel. – FloHin Apr 07 '14 at 14:59
  • You have to have a line of code like this one: `RootLayoutPanel.get().add(appWidget);` Otherwise, your GWT app will show nothing on the screen. I updated my response. – Andrei Volgin Apr 07 '14 at 15:24
  • I added "RootLayoutPanel.get().clear(); RootLayoutPanel.get().add(appWidget);" instead of just RootPanel. – FloHin Apr 09 '14 at 09:43
0

It works now!

We are using SuperDevMode and it mixed up both modules. See https://stackoverflow.com/a/20334018/2337633 for a similar answer and better explanation maybe

I changed the arguments for the code server to load the modules each, not together

Before:

 -src SRC package.Main package.Login

Now:

-src SRC package.Main -src SRC package.Login

Note: In both cases, SRC is the same directory. I do not know why and how this argument list works, but everytime when I see both modules on the same page, I start DevModeOn and compile just the current module based on url, and then it works again.

If I get a redirect and other module starts up, it may again be broken. But then again, DevModeOn for that module and recompiling it - works.

This problem (as I understand it) was just a minor issue of using SuperDevMode with wrong arguments..

Note also, that if even when replacing the whole RootLayoutPanel (html body) per

RootLayoutPanel.get().clear();
RootLayoutPanel.get().add(appWidget);

the problem insisted to stay. I really think it was just the CodeServer arguments and recompilation mashup.

Community
  • 1
  • 1
FloHin
  • 41
  • 1
  • 7