Places navigation proglem

37 views
Skip to first unread message

Arthur Rosenzahl

unread,
Oct 20, 2014, 11:12:44 AM10/20/14
to gwt-pl...@googlegroups.com
Hi all,

we have a strange problem in a GWT/GWTP-Project. We have a couple of presenters and the navigation was totally fine. But now i tried to create a new one and it is impossible to go to this presenter. It always jumps to the default presenter.
All presenters are declared the same way in the application module:
public class ApplicationModule extends AbstractPresenterModule {
    @Override
    protected void configure() {
        install(new UiModule());

        // Application Presenters
        bindPresenter(ApplicationPresenter.class, ApplicationPresenter.MyView.class, ApplicationView.class,
                      ApplicationPresenter.MyProxy.class);
        bindPresenter(HomePresenter.class, HomePresenter.MyView.class, HomeView.class, HomePresenter.MyProxy.class);
        bindPresenter(DevicesPresenter.class, DevicesPresenter.MyView.class, DevicesView.class, DevicesPresenter.MyProxy.class);
        bindPresenter(ContainerListPresenter.class, ContainerListPresenter.MyView.class, ContainerListView.class, ContainerListPresenter.MyProxy.class);
        bindSingletonPresenterWidget(DeviceEditorDialogPresenterWidget.class, DeviceEditorDialogPresenterWidget.MyView.class,
        DeviceEditorDialogView.class);
        bindSingletonPresenterWidget(ContainerInfoPresenter.class, ContainerInfoPresenter.MyView.class,
        ContainerInfoView.class);
        bindSingletonPresenterWidget(SettingsPresenter.class, SettingsPresenter.MyView.class,
                SettingsView.class);

    }
}
 And our top level presenter is declared as follows:

public class ApplicationPresenter
        extends Presenter<ApplicationPresenter.MyView, ApplicationPresenter.MyProxy> 
        implements CurrentUserChangedHandler, AsyncCallStartHandler, AsyncCallFailHandler, AsyncCallSucceedHandler {
    /**
     * {@link ApplicationPresenter}'s proxy.
     */
    @ProxyStandard
    public interface MyProxy extends Proxy<ApplicationPresenter> {
    }

    /**
     * {@link ApplicationPresenter}'s view.
     */
    public interface MyView extends View {
        void setTopMessage(String string);
    }
    
    @ContentSlot
    public static final Type<RevealContentHandler<?>> SLOT_SetMainContent = new Type<>();

    @Inject
    ApplicationPresenter(EventBus eventBus,
                         MyView view,
                         MyProxy proxy) {
        super(eventBus, view, proxy, RevealType.Root);
    }

    @ProxyEvent
    @Override
    public void onCurrentUserChanged(CurrentUserChangedEvent event) {
    }

    @ProxyEvent
    @Override
    public void onAsyncCallStart(AsyncCallStartEvent event) {
        getView().setTopMessage("Loading...");
    }

    @ProxyEvent
    @Override
    public void onAsyncCallFail(AsyncCallFailEvent event) {
        getView().setTopMessage("Oops, something went wrong...");
    }

    @ProxyEvent
    @Override
    public void onAsyncCallSucceed(AsyncCallSucceedEvent event) {
        getView().setTopMessage(null);
    }

    @Override
    protected void onReveal() {
        // Workaround to set a body background in login page
        ScriptInjector.fromString("document.body.classList.remove('signin');")
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
        
        // Inject the js that must be executed when the document is ready,
        // after gwt code is deployed, js for the template
        ScriptInjector.fromString(JsClientBundle.INSTANCE.docuReadyJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
}


The NameTokens are defined all the same:
public class NameTokens {
    public static final String homePage = "!homePage";
    public static final String loginPage = "!loginPage";
public static final String containersPage = "!containersPage";
//TODO why do we have two devices things?
    public static final String devicesPage = "!devicesPage";
    public static final String devicesDialog = "!devicesDialog";    
    public static final String uiExamplesPage = "!uiExamples";
    public static final String settingsPage = "!settingsPage";


    public static String getHomePage() {
        return homePage;
    }
    
    public static String getSettingsPage() {
        return settingsPage;
    }
    
    public static String getDevicesPage() {
        return devicesPage;
    }
    
    public static String getDevicesDialog() {
        return devicesDialog;
    }
    
    public static String getContainersPage() {
        return containersPage;
    }

    public static String getUiExamplesPage() {
        return uiExamplesPage;
    }

}


The presenter itself is just copied and renamed from an existing, working presenter:
public class SettingsPresenter extends Presenter<SettingsPresenter.MyView, SettingsPresenter.MyProxy>
        implements SettingsUiHandlers {
Logger logger = Logger.getLogger("RootLogger");
    /**
     * {@link SettingsPresenter}'s proxy.
     */
@ProxyCodeSplit
    @NameToken(NameTokens.settingsPage)
    // The first tab in the main page
    public interface MyProxy extends ProxyPlace<SettingsPresenter> {
    }

    /**
     * {@link SettingsPresenter}'s view.
     */
    public interface MyView extends View, HasUiHandlers<SettingsUiHandlers> {
    void setTitle(String title);

    }

    private DispatchAsync dispatcher;

    @Inject
    SettingsPresenter(final EventBus eventBus,
                      final MyView view,
                      final MyProxy proxy,
                      final DispatchAsync dispatcher) {
        super(eventBus, view, proxy, ApplicationPresenter.SLOT_SetMainContent);
        this.dispatcher = dispatcher;
        view.setUiHandlers(this);
    }
    


    @Override
    protected void onReveal() {
        getView().setTitle("Trust|me MDM");
    }
    
    @Override 
    protected void onReset() {
    super.onReset();
   
    }




Can the ClientModule definition be related to this?
public class ClientModule extends AbstractPresenterModule {
    @Override
    protected void configure() {
        install(new DefaultModule(DefaultPlaceManager.class));
        install(new ApplicationModule());
        install(new RpcDispatchAsyncModule()); // binds DispatchAsync to RpcDispatchAsync

        bind(ClientModelProvider.class).in(Singleton.class);
        bind(CurrentUser.class).in(Singleton.class);
        bind(IsAdminGatekeeper.class).in(Singleton.class);
        bind(LoggedInGatekeeper.class).in(Singleton.class);

        // DefaultPlaceManager Constants
        bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.homePage);
        bindConstant().annotatedWith(ErrorPlace.class).to(NameTokens.homePage);
        bindConstant().annotatedWith(UnauthorizedPlace.class).to(NameTokens.loginPage);

        // CSRF-Protection
        bindConstant().annotatedWith(SecurityCookie.class).to(ConstantHelper.securityCookie);
        
        // Load and inject CSS resources
        bind(ResourceLoader.class).asEagerSingleton();
    }
}

Sorry for posting so much and having such an unspecific question, but i really do not know how why the navigation just stopped working for new presenters.

Thanks for your help!


Richard Wallis

unread,
Oct 20, 2014, 11:14:42 AM10/20/14
to gwt-pl...@googlegroups.com
Can you post the module where the SettingsPresenter is bound

--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Wallis

unread,
Oct 20, 2014, 11:16:05 AM10/20/14
to gwt-pl...@googlegroups.com
Sorry I see you did as the first file.

You're not binding the Settings Proxy,  copy the binding for another Presenter rather than Presenter Widget

Arthur Rosenzahl

unread,
Oct 20, 2014, 11:45:53 AM10/20/14
to gwt-pl...@googlegroups.com
Ahhhh i see.
Now it works! Thanks for your help :) I guess i got blind from looking too long at the code.
 
Reply all
Reply to author
Forward
0 new messages