Thursday, November 20, 2008

creation complete and puremvc

Seems when working with puremvc and flex events there are some hangups, in that not all events are useable.  The one I found was that creationComplete event triggered by modules.  What I wanted was to be able to populate certain dropdowns from database dynmically.   The onload event triggered prior to onregister function in the mediator.  Documented is the lifecycle. 

* Mxml creation
  * View components
  * Facade
* PureMVC startup  
  * Register proxies
  * Register mediators
* Request data
  * Proxy method (such as 'load') invoked by mediator or command
  * Proxy calls service directly or uses a delegate to do so. 
* Receive data
  * Proxy recieves result/fault return
  * if result then Proxy stores data internally, parsing if need be, possibly using a helper.
  * Proxy sends result or fault notification.
  * Interested mediators respond by setting data on view component.


To get around this I used a puremvc plugin called startup manager. 


introduction to startup manager

Creation complete
--post defined by cliff creator of puremvc
Link to puremvc forums about topic

Saturday, October 11, 2008

Flex-Mojos and working with modules

overview : I have several maven modules, maven java module - consists of java domain, and persistance, maven flex module - consists of actionscript files, and mxml, and any other supporting flex artifacts, maven web module- any related java, jsp, js, html, and anything responsible for packaging. I have one main application consisting of the shell, and several modules built in the same flex project. I assume , this is pretty standard setup, or something similar. So when packaging war. Using maven copy-dependencies plugin, we are able to copy the swf file as a dependency into the war.
- When maven compiles the flex package, it creates the main swf .. ex. flexapp.swf, and additional modules ex. flexmod1.swf . This gets created and installed in maven under the same group and artifact and id.
Took some time to figure out when packaging the war how to include all swf files in the war.

- this includes the main compiled swf


<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mainproj</artifactId>
<version>${project.version}</version>
<type>swf</type>
</dependency>



- to include the compiled modules


<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mainproj</artifactId>
<version>${project.version}</version>
<type>swf</type>
<classifier>nameofmodule</classifier>
</dependency>



use the classifier to specify the name of the compiled module.

Thursday, September 4, 2008

Flex Libraries - SWC and Maven

Handling these dependencies in maven, is just like any other library or jar. For example I'm using mate in my project ,

mvn install:install-file -DgroupId=com.asfusion.mate -DartifactId=mate -Dversion=0.7.8 -Dpackaging=swc -Dfile=<file path>Mate_07_8.swc

and now just add the dependency in your pom file ,


<dependency>
<groupId>com.asfusion.mate</groupId>
<artifactId>mate</artifactId>
<version>0.7.8</version>
<type>swc</type>
</dependency>



for more information refer to this post Adding Libraries to Compilation by velos from the flex-mojos blog

Monday, September 1, 2008

flex-mojos - getting started

What is flex-mojos?

A collection of maven plugins to allow maven to compile, optimize, test and ... Flex SWF, Flex SWC, Air SWF and Air SWC.The main goal is to provide a full support to all mxmlc/compc options. Also here is post from the author on why he wrote it. Flex Mojos Why

First we want to add the flex dependencies to maven to our local repository, or your remote repository. Download the flex sdk from here - Flex 3 SDK . Follow the instructions here Install Adob SDK Mojo .

In the root project add the flex mojos repository



<repositories>
<repository>
<id>flex-mojos-repository</id>
<url>http://svn.sonatype.org/flexmojos/repository/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>


Now we want to add pluginRepository next which is identical to repository



<pluginRepositories>
<pluginRepository>
<id>flex-mojos-repository</id>
<url>
http://svn.sonatype.org/flexmojos/repository/
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>


under build we add plugins - plugin



<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
</plugin>
</plugins>
</pluginManagement>
</build>


Now in the flex module under dependency all that is needed to handle all flex dependencies is this :




<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>3.0.3.2490</version>
<type>pom</type>
</dependency>
</dependencie



Now under build of the pom ..

<build>
<sourceDirectory>src/main/flex/</sourceDirectory>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>info.flex-mojos</groupId>
<artifactId>flex-compiler-mojo</artifactId>
<version>2.0M5</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>3.0.3.2490</version>
<type>pom</type>
</dependency>
</dependencies>
<configuration>
<locales>
<param>en_US</param>
</locales>
</configuration>
</plugin>
</plugins>
</build>



Thats it...

Anytime you want to upgrade to a newer version of the sdk , just install and change version numbers. Super simple.

run mvn install , and everything should be good.

Wednesday, August 27, 2008

Flex and Java and Me - Getting Started

The technology stack I'm going to use is flex, actionscript 3 .. using pure mvc, mate, or caingorm ( this requires another writeup) for the front end. Back end will be using java - spring , hibernate. So now that the easy stuff is out of the way, I'm going to setup the frame for the project using maven to manage dependencies, and builds. I went through this tutorial Flex, Spring and BlazeDS full Stack, and it was very good to get a good start running on the build and management tools. I will build and expand on this tutorial, to organize and manage everything easier.

Adobe released Flex Builder Linux. Im using alpha 4 currently. Start with getting eclise 3.3 as I issues with ganymede 3.4 and Flex Builder alpha 3, but may have been resolved with alpha 4. Also I'm using Q for Eclipse plugin.

Refer back to the original tutorial I followed for most examples.
So to start first thing to do is create a root project. This is where all modules will be placed under. In eclipse or maven directly create a project archetype quick-start.
1. delete the "src" directory, its not necessary.
2. Edit pom.xml change packaging to "pom" instead of "jar"
3. create a maven module for your flex for example projname-ria.

Creating a Flex Module
Create a maven module under the root project. The archetype is the maven-archetype-flex.
To have maven handle the adobe flex dependencies and to compile, I am currently using the - flex mojos - project. Some really excellent work is being done on this project. Refer to my writeup here - flex-mojo - getting started

Creating - Java
Next I wil create a core module - maven-archetype-quickstart and a web module - maven-archetype-webapp. The only thing I would consider is creating a commons project. If you intend on creating library reusable classes, then its probably good to create it as a separate project. Refactor later.
Now for dependencies, add Spring 2.5.5 , and hibernate 3.2.6.ga as these are pretty much the middle tier and persistence tier frameworks we will be working with.

Now pretty much follow the tutorial for the configuration module, and the plugins to put everything together. The only other catch is in the mxml files refer to the full namespace


<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"



and in the article they just refer to /2006/mxml and you will get compile errors.