views:

15

answers:

0

I want to use the Parsley framework and I want to use GraniteDS for remoting. As of 2.1, GraniteDS generates AS3 service classes from your Java code as local proxies, and I want to use these classes in Parsley.

I can successfully inject the service classes with Parsley but when I call any of their methods I get a null object error

at org.granite.tide::Component/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[C:\workspace_\graniteds\as3\framework\org\granite\tide\Component.as:172]
at library::BookServiceBase/get()[C:\Documents and Settings\MedLineTec\Adobe Flash Builder 4\library\src\library\BookServiceBase.as:36]

This would be because Parsley is creating instances of the service classes without actually injecting them with the relevant "context" to do the GraniteDS remoting. I need to figure out how to give the GraniteDS context to the service classes which parsley instantiates. I saw a post on the parsley forums where someone recommended:

<parsley:ContextBuilder>
      <parsley:FlexConfig type="{UserManagerConfig}"/>
      <parsley:RuntimeConfig instances="{[tideContext]}" />
</parsley:ContextBuilder>

...

[Bindable]
private var tideContext:Context = Spring.getInstance().getSpringContext(); 

But that didn't work for me. I'm familiar with GraniteDS but not with Parsley so maybe this is the solution but applying it correctly is above my head.

If someone has it going with another framework like Swiz or Spring ActionScript then please also pass that solution on as it might be very similar.

UPDATE: I figured out by reading the Granite source code that after I inject a service with Parsley (e.g. bookService), if I run

private var tideContext:Context = Spring.getInstance().getSpringContext(); 
bookService.meta_init("bookService", tideContext);

Then I can successfully use the service. So I guess I just need to know how to do this in a sort of automatic way with all the services I declare in Parsley.