Swiz Flex framework – presentation and example app

Categorized Under: Flex, RIA, Swiz

Please find attached my presentation about Swiz from yesterday. As I already said, I like Swiz and I will definitively use it in my projects where I think it’s appropriate. Not only because I’m Swiss ;) , but also because it addresses the main things I miss in Flex like IoC, sometimes don’t like in PureMVC like boilerplate code or just built over and over again like the dynamic channels.

In my example, at one place I dispatch an event in my view where my controller is listening for (dynamic dispatcher and [Mediate]) and in the other place I call the method directly on the autowired controller and I use binding to update the view. I think mixing the two styles is ok, but in a real live app I would let my view know about the controller only if it’s more a data app with crud functionality. If the view components and app controller becomes more complex I would use the dispatch/mediate style and introduce some mediator or presenter to decouple the view from the controller completely. This is more like PureMVC or MATE advocate. I will add an example about this in another post.

Maybe another difference of my approaches is that my service is an interface an I use it directly in my controller, either the mock or the real service, without going over a delegate. On the other side my java class is called a delegate because most of the time I use a façade for the business logic where my delegate dispatches the BlazeDS request from the web app to the backend. This means my service is in Flex, my delegate and BlazeDS in my war webapp and my façade in my backend jar, but I have put everything together for the example.

Here are the links:

Swiz
http://code.google.com/p/swizframework/

Chris Scott’s video from 360flex
http://www.onflash.org/ted/2008/09/360flex-sj-2008-introduction-to-swiz.php

I also like Joe Rinehart’s MockAsyncToken
http://blog.broadchoice.com/index.cfm/2008/8/18/Swiz-and-MockAsyncToken

As Chris Scott wrote on the swiz google group, he plans to include the MockAsyncToken into Swiz, that’s why I like Swiz it’s just about making my live easier and what more could you ask for…

You can download the presentation and example zip from here.

In the example, the swiz library project contains swiz in version 0.0.3-SNAPSHOT, but I don’t use maven to build it yet, so I just named the library project swiz. I added it so you can also look and debug the swiz code nicely and even add some log info. The Alcon logger in the libs folder. http://osflash.org/projects/alcon

The java app is in swiz-mercator-backend under target, just deploy it on the server of your joice. If you want to build the example backend app and play around with it, import them into eclipse and let maven download all jars so that everything needed is available. I use the m2eclipse plugin to use maven in eclipse. If you don’t use maven yet, of course you have to install anything first and I’m afraid you have to google this out, but this shuld be no probl.

The pom expects the BlazeDS flex.jars in the maven repository under groupId com.adobe.flex, artifactId blazeds-*, version 3.0.1 etc. You can downloaded BlazeDS 3.0.1 stable from opensource.adobe.com http://opensource.adobe.com/wiki/display/blazeds/download+blazeds+3 and then use the following maven command on the command line to install the BlazeDS jars in your local maven repository:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id>   -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

for example I use

mvn install:install-file -Dfile=flex-messaging-common.jar -DgroupId=com.adobe.flex   -DartifactId=blazeds-common -Dversion=3.0.1 -Dpackaging=jar

As you can see I rename the jars because we are all still waiting to be able to download the official ones from a maven repository (hint, hint Adobe), this way my naming will not interfere with an official Adobe artifactId. It’s the same naming Swiz is using in it’s example app which you can download from the swiz project website. Of course you can use your own structure, just don’t forget to change the pom file.

Have fun, cheers
Roland

5 Responses to “Swiz Flex framework – presentation and example app”

  1. Jan Van Coppenolle says:

    Very interesting project.

    Regarding the MockAsyncToken, i’ve created something similar for my MockRemoteObject class. I’ll create a post about that here later.

  2. wow gold says:

    A man becomes learned by asking questions

  3. Kris Hofmans says:

    Nice work there Roland, everything is fine at mediafoundry I hope? I actually arrived here while doing some google-ing on swiz and maven. Because I have a flex app that I’m building with maven, I just need to add the swiz framework, I can easily add it to my local repository but would prefer a more extensive repo than flex-mojos … :)

  4. Interesting website, i have bookmarked your site for future referrence :)

  5. Great post! I’ll subscribe right now wth my feedreader software!

Leave a Reply