Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve the Current Presenter in GWT or GWTP?
    primarykey
    data
    text
    <p>Here is my problem. I have many links in my header presenter.</p> <pre> Link1 - Link2 - Link3 - GuideDialogLink </pre> <p>When user clicks on Link1 or Link2 or Link3, it will open a new browser.</p> <p>However, when user clicks on GuideDialogLink, then it will popup a DialogBox right on top of the current link. </p> <p>The GuideDialog is designed in a way that it show different Gui depending on which link user is staying. Its code is like this:</p> <pre><code> 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 } } } </code></pre> <p>Ex, when user is staying in Link3 &amp; 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.</p> <p>So, my question is:</p> <p>Is there any way to retrieve the Current Presenter?</p> <p>If we know which Presenter is current one, then we can call GuideDialog accordingly ex: <code>GuideDialog myGD=new GuideDialog(0);</code></p> <p>-Other solution is to store a <code>public static int currentLink</code> in <code>Utility</code> class. And when user clicks link1 or link2 or link3 we can use EventBus to set <code>public static currentLink</code> to set accordingly &amp; eventually <code>GuideDialog myGD=new GuideDialog(Utility.currentLink);</code>. </p> <p>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.</p> <p>So how can i solve my problem elegantly?</p> <p>EDIT</p> <p>Ok, let me clarify it. I am using GWTP to create my webapp.</p> <p>-1st, I used eclipse to generate HeaderPresenter. The eclipse will create (HeaderPresenter.java, HeaderView.java &amp; HeaderView.ui.xml). HeaderPresenter has 4 hyperlinks: link1,link2, link3, GuideDialogLink.</p> <p>-2nd, I created Link1Presenter (Link1Presenter.java, Link1View.java, Link1View.ui.xml). Then i created Link2Presenter (Link2Presenter.java, Link2View.java, Link2View.ui.xml). Then I created Link3Presenter (Link3Presenter.java, Link3View.java, Link3View.ui.xml)</p> <p>-3rd, I used <code>setInSlot</code> to make Link1Presenter, Link2Presenter, Link3Presenter to be embeded or nested inside HeaderPresenter. It means when user go to link1 (ex: abc.com#link1) they will see 4 hyperlinks (link1,link2, link3, GuideDialogLink). If they go to link2 (ex: abc.com#link2) or link3, they also see 4 hyperlinks.</p> <p>-4th, I create GuideDialog.java extends DialogBox &amp; in the HeaderPresenter, i has <code>guideDialogLink.addClickHandler(new ClickHandler(){ GuideDialog myGD=new GuideDialog (int whichLink); });</code></p> <p>So when users are in either link1,2, or 3 they will see GuideDialogLink right? &amp; when they click GuideDialog a DialogBox will popup right?</p> <p>Now my requirement is that when users are in Link1 &amp; if they click GuideDialogLink, a dialog will popup &amp; show a Gui (2 textboxes on it). When users are in Link2 &amp; if they click GuideDialogLink, a dialog will popup &amp; show another Gui (2 labels on it). When users are in Link3 &amp; if they click GuideDialogLink, a dialog will popup &amp; show another different Gui (2 checkboxes on it) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload