Frinje implements the View component of the MVC architecture as two separate classes, view and mediator classes.

The graphic elements of the View component are implemented in an MXML class and the logic elements of the View component are implemented in an ActionScript class. The Frinje framework refers to the MXML class as a view class, and the ActionScript class as a mediator class.

The view class and the mediator class are associated by using metadata tags. The MXML view class uses the [DefaultMediator] tag to specify the associated mediator class. The ActionScript mediator class uses the [View] tag to specify the associated view class.

The view class contains the graphic elements that the user sees and clicks, such as buttons, text fields, and menus. The mediator class contains the logic that drives those elements, such as the actions taken when a user clicks a particular button. A mediator class interacts with the other elements in the Frinje framework by dispatching events in response to user actions. To gain this functionality, each mediator class must extend the EventDispatcher base class.

When you create data view or global view extensions to the vSphere Web Client, you must provide the UI view that appears in the main workspace, and the mediator class that contains the interaction logic for that view.

The view class is typically an MXML class that encapsulates the visual Flex components for the data view. The view class specifies the data view mediator by using the [DefaultMediator] annotation, and contains little business logic, if any.

The mediator class in a vSphere Web Client data view contains the logic used to populate the view components, make data requests, and handle data responses. The vSphere Web Client SDK provides libraries and interfaces that your mediator class can use to obtain the object that the user has currently selected in the vSphere Web Client, and to request data from the vSphere environment.

Some data views, such as those you add to the object workspace for a specific vSphere object type, need to track which object the user has selected by using the object navigator. For example, if you add a data view to the object workspace for Virtual Machine objects, that data view must track which Virtual Machine the user has selected to request the appropriate data for display.

Your mediator class can use the Frinje framework to obtain the object that the user has currently selected in the object navigator. To make use of this functionality, your mediator class must implement the com.vmware.ui.IContextObjectHolder interface.

When your mediator class implements the IContextObjectHolder interface, you must provide get and set methods for the contextObject property. You do not need to set the contextObject property directly. The Frinje framework calls the mediator class set contextObject() method when the view becomes active. The currently selected vSphere object is passed to set contextObject() as the parameter value.

A best practice is to place your data view’s initial data requests and other initialization code in the set contextObject() method. That way, you can initialize the view when the framework passes the currently selected object as the view becomes active.

The following example mediator class contains the logic for a data view for a custom object type called Chassis. The example mediator implements the IContextObjectHolder interface, and uses set contextObject() to obtain the currently selected Chassis object. In the example, the framework invokes the set contextObject() method, which in turn sends an initial data request, or clears the interface if no object is selected.

public class ChassisSummaryViewMediator extends EventDispatcher implements IContextObjectHolder {

  private var _view:ChassisSummaryView;
  private var _contextObject:IResourceReference;
 
  public function set contextObject(value:Object):void {
     _contextObject = IResourceReference(value);
     if (_contextObject == null) {
        clearData();
        return;
     }
     // Initialize the view's data once the current context is known.
     requestData();
  }
 
  [Bindable]
  public function get contextObject():Object {
     return _contextObject;
  }
   ...
}

To obtain the data needed to populate the view, your mediator class must communicate with data sources. These data sources can be in vSphere, or they can be external Web sources. Your mediator class can use the Data Access Manager (DAM) Flex library in the vSphere Web Client SDK to request data from either type of data source. To use Data Access Manager, your mediator must use the DAM API, which is based on Frinje events. See Frinje Event-Driven APIs.

Your mediator class can also communicate with a data source by importing a Java service that you create. If you create a Java service and add it to the vSphere Web Client Virgo server framework, you can use an ActionScript proxy class to access the service from your mediator class. See Model Components in Frinje.