Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

A Lightning Look at Configuration

Configuring Swiz in your Flex or AIR application is very straightforward: declare Swiz, define the beanProviders and config properties, and optionally define one or more loggingTargets to view debugging messages. Here is an example:

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_main.xml"></script>


Non-visual components that you want Swiz to manage are defined in a BeanProvider tag. Any beans that you define within the BeanProvider are processed by Swiz for dependency injection and the creation of event mediators. In the following example, a UserService and a UserController are created:

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_beans.xml"></script>

The "Big Three": Dependency Injection, Event Handling, and Server Interaction

The three most commonly used features of Swiz are its dependency injection capabilities, its event handling features, and its server interaction utilities. Let's look at how each of these work.

Adding Dependency Injection

Dependencies are injected by using [Inject] metadata. In this example, the UserService is injected into the UserController:

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_usercontroller.java"></script>


In addition to injecting a bean, you can inject individual bean properties. In this example, the currentUser property of the UserController is injected into a UserForm visual component. Note that it is not necessary for the UserForm to be declared as a bean in the BeanProviders tag. When visual components are added to the display list, Swiz automatically inspects them and processes any metadata tags that are found.

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_userform.mxml"></script>

Dispatching and Handling Events

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_userform2.mxml"></script>

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_userevent.java"></script>

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_usercontroller2.java"></script>

Talking to the Server

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_usercontroller3.java"></script>

Unknown macro: {html}

<script src="http://gist.github.com/383055.js?file=quickswiz_userservice.java"></script>

There's More Where That Came From

  • No labels