Module, View and Presenter extension

54 views
Skip to first unread message

AJ Gray

unread,
May 25, 2012, 8:08:14 AM5/25/12
to gwt-pl...@googlegroups.com
I have been struggling with figuring this out for a couple days now.

We have a situation where we have a base product that is a fully functional gwtp application on its own. However, we offer customers the ability to tailor it to their needs. This could be as simple as adding or removing a single field from a screen or even changing text that is displayed. In order to achieve this, my assumption is that we would need the ability to have our default gwtp application fully extended by a new application (ginjectors, placemanager, nametokens, etc.). On top of that, some of the views may or may not need to be modified as well as presenters.

The goal would be to (1) extend the views and presenters in the customized application from the base application. Be able to (2) use the same place tokens but have them go to the extended applications view and presenters. Also, (3) have additional place tokens for the new application. Finally, and most important, (4) reuse as much of the base application as possible.

I can't for the life of me figure this out. Each time i think I've got it, i run into a new issue. I was hoping that someone could direct me to a simple, sample application that does this or maybe documentation that explains how to configure everything to work together.

I've been scouring the various posts and have yet to find anything to answer my question. Perhaps my unfamiliarity with gwtp is the cause and i've just not been able to identify the answer that someone has provided yet.

Any help at this point would be HUGELY appreciated!

Christian Goudreau

unread,
May 25, 2012, 11:25:00 AM5/25/12
to gwt-pl...@googlegroups.com
Tailoring to their need, well I don't know what are those needs, but changing the data model could be a good start to save what they wanted to have.

I never been in that situation and I don't fully understand what you're trying to achieve though... could you help me?
--
Christian Goudreau

AJ Gray

unread,
May 25, 2012, 2:26:15 PM5/25/12
to gwt-pl...@googlegroups.com
quite simply, we have an application that is pretty generic. it's a fully functional gwtp application (Base). we want to build a new application (App) building off of the core foundation provided by Base (new screens, changes to some screens, some presenter logic will need to be added). This is dead simple with GWT's create() method. However, without that functionality in gwtp/gin, i'm uncertain how to achieve the same end result.

again, i'm brand new to gwtp, gin, guice so please forgive me if i look completely incompetent. so far i have:
AppGinjector exends BaseGinjector

originally i thought that AppModule would need to extend BaseModule but it appears that's not the case so each of them extend AbstractPresenterModule.

in BaseModule, i bind EventBus, TokenFormatter, and RootPresenter.
in AppModule i bind PlaceManager as AppPlaceManager so the placemanager is used from App rather than Base (so we can provide more places, etc.).

AppEntryPoint extends BaseEntryPoint.

This is where i'm lost. I'm trying to get the PlaceManager to take me to a Presenter in App that's extending a Presenter from Base. It's a place request so i'm guessing it's got to be the same token unless there's a way for me to use a new token. Or, if there's a way in the App's placemanager to intercetp Base.tokenName and then redirect it to App.tokenNameExt

With the following presenter:
public class BaseAccountPresenter extends Presenter< BaseAccountPresenter.MyView, BaseAccountPresenter.MyProxy > implements BaseAccountUiHandlers
{
    public interface MyView extends View, HasUiHandlers< BaseAccountUiHandlers >
    {}

    @ProxyStandard
    @NameToken( BaseNameTokens.personal )
    public interface MyProxy extends ProxyPlace< BaseAccountPresenter >
    {}

    @Inject
    public BaseAccountPresenter( final EventBus eventBus, final MyView view, final MyProxy proxy )
    ...
}

my assumption is this is what AppAccountPresenter should look like in order to extend BaseAccountPresenter:

public class AppAccountPresenter extends BaseAccountPresenter
{
    public interface MyView extends BaseAccountPresenter.MyView
    {}
   
    @ProxyStandard
    @NameToken( BaseNameTokens.personal )
    public interface MyProxy extends ProxyPlace< AppAccountPresenter >
    {}

