ArcBees / GWTP

A complete model-view-presenter framework to simplify your next GWT project.
Other
334 stars 132 forks source link

@NameToken to Proxy #697

Open confile opened 9 years ago

confile commented 9 years ago

I a controller which is also a place I do:

    @ProxyCodeSplit
    @NameToken(NameTokens.start)
    public interface MyProxy extends ProxyPlace<StartPagePresenter> {
    }

I know that there is a Generator which collects all the @NameToken name tokens and creates a

But, what else is done with the @NameTokens? Where does a proxyPlace get its nameToken? Could you give my a hint where to search?

christiangoudreau commented 9 years ago

The generator doesn't only collect the name token, it generate the proxy, which instantiate the presenter in due time, allowing clean code splitting when needed. The nametoken is used to identify the presenter uniquely following a "web" pattern.

As a hint "where" to search, you should take a look at the proxy generators. You can also create your own proxy, but that is undocumented. We've been creating dynamic proxies for a while now, while it's not obvious, it's really useful for CMS and dynamic tabs.

confile commented 9 years ago

@christiangoudreau Thank you for your help. I see that for my StartPagePresenterthe following proxy has been generated:

public class StartPagePresenterMyProxyImpl extends com.gwtplatform.mvp.client.proxy.ProxyPlaceImpl<StartPagePresenter> implements buddyis.mobile.client.app.start.StartPagePresenter.MyProxy, com.gwtplatform.mvp.client.DelayedBind {

  private com.gwtplatform.mvp.client.ClientGinjector ginjector;

  public static class WrappedProxy
  extends com.gwtplatform.mvp.client.proxy.ProxyImpl<StartPagePresenter> implements com.gwtplatform.mvp.client.DelayedBind {

    private com.gwtplatform.mvp.client.ClientGinjector ginjector;

    public WrappedProxy() {
    }

    @Override
    public void delayedBind(Ginjector baseGinjector) {
      ginjector = (com.gwtplatform.mvp.client.ClientGinjector)baseGinjector;
      bind(ginjector.getPlaceManager(),
          ginjector.getEventBus());
      presenter = new CodeSplitProvider<StartPagePresenter>( ginjector.getbuddyismobileclientappstartStartPagePresenter() );

      RevealContentHandler<StartPagePresenter> revealContentHandler = new RevealContentHandler<StartPagePresenter>( eventBus, this );
      getEventBus().addHandler( StartPagePresenter.CONTENT_SLOT, revealContentHandler );
    }
  }

  public StartPagePresenterMyProxyImpl() {
    DelayedBindRegistry.register(this);
  }

  @Override
  public void delayedBind(Ginjector baseGinjector) {
    ginjector = (com.gwtplatform.mvp.client.ClientGinjector)baseGinjector;
    bind(ginjector.getPlaceManager(),
        ginjector.getEventBus());
    WrappedProxy wrappedProxy = GWT.create(WrappedProxy.class);
    wrappedProxy.delayedBind( ginjector ); 
    setProxy(wrappedProxy); 
    String[] nameToken = {"/start"}; 
    String[] gatekeeperParams = null;
    setPlace(new com.gwtplatform.mvp.client.proxy.PlaceImpl( nameToken ));
  }
}

I can see that StartPagePresenterMyProxyImpl is an implementation of StartPagePresenter.MyProxy.

Why is a WrappedProxy created inside and set with setProxy(wrappedProxy); to StartPagePresenterMyProxyImpl.

Since StartPagePresenterMyProxyImpl is a proxy implementation why does a ProxyImpl. get another Proxy? I did not get the reason for that?

olafleur commented 9 years ago

Closing as, from what I see, the question has been answered. Don't hesitate to ask your question on the forum.

confile commented 9 years ago

@olafleur No id do not see any answer.

olafleur commented 9 years ago

Oh sorry, I didn't saw that you had other questions. Reopening. ;-)