Packagecom.adobe.cairngorm.view
Classpublic class ViewHelper
Implementsmx.core.IMXMLObject

Deprecated as of Cairngorm 2.1.

Used to isolate command classes from the implementation details of a view.

Model-View-Controller (MVC) best practices specify that command classes should interact with the view using the model (see the ModelLocator class), but, in some instances, command classes may require to both interrogate and update the view directly. Prior to performing any business logic, the command class may require to fetch values that have been set on the view; following completion of any business logic, the final task may be for a command class to update the View (user interface) with any results returned, or perhaps to switch the View entirely (to a different screen).

By encapsulating all the logic necessary for interrogating and updating a particular View into a single helper class, we remove the need for the command classes to have any knowledge about the implementation of the View. The ViewHelper class decouples our presentation from the control of the application.

A ViewHelper belongs to a particular View in the application; when a ViewHelper is created, its id is used to register against a particular View component (such as a particular tab in a TabNavigator, or a particular screen in a ViewStack). The developer then uses the ViewLocator to locate the particular ViewHelper for interrogation or update of a particular View.

See also

com.adobe.cairngorm.model.ModelLocator
com.adobe.cairngorm.view.ViewLocator


Protected Properties
 PropertyDefined by
  id : String
The id of the view
ViewHelper
  view : Object
The view referred to by this view helper
ViewHelper
Public Methods
 MethodDefined by
  
initialized(document:Object, id:String):void
On initialization, the view is initialized with the ViewLocator with the ViewLocator, using its id.
ViewHelper
Property detail
idproperty
protected var id:String

The id of the view

viewproperty 
protected var view:Object

The view referred to by this view helper

Method detail
initialized()method
public function initialized(document:Object, id:String):void

On initialization, the view is initialized with the ViewLocator with the ViewLocator, using its id. On Event.REMOVED and Event.ADDED events of a view, the view is registered or unregistered from the ViewLocator.

The initialized method is called by the Flex component framework after a component has been initialized, so long as the component implements mx.core.IMXMLObject.

Parameters
document:Object
 
id:String