Interface IMediator
- All Superinterfaces:
 INotifier
- All Known Implementing Classes:
 Mediator
public interface IMediator extends INotifier
The interface definition for a PureMVC Mediator.
In PureMVC, IMediator implementors assume these responsibilities:
- Implement a common method which returns a list of all 
INotifications theIMediatorhas interest in. - Implement a notification callback method.
 - Implement methods that are called when the IMediator is registered or removed from the View.
 
Additionally, IMediators typically:
- Act as an intermediary between one or more view components such as text boxes or list controls, maintaining references and coordinating their behavior.
 - In Flash-based apps, this is often the place where event listeners are added to view components, and their handlers implemented.
 - Respond to and generate 
INotifications, interacting with of the rest of the PureMVC app. 
When an IMediator is registered with the IView,
 the IView will call the IMediator's
 listNotificationInterests method. The IMediator will
 return an Array of INotification names which
 it wishes to be notified about.
The IView will then create an Observer object
 encapsulating that IMediator's (handleNotification) method
 and register it as an Observer for each INotification name returned by
 listNotificationInterests.
A concrete IMediator implementor usually looks something like this:
 import org.puremvc.as3.multicore.patterns.mediator.*;
 import org.puremvc.as3.multicore.patterns.observer.*;
 import org.puremvc.as3.multicore.core.view.*;
 import com.me.myapp.model.*;
 import com.me.myapp.view.*;
 import com.me.myapp.controller.*;
 import javax.swing.JComboBox;
 import java.awt.event.ActionListener;
 public class MyMediator extends Mediator implements IMediator, ActionListener {
     public MyMediator( Object viewComponent ) {
         super( viewComponent );
         combo.addActionListener( this );
     }
     public String[] listNotificationInterests() {
         return [ MyFacade.SET_SELECTION,
                  MyFacade.SET_DATAPROVIDER ];
     }
     public void handleNotification( INotification notification ) {
         switch ( notification.getName() ) {
             case MyFacade.SET_SELECTION:
                 setSelection(notification);
                 break;
             case MyFacade.SET_DATAPROVIDER:
                 setDataProvider(notification);
                 break;
         }
     }
     // Set the data provider of the combo box
     protected void setDataProvider( INotification notification ) {
         combo.setModel(ComboBoxModel<String>(notification.getBody()));
     }
     // Invoked when the combo box dispatches a change event, we send a
     // notification with the
     public void actionPerformed(ActionEvent event) {
         sendNotification( MyFacade.MYCOMBO_CHANGED, this );
     }
     // A private getter for accessing the view object by class
     protected JComboBox getViewComponent() {
         return viewComponent;
     }
 }
 
 - See Also:
 INotification
- 
Method Summary
Modifier and Type Method Description java.lang.StringgetMediatorName()Get theIMediatorinstance namejava.lang.ObjectgetViewComponent()Get theIMediator's view component.voidhandleNotification(INotification notification)Handle anINotification.java.lang.String[]listNotificationInterests()ListINotificationinterests.voidonRegister()Called by the View when the Mediator is registeredvoidonRemove()Called by the View when the Mediator is removedvoidsetViewComponent(java.lang.Object viewComponent)Set theIMediator's view component.Methods inherited from interface org.puremvc.java.interfaces.INotifier
sendNotification, sendNotification, sendNotification 
- 
Method Details
- 
getMediatorName
java.lang.String getMediatorName()Get the
IMediatorinstance name- Returns:
 - the 
IMediatorinstance name 
 - 
getViewComponent
java.lang.Object getViewComponent()Get the
IMediator's view component.- Returns:
 - Object the view component
 
 - 
setViewComponent
void setViewComponent(java.lang.Object viewComponent)Set the
IMediator's view component.- Parameters:
 viewComponent- the view component
 - 
listNotificationInterests
java.lang.String[] listNotificationInterests()List
INotificationinterests.- Returns:
 - an 
Arrayof theINotificationnames thisIMediatorhas an interest in. 
 - 
handleNotification
Handle an
INotification.- Parameters:
 notification- theINotificationto be handled
 - 
onRegister
void onRegister()Called by the View when the Mediator is registered
 - 
onRemove
void onRemove()Called by the View when the Mediator is removed
 
 -