Tagged: prana

Spring AS & Prana woes with blank prop or constructor args

UPDATE: The bug described here appears to be fixed as of 0.8

So I’ve been doing a fair amount of work with Spring Actionscript v0.7.1 (formally the Prana Framework). In AS3 you can define methods and/or constructors that take optional arguments. Optional arguments must always be defined after the required arguments and they are noted by the presence of a default value in the method/constructor signature as such:

package my {
   public class MyClass {

      public function MyClass(reqArg1:String, opArg1:Boolean=false, opArg2:String=null):void {
         // your constructor code for MyClass here;


When you are defining a bean in Spring AS you can define it’s constructor arguments as so:

<object id="myClassInst"       class="my.MyClass"       scope="prototype">                          <!-- required arg 1-->   <constructor-arg value="val4ReqArg1"/>   <!-- pass false for optional boolean arg 2 -->    <constructor-arg value="false"/>    <!-- intentionally pass BLANK to 3rd optional arg -->    <constructor-arg value=""/></object>

Well when running this  you will get an error like this for the 3rd argument:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at org.springextensions.actionscript.ioc.factory.xml. parser.support.nodeparsers::KeyValueNodeParser/parse()
at org.springextensions.actionscript.ioc.factory.xml. parser.support::XMLObjectDefinitionsParser/parsePropertyValue()
at org.springextensions.actionscript.ioc.factory.xml. parser.support::XMLObjectDefinitionsParser/parseProperty()
at org.springextensions.actionscript.ioc.factory.xml. parser.support::XMLObjectDefinitionsParser/parseProperties()

This is a bug in Prana (see here http://jira.springframework.org/browse/SESPRINGACTIONSCRIPTAS-49), to get around this until it is fixed, you will need to pass some dummy value, that your constructor code will interpret as a BLANK, such as literally the string “BLANK”. Stupid? Yes, but until this is fixed in Spring AS this is the solution unfortunately!


Prana Framework is now under the Spring umbrella

Great news and I’ve been hoping for this for quite a while. Spring has taken the Prana Framework under its wing and added it as an official Spring extension called Spring Actionscript. Here is another post about this.

When I first got into developing in AS3/Flex this past summer I immediately began looking for some sort of “Spring like” bootstrap/DI container for AS3 apps. Well the playing field was pretty slim. The two main ones out there were SpiceFactory’s Parsley project and the Prana Framework. I tended to like Prana’s because at the time it was much closer to Spring and quite lightweight. I also compared the functionality and activity on the forums and it appeared that Prana was getting more traction. As I posted previously, due to the uncertainty of who would come out the winner in the AS3 IOC world I ended up putting in a light IOC container abstraction layer in my AS3 API as to not be bound too tightly to any one implementation… as my app was only calling variations of <code>getObject()</code> to fetch services etc.

So here we are several months later and with this news that Spring is officially making Prana it’s AS3 extension of Spring, I think we made the right decision. This is great news