Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Section
Column
width15px

Column

Page Contents:

Table of Contents
minLevelmaxLevel4
maxLevelminLevel4

View Mediator Support

Swiz includes two metadata tags which support the view mediator pattern. This allows references to views to be supplied to other beans. These two tags are [ViewAdded] and [ViewRemoved]. The tags have no attributes, so using them is very straightforward.

[ViewAdded] and [ViewRemoved] can be specified on properties, setters or methods in beans. Swiz will pass in any instances of the type specified that it detects have been added to or removed from stage. The events that trigger these actions are those specified in your SwizConfig's setUpEventType and tearDownEventType properties.

For example:


Code Block
as3
as3
[ViewAdded]
public function userListViewAdded( view : UserListView ) : void
{
    this.view = view;
}

[ViewRemoved]
public function userListViewRemoved( view : UserListView ) : void
{
    this.view = null;
}


Note

The existence of these tags in a Prototype bean will not trigger the creation of that bean just because a matching view is added/removed. The bean instance containing these tags must already exist when the view event occurs.


ViewNavigator Metadata Tag

In Flex mobile projects, you can now use the [ViewNavigator] tag to get a reference to the ViewNavigator instance in non-view classes. This works in a manner similar to [ViewAdded]:


Code Block
as3
as3
[ViewNavigator]
public var viewNavigator : ViewNavigator;


Note

Note that a ViewNavigator injection is not guaranteed to be populated by the time [PostConstruct] methods run, due to the timing around the creation of the ViewNavigator by the Flex mobile SDK.

Column
width15%