RootPresenter switching on double main views

58 views
Skip to first unread message

newbie

unread,
Oct 15, 2015, 12:08:38 PM10/15/15
to Mvp4g
Hi!

I'm so sorry if the question that I'll post here seems to someones so stupid, but I'm already newbie on the gwt framework and especially the mvp4g Api.

I'm creating double gwt Applications that must be both merged into one single project. So I renamed all my RootViews and RootPresenters classes to (SubRootView1 and SubRootView2 and SubRootPresenter1 and SubRootPresenter2) and created a new RootView and RootPresenter. So that this latter will direct the user to the SubRootView1 or to the SubRootView2 depending on his choice performed on the LoginView using 2 radioButtons. and also, the new RootView have to eventually contain nothing and will act as a recipient for the SubRootView1 or the SubRootView2.

My question here is how could we make an if condition into the onStart() method of the RootPresenter in order to take into account the user choice performed on the LoginView???

please feel free to ask for any further information.

pleaaaaaaase help, it's very urgent

newbie

unread,
Oct 16, 2015, 4:51:23 AM10/16/15
to Mvp4g
Any suggestion please, I'm blocked.


newbie

unread,
Oct 16, 2015, 9:32:24 AM10/16/15
to Mvp4g
No one could unblock me ?

Sergey

unread,
Oct 19, 2015, 1:15:26 PM10/19/15
to Mvp4g
Hi!

If I understand you correctly, you want to have two individual application that are independent from each other and on login user selects one of them. If complete independence is a requirement I would suggest you to deploy two separate applications and do URL based routing depends on what user selects on Login. This is a bad solution. Better one will be to use multi-modules feature of mvp4g. There you'll have RootEventBus where you RootPresenter is sitting and listens to login form and then you have two child modules one SubApplication1 and SubApplication2. Both of them has independent event bus, you can enable code splitting and all other cool features of Mvp4g. You still can reuse code in both of the modules and talk between them using RootEventBus with forwardToParent events. 

Let me know if it helps,
Sergey

newbie

unread,
Oct 20, 2015, 3:51:54 AM10/20/15
to Mvp4g
Hi!

thanks for your reply, 

well, your last solution seems to be convenient for my case, nevertheless I'm not very expert in gwt neither in mvp4g API, so that, I think to have this working will takes time more than expected.
that's why I'd rather to continue in the same solution I have started and if possible guide me what's wrong I've commited in my code.
Actually, as I said before, I have changed all the names  RootView and  RootPresenter of my two separate application and created on single RootView and RootPresenter which implements the changeRootBody(Widget w) and also the start() method jointly with LoginPresenter and subsequently, I've removed the onStart() and onChangeRootBody(Widget w)  methods from the 2 old RootPresenters . and now I have the LoginView displayed on the first loading page.

this LoginView manage the user choice by 2 radioButton. so that here is the code implementing this condition:

@UiHandler ("btnLogin")
void onLogin (ClickEvent event){
if(radioHome1.getValue())
{
presenter.onBottonHome1Click(); //already in the project
}
else if(radioHome2.getValue())
{
// presenter.onButtonHome2Click(); // not added yet to the project
}
}
but the problem is that when I click on the radioHome1, I'll be directed to a blank page (which is the home page) ???

Have you an idea, what I've probably missed to configure ??????????

please help me!

Sergey Shvets

unread,
Oct 20, 2015, 12:57:54 PM10/20/15
to mv...@googlegroups.com
Looks like you have some UiHandler that triggers some action on RadioBox selection. I can't see any problems with your current pieces of code you presented. Try to put debug messages in all the functions (or use logging capabilities on mvp4g) to trace what is happening. 

--
You received this message because you are subscribed to the Google Groups "Mvp4g" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvp4g+un...@googlegroups.com.
To post to this group, send email to mv...@googlegroups.com.
Visit this group at http://groups.google.com/group/mvp4g.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

newbie

unread,
Oct 22, 2015, 6:39:35 AM10/22/15
to Mvp4g

I already understood the issue. So that since I have multi level of RootView and RootPresenter, I mean the one of the top level that have to behave as a dispatcher and the two others of the sub level and each one of them have to use the changeRootBody() method in order to put different views inside. 

 

In other words, if we consider our top RootView is an empty view in which we'll display one of the double SubRootView, so in this case we'll use the changeRootBody() method of the RootPresenter. on the other side, SubRootPresenter1 and SubRootPresenter2 have also this method in order to fill their SubRootView with different project views, so in this case we'll have a conflict even when I subscribe these method with different name in the MainEventBus, it doesn't work.

 

To be more clear, in my LoginPresenter, I use an UiHandler on the LoginButton which will direct me to one of the 2 project using the radionButton. If we suppose we chose project 1, ther is the code:

 

LoginView:

 

      if(radioProj1.getValue())

      presenter.onBottonProj1Click();

 

LoginPresenter:

 

       public void onBottonProj1Click(){

                              

                eventBus.goToSubRoot1();

                eventBus.goToHome1();

      }

 

SubRootPresenter1

 

      public void  onGoToSubRoot1() {

                eventBus.changeRootBody(view.getViewWidget());

                }

 

HomePresenter1

 

      public void onGoToHome1()

                {

                eventBus.changeBody(view.getViewWidget());

                }

               

MainEventBus

 

       @Events(startPresenter=RootPresenter.class)

       public interface AppEventBus extends EventBus{

               

                @Start

                @Event(handlers = {LoginPresenter.class, RootPresenter.class })

                public void start(); 

               

                @Event(handlers = {RootPresenter.class})

                public void changeRootBody(Widget widget);

               

                @Event(handlers = {HomePresenter.class, SubRootPresenter1.class, RootPresenter.class})

                public void goToHome1();

               

               

                @Event(handlers = {SubRootPresenter1.class})

                public void changeBody(Widget w);

               

                @Event(handlers={SubRootPresenter1.class})

                public void goToSubRoot1();

               

                @Event (handlers = {LoginPresenter.class})

                public void goToLogin();

       }

 

So here is the whole of my main pages code, so if someone could read carefully the code and try to detect what's wrong with this code and how could I resolve the changeBody() method problematic , I'd be very grateful.

Frank Hossfeld

unread,
Oct 22, 2015, 4:32:35 PM10/22/15
to Mvp4g
Can you provide a small sample project? That would it make easier to help.

Reply all
Reply to author
Forward
0 new messages