Friday, October 25, 2013

Re: How to retrieve the Current Presenter in GWT or GWTP?

I found the answers, very simple.

1st, when opening a new link we can add a param like whichLink. Ex my.com#link1;whichLink=link1

Then in HeaderPresenter, when calling GuideDialog, we do this

GuideDialogBox gDialogBox=new GuideDialogBox(placeManager.getCurrentPlaceRequest().getParameter("whichLink", "home"));

On Friday, October 25, 2013 11:15:39 PM UTC+11, Tom wrote:

Here is my problem. I have many links in my header presenter.

Link1 - Link2 - Link3 - GuideDialogLink  

When user clicks on Link1 or Link2 or Link3, it will open a new browser.

However, when user clicks on GuideDialogLink, then it will popup a DialogBox right on top of the current link.

The GuideDialog is designed in a way that it show different Gui depending on which link user is staying. Its code is like this:

 class GuideDialog extends DialogBox{      public GuideDialog(int whichLink){         if(whichLink==0){             //show Gui 1          }         else if(whichLink==2){             //show Gui 2          }         else if(whichLink==3){             //show Gui 3          }      }   }  

Ex, when user is staying in Link3 & if they click GuideDialogLink, it will show a DialogBox that has Gui3 which is different from Gui1 or Gui2 if user is staying on Link1 or Link2.

So, my question is:

Is there any way to retrieve the Current Presenter?

If we know which Presenter is current one, then we can call GuideDialog accordingly ex: GuideDialog myGD=new GuideDialog(0);

-Other solution is to store a public static int currentLink in Utility class. And when user clicks link1 or link2 or link3 we can use EventBus to set public static currentLink to set accordingly & eventually GuideDialog myGD=new GuideDialog(Utility.currentLink);.

But i don't think this solution is elegant since Google must have some function to let us know which current page we are in.

So how can i solve my problem elegantly?

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

No comments:

Post a Comment