neo09 / gwt-platform

Automatically exported from code.google.com/p/gwt-platform
0 stars 0 forks source link

Think about a way to use dialog-based presenters #106

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Dialog boxes are a nice way to build wizards, like:
http://blog.hivedevelopment.co.uk/2009/10/introduction-to-mvp-unit-testing-
part.html

Right now, dialog boxes are forced to be PresenterWidgets, so they are not 
linked to any name token. Dialog-box based wizards, however, could greatly 
benefit from being linked to name tokens, so that modifying the URL would 
switch the wizard page. 

The problem with linking a dialog box presenter with a name token is: what 
page should we display in the background if the dialog is invoked from the 
URL?

Options:
1) Don't worry about it, just leave what's there or display a blank page is 
the wizard is accessed directly.
2) Use the new hierarchical places and display the presenter corresponding to 
the next-to-last name token in the hierarchy. For example, 
#home/buyCar/carWizardPage1 would display the "buyCar" presenter in the 
background and the "carWizardPage1" dialog presenter in the foreground.
3) Somehow make the dialog responsible of specifying the presenter to display 
in the background.

I'm heavily leaning towards (1) for now, because its simpler and it is 
probably enough.

Original issue reported on code.google.com by philippe.beaudoin on 1 Jun 2010 at 4:57

GoogleCodeExporter commented 9 years ago
The main purpose of a popup/dialogbox is to Pop in front of everything else as 
a movable living entity.

I would also go for A, since it's the natural order of a DialogBox and I would 
leave everything behind.

Only one case that we must pay attention : When focus is not enforced to the 
DialogBox (Don't know if you have 
deactivated that) but sometimes it's usefull to have a popup box and still be 
able to work on the background. 
that being said, I don't think a "Place" dialog box should have that 
opportunity.

Original comment by goudreau...@gmail.com on 1 Jun 2010 at 5:29

GoogleCodeExporter commented 9 years ago
We have a way to use popup since V0.3, is this an already resolved issue ?

Original comment by goudreau...@gmail.com on 22 Jul 2010 at 2:08

GoogleCodeExporter commented 9 years ago
I'll leave it here for now since this one is about attaching name tokens 
directly to dialog boxes... I'm not sure it's at all needed so I'll reduce 
priority, but if anybody has a use case please step forward and describe it.

Original comment by philippe.beaudoin on 22 Jul 2010 at 5:27

GoogleCodeExporter commented 9 years ago
I have one... That I'm working on right now ! I have a popup description window 
and I like it that It can be triggered by history !

This is already working pretty well and I'm using  view.show on reveal and 
view.hide onHide in presenter. Really simple.

Cheers

Original comment by goudreau...@gmail.com on 22 Jul 2010 at 5:32

GoogleCodeExporter commented 9 years ago
Great. If you have the time, maybe you could write and post a sample "wizard" 
app on GWTP so we can all see how to do this?

Original comment by philippe.beaudoin on 22 Jul 2010 at 5:35

GoogleCodeExporter commented 9 years ago
Yeah but the this is that I'm not using popupPresenter :) It sound more like a 
hack to me :D

Original comment by goudreau...@gmail.com on 22 Jul 2010 at 5:37

GoogleCodeExporter commented 9 years ago

Original comment by philippe.beaudoin on 22 Sep 2010 at 1:35

GoogleCodeExporter commented 9 years ago
I would love to see option 2.

I'm using a global popup with a PopupView, a ProxyPlace (#popup) and 
hierarchical history. The app itself uses a TabContainerPresenter with 
different tabs (#tab1, #tab2, ...)

What I want to achieve: If the user goes to www.myapp.com/#tab1/popup;id=123, 
he/she should see #tab1 + #popup;id=123.

Problem: This only works after the app is loaded. If the user would enter the 
link in a new window he/she would only see the dialog box not the presenters 
behind it.

Is there a way to implement something like (pseudocode):

if (placeRequest == PopupPresenter && relativePlace(-1) != PopupPresenter && 
relativePlace(-1) != visible) {
    placeManager.revealRelativePlace(-1);
}
proxy.manualReveal(this);

I don't know how to do this myself because once I reveal #tab1 it's no longer 
possible to reveal #popup.

Original comment by dominik.mayer on 11 Feb 2012 at 4:01

GoogleCodeExporter commented 9 years ago
I just walked into Dominik's shoes, although my default place doesn't have tabs 
(however, user could still start the app using an url such as 
www.myapp.com/#popup), and here is how I managed to handle our common issue, 
although this is far from being a perfect solution...

In the entry-point, before calling PlaceManager.revealCurrentPlace(), first 
analyze whether the initially requested URL corresponds to a popup view.  If 
so, first reveal the default place and then, reveal the current (here, initial) 
place (looks like this has to be done in a deferred command).
Doing so reveals two places without adding anything in the history.

This solution is not very satisfactory (at least) in the way it figures whether 
we are to deal with a popup or not, as I couldn't find a way to figure out 
whether a place token (in our case, that appears at some point in the history 
hierarchy thingie) corresponds to a PopupView or not in a generic fashion :  
internally, all presenters basically register "themselves" as 
ValueChangeHandlers and decide whether the event (the place token) should 
trigger them or not.  In other words, a clear mapping between place tokens and 
corresponding presenters is nowhere to be found.

Besides that, here is the code I use, in case it can help you...

final PlaceManager        place_manager= INJECTOR.getPlaceManager();
final String              token= History.getToken().trim();

if (!token.isEmpty())
{
    final List< PlaceRequest >      place_request_hierarchy= INJECTOR.getTokenFormatter().toPlaceRequestHierarchy( token );

    if (!place_request_hierarchy.isEmpty())
    {
        final PlaceRequest          first_place_request= place_request_hierarchy.get( 0 );

        if (MOBILE_ID_ENROLLMENT.equals( first_place_request.getNameToken() ))
        {
            place_manager.revealDefaultPlace();
        }
    }
}

Scheduler.get()
         .scheduleDeferred( new ScheduledCommand()
                                {
                                    @Override
                                    public final void execute()
                                    {
                                        place_manager.revealCurrentPlace();
                                    }
                                } );

Needless to say, I wish there could be a better way to do all that...

I'm wondering whether GWTP could figure out by itself whether, the first time a 
place is to be revealed, that if it's a popup one, then the default place 
should be revealed first...  However, I suspect that other users may want a 
different behaviour...

Original comment by Yaya.at....@gmail.com on 22 Apr 2012 at 11:01