com.extjs.gxt.ui.client.mvc
Class Dispatcher

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.mvc.Dispatcher
All Implemented Interfaces:
Observable

public class Dispatcher
extends BaseObservable

Dispatchers are responsible for dispatching application events to controllers.

Events:
Dispatcher.BeforeDispatch : MvcEvent(dispatcher, appEvent)
Fires before an event is dispatched. Listeners can set the doit field to false to cancel the action.
Dispatcher.AfterDispatch : MvcEvent(dispatcher, appEvent)
Fires after an event has been dispatched.

See Also:
DispatcherListener

Field Summary
static int AfterDispatch
          Fires after an event has been dispatched (value is 960).
static int BeforeDispatch
          Fires before an event is dispatched (value is 955).
 
Method Summary
 void addController(Controller controller)
          Adds a controller.
 void addDispatcherListener(DispatcherListener listener)
          Adds a listener to receive dispatch events.
 void dispatch(AppEvent event)
          The dispatcher will query its controllers and pass the app event to any controllers that can handle the particular event type.
 void dispatch(int type)
          The dispatcher will query its controllers and pass the app event to controllers that can handle the particular event type.
 void dispatch(int type, java.lang.Object data)
          The dispatcher will query its controllers and pass the app event to controllers that can handle the particular event type.
static void forwardEvent(AppEvent event)
          Forwards an app event to the dispatcher.
static void forwardEvent(int eventType)
          Creates and forwards an app event to the dispatcher.
static void forwardEvent(int eventType, java.lang.Object data)
          Creates and fowards an app event to the dispatcher.
static void forwardEvent(int eventType, java.lang.Object data, boolean historyEvent)
          Creates and fowards an app event to the dispatcher.
static Dispatcher get()
          Returns the singleton instance.
 java.util.List<Controller> getControllers()
          Returns all controllers.
 java.util.Map<java.lang.String,AppEvent> getHistory()
          Returns the dispatcher's history cache.
 void removeController(Controller controller)
          Removes a controller.
 void removeDispatcherListener(DispatcherListener listener)
          Removes a previously added listener.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, fireEvent, fireEvent, getFiresEvents, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BeforeDispatch

public static final int BeforeDispatch
Fires before an event is dispatched (value is 955).

See Also:
Constant Field Values

AfterDispatch

public static final int AfterDispatch
Fires after an event has been dispatched (value is 960).

See Also:
Constant Field Values
Method Detail

forwardEvent

public static void forwardEvent(AppEvent event)
Forwards an app event to the dispatcher.

Parameters:
event - the app event

forwardEvent

public static void forwardEvent(int eventType)
Creates and forwards an app event to the dispatcher.

Parameters:
eventType - the app event type

forwardEvent

public static void forwardEvent(int eventType,
                                java.lang.Object data)
Creates and fowards an app event to the dispatcher.

Parameters:
eventType - the app event type
data - the event data

forwardEvent

public static void forwardEvent(int eventType,
                                java.lang.Object data,
                                boolean historyEvent)
Creates and fowards an app event to the dispatcher.

Parameters:
eventType - the app event type
data - the event data
historyEvent - true to mark event as a history event

get

public static Dispatcher get()
Returns the singleton instance.

Returns:
the dispatcher

addController

public void addController(Controller controller)
Adds a controller.

Parameters:
controller - the controller to be added

addDispatcherListener

public void addDispatcherListener(DispatcherListener listener)
Adds a listener to receive dispatch events.

Parameters:
listener - the listener to add

dispatch

public void dispatch(AppEvent event)
The dispatcher will query its controllers and pass the app event to any controllers that can handle the particular event type.

Parameters:
event - the app event

dispatch

public void dispatch(int type)
The dispatcher will query its controllers and pass the app event to controllers that can handle the particular event type.

Parameters:
type - the event type

dispatch

public void dispatch(int type,
                     java.lang.Object data)
The dispatcher will query its controllers and pass the app event to controllers that can handle the particular event type.

Parameters:
type - the event type
data - the app event data

getControllers

public java.util.List<Controller> getControllers()
Returns all controllers.

Returns:
the list of controllers

getHistory

public java.util.Map<java.lang.String,AppEvent> getHistory()
Returns the dispatcher's history cache.

Returns:
the history

removeController

public void removeController(Controller controller)
Removes a controller.

Parameters:
controller - the controller to be removed

removeDispatcherListener

public void removeDispatcherListener(DispatcherListener listener)
Removes a previously added listener.

Parameters:
listener - the listener to be removed