| Package | com.adobe.cairngorm.view |
| Class | public class ViewHelper |
| Implements | mx.core.IMXMLObject |
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
| Property | Defined by | ||
|---|---|---|---|
| id : String
The id of the view
| ViewHelper | ||
| view : Object
The view referred to by this view helper
| ViewHelper | ||
| Method | Defined by | ||
|---|---|---|---|
|
initialized(document:Object, id:String):void
On initialization, the view is initialized with the
ViewLocator
with the ViewLocator, using its id. | ViewHelper | ||
| id | property |
protected var id:StringThe id of the view
| view | property |
protected var view:ObjectThe view referred to by this view helper
| 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.
document:Object |
|
id:String |