    @Inject
    public AppAccountPresenter( final EventBus eventBus, final BaseAccountPresenter.MyView view, final BaseAccountPresenter.MyProxy proxy )
    {
        super( eventBus, view, proxy );
    }
}

i really have no idea how to bind this all together so i've been trying various combinations from the group messages. currently i have:

public class AppModule extends AbstractPresenterModule
{
    @Override
    protected void configure()
    {
        bind( PlaceManager.class ).to( AppPlaceManager.class ).in( Singleton.class );
        bind( AppAccountPresenter.class ).in( Singleton.class );
        bind( AppAccountPresenter.MyProxy.class ).asEagerSingleton();
        bindSharedView( BaseAccountPresenter.MyView.class, BaseAccountView.class );
    }
}

currently i'm getting:
    [ERROR] [gen] - Line 42: The constructor StandardProvider<BaseAccountPresenter>(Provider<AppAccountPresenter>) is undefined
   
I say currently because i've gotten many errors on my little journey here.

I hope this helps explain my need for you. I'm at the point of giving this up and going a different direction.

AJ Gray

unread,
May 25, 2012, 4:16:59 PM5/25/12
to gwt-pl...@googlegroups.com
alright, so i slowed down a bit and looked a little closer at things. I've managed to get a shared view with extended presenter working by doing this:


public class BaseAccountPresenter extends Presenter< BaseAccountPresenter.MyView, BaseAccountPresenter.MyProxy > implements BaseAccountUiHandlers
{
    public interface MyView extends View, HasUiHandlers< BaseAccountUiHandlers >
    {}

    @ProxyStandard
    @NameToken( BaseNameTokens.personal )
    public interface MyProxy extends ProxyPlace< BaseAccountPresenter >
    {}

    @Inject
    public BaseAccountPresenter( final EventBus eventBus, final MyView view, final MyProxy proxy )
    ...
}

public class AppAccountPresenter extends BaseAccountPresenter
{
    @Inject
    public AppAccountPresenter( final EventBus eventBus, final AppAccountPresenter.MyView view, final AppAccountPresenter.MyProxy proxy )

    {
        super( eventBus, view, proxy );
    }
}


public class AppModule extends AbstractPresenterModule
{
    @Override
    protected void configure()
    {
        bind( PlaceManager.class ).to( AppPlaceManager.class ).in( Singleton.class );        
        bindPresenter( BaseAccountPresenter.class, AppAccountPresenter.class, AppAccountPresenter.MyProxy.class );
        bindSharedView( AppAccountPresenter.MyView.class, BaseAccountView.class );
    }
}

Is that a valid configuration?

My question now is, what do i do if i want to extend BaseAccountView with AppAccountView? For example, i want to create a new AppAccountView that extends BaseAccountView but in AppAccountView add an additional data entry field.

It's unclear to me how to create the AppAccountView due to the Binder interface. The BaseAccountView is pretty simple but due to the UiHandlers there is some code in there i'd rather not have to copy/paste. Do i simply have no other option but to create AppAccountView w/o it extending BaseAccountView?

AJ Gray

unread,
May 25, 2012, 4:17:43 PM5/25/12
to gwt-pl...@googlegroups.com
My apologies for earlier, i never thanked your for helping me with this :)

AJ Gray

unread,
May 25, 2012, 5:10:37 PM5/25/12
to gwt-pl...@googlegroups.com
I have figured all of this out.

I now have a Presenter/View in Base that works on it's own and i also have a Presenter/View in App that is inheriting from Base!

I will post later with my setup and would appreciate it someone would take a look and make sure i'm not going against any gwtp design patterns or implementations.

Christian Goudreau

unread,
May 25, 2012, 5:27:08 PM5/25/12
to gwt-pl...@googlegroups.com
Well I guess that asking you questions helped you figure out what you needed to do :D That was a great start hehe glad to hear!
--
Christian Goudreau
Reply all
Reply to author
Forward
0 new messages