Friday, October 25, 2013

How to retrieve the Current Presenter in GWT or GWTP?

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