net.customware.gwt.presenter.client.place
Class Place

java.lang.Object
  extended by net.customware.gwt.presenter.client.place.Place
Direct Known Subclasses:
PresenterPlace

public abstract class Place
extends java.lang.Object

A place represents a particular 'bookmark' or location inside the application. A place is stateful - it may represent a location with it's current settings, such as a particular ID value, or other unique indicators that will allow a user to track back to that location later, either via a browser bookmark, or by clicking the 'back' button.

However, there may be more than one instance of concrete Place classes, so the state should be shared between all instances of any given class. Usually this is done via a shared class, such as a Presenter instance.

Author:
David Peterson

Constructor Summary
Place()
           
 
Method Summary
 void addHandlers(EventBus eventBus)
          This method is called if the place should register itself with the event bus.
 PlaceRequest createRequest()
          Returns a new request for this place in its current state.
 boolean equals(java.lang.Object o)
           
abstract  java.lang.String getName()
          Returns the unique name for this place.
protected abstract  void handleRequest(PlaceRequest request)
          This method is called when a matching request is received.
 int hashCode()
           
 boolean matchesRequest(PlaceRequest request)
          This method is checked before calling handleRequest(PlaceRequest).
protected abstract  PlaceRequest prepareRequest(PlaceRequest request)
          Returns the request with any extra values relevant to the current place initialised.
 void removeHandlers(EventBus eventBus)
          This method is called when it should deregister any event handlers that were registered with the addHandlers(net.customware.gwt.presenter.client.EventBus) method.
protected abstract  void reveal()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Place

public Place()
Method Detail

getName

public abstract java.lang.String getName()
Returns the unique name for this place. Uniqueness is not enforced - creators must ensure that the name is unique or there will be potential issues with multiple places responding to the same History token.

Returns:
The place ID.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

handleRequest

protected abstract void handleRequest(PlaceRequest request)
This method is called when a matching request is received.

Parameters:
request - The place request.

matchesRequest

public boolean matchesRequest(PlaceRequest request)
This method is checked before calling handleRequest(PlaceRequest).

Parameters:
request - The request to check.
Returns:
true if the ID matches this place's name.

createRequest

public PlaceRequest createRequest()
Returns a new request for this place in its current state. This method calls prepareRequest(PlaceRequest) before returning.

Returns:
The new PlaceRequest.

prepareRequest

protected abstract PlaceRequest prepareRequest(PlaceRequest request)
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" );
 

Parameters:
request - The current request object.
Returns:
The prepared request.

reveal

protected abstract void reveal()

addHandlers

public void addHandlers(EventBus eventBus)
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.

Parameters:
eventBus - The event bus.

removeHandlers

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

Parameters:
eventBus - The event bus.


Copyright © 2010 customware.net. All Rights Reserved.