net.customware.gwt.presenter.client.place
Class PresenterPlace<T extends Presenter>

java.lang.Object
  extended by net.customware.gwt.presenter.client.place.Place
      extended by net.customware.gwt.presenter.client.place.PresenterPlace<T>
Direct Known Subclasses:
BasicPresenterPlace, ProvidedPresenterPlace

public abstract class PresenterPlace<T extends Presenter>
extends Place

This is a subclass of Place with some helper values for working with Presenters.

Author:
David Peterson

Constructor Summary
PresenterPlace()
           
 
Method Summary
 void addHandlers(EventBus eventBus)
          This method is called if the place should register itself with the event bus.
abstract  T getPresenter()
           
static Presenter getPresenter(Place place)
          Returns the Presenter for the provided Place if the place is an instance of PresenterPlace and the contained Presenter is an instance of the presenterClass.
static WidgetPresenter<?> getWidgetPresenter(Place place)
           
protected  void handleRequest(PlaceRequest request)
          Reveals the display.
protected abstract  void preparePresenter(PlaceRequest request, T presenter)
          This method is called on matching place requests before the presenter is revealed.
protected  PlaceRequest prepareRequest(PlaceRequest request)
          Returns the request with any extra values relevant to the current place initialised.
protected abstract  PlaceRequest prepareRequest(PlaceRequest request, T presenter)
          This method is called when creating a PlaceRequest for this place.
 void removeHandlers(EventBus eventBus)
          This method is called when it should deregister any event handlers that were registered with the Place.addHandlers(net.customware.gwt.presenter.client.EventBus) method.
 void reveal()
          Calls the Presenter.revealDisplay() method for the place's presenter.
 
Methods inherited from class net.customware.gwt.presenter.client.place.Place
createRequest, equals, getName, hashCode, matchesRequest, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PresenterPlace

public PresenterPlace()
Method Detail

getPresenter

public abstract T getPresenter()

reveal

public void reveal()
Calls the Presenter.revealDisplay() method for the place's presenter.

Specified by:
reveal in class Place

handleRequest

protected void handleRequest(PlaceRequest request)
Reveals the display. Subclasses should override this method to perform any custom handling.

Specified by:
handleRequest in class Place
Parameters:
request - The place request.

preparePresenter

protected abstract void preparePresenter(PlaceRequest request,
                                         T presenter)
This method is called on matching place requests before the presenter is revealed. Subclasses can perform any calls to the presenter to prepare it for display based on the request.

Parameters:
request - The request.
presenter - The presenter.

prepareRequest

protected PlaceRequest prepareRequest(PlaceRequest request)
Description copied from class: Place
Returns the request with any extra values relevant to the current place initialised. If nothing needs to be done, return the request that was passed in.

Typical usage:

 return request.with( "name", idValue ).with( "name", "Foo" );
 

Specified by:
prepareRequest in class Place
Parameters:
request - The current request object.
Returns:
The prepared request.

prepareRequest

protected abstract PlaceRequest prepareRequest(PlaceRequest request,
                                               T presenter)
This method is called when creating a PlaceRequest for this place. It should add any state to the request as defined by the current presenter.

If nothing is to be done, simply return the request unchanged. Otherwise, call PlaceRequest.with(String, String) to add parameters. Eg:

 return request.with( "id", presenter.getId() );
 

Parameters:
request - The current request.
presenter - The presenter.
Returns:
The prepared place request.

getWidgetPresenter

public static WidgetPresenter<?> getWidgetPresenter(Place place)

getPresenter

public static Presenter getPresenter(Place place)
Returns the Presenter for the provided Place if the place is an instance of PresenterPlace and the contained Presenter is an instance of the presenterClass. If not, null is returned.

Parameters:
place - The place.
Returns:
The Presenter, if appropriate.

addHandlers

public void addHandlers(EventBus eventBus)
Description copied from class: Place
This method is called if the place should register itself with the event bus. Only one instance of any given concrete Place should be registered. The PlaceManager should enforce this however, so in general, don't call this method directly.

Overrides:
addHandlers in class Place
Parameters:
eventBus - The event bus.

removeHandlers

public void removeHandlers(EventBus eventBus)
Description copied from class: Place
This method is called when it should deregister any event handlers that were registered with the Place.addHandlers(net.customware.gwt.presenter.client.EventBus) method.

Overrides:
removeHandlers in class Place
Parameters:
eventBus - The event bus.


Copyright © 2010 customware.net. All Rights Reserved.