ictvmt / mvp4g

Automatically exported from code.google.com/p/mvp4g
0 stars 0 forks source link

GWT dev-mode ignores @Singleton for views, but production mode works #117

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In my mvp4g project I am injecting view's into the main layout. In production 
mode (full compile) this works as expected. The view is injected into the 
layout, and the presenter updates this view.

However in GWT development mode, two MyView's are created and one MyPresenter. 
So what happens is that the view that is attached to the layout is different 
than the one that the presenter is updating.

The Presenter:

@Presenter(view = MyView.class)
public class MyPresenter extends BasePresenter<MyView, MyEventBus> {
    public void someMethod() {
       view.doSomething()
    }
}

The view:

@Singleton
public class MyView extends Composite {
    public void doSomething() {
        ...
    }
}

The layout view:

public class LayoutView extends Composite {

    @Inject
    public LayoutView(MyView my) {
        ContentPanel panel = new ContentPanel();
        panel.add(my);
        initWidget(panel);
    }
}

Why would this behave differently in production and development modes?

What version of the product are you using? On what operating system?
1.4

Original issue reported on code.google.com by jordan.t...@gmail.com on 13 Jul 2012 at 7:23

GoogleCodeExporter commented 8 years ago
As long as your presenter and your LayoutView are in the same module, you 
should have a singleton for MyView (otherwise, you need to create a crossmodule 
singleton: 
http://code.google.com/p/mvp4g/wiki/GinIntegration#Creating_Cross-Module_Singlet
on.

Also, when you add the @Singleton annotation, you need to restart your dev mode 
for it to work.

I used @Singleton fine in the past, do you still have the issue? Do you have 
this issue for any view?

Original comment by plcoir...@gmail.com on 17 Jul 2012 at 7:12

GoogleCodeExporter commented 8 years ago
It is currently a single module project.

I tried rebooting the server (Jboss), restarting eclipse and dev mode and the 
problem persisted.

I did a "mvn clean" since it is a maven project and the error went away after 
recompiling.  It sounds like there was an object cached somewhere that never 
got updated.  Either way it now works exactly as I expect.

Original comment by jordan.t...@gmail.com on 17 Jul 2012 at 8:59

GoogleCodeExporter commented 8 years ago
Thanks, I'll mark this issue as fixed then.

Original comment by plcoir...@gmail.com on 23 Jul 2012 at 10:53