2. Flex application initialization
Application initialization
First you have to determine the correct integration singleton for your application. It's easy, it just depends on the server framework that you use :
choose from Spring, Seam, Ejb, Cdi. It's even possible to use the Tide framework if you don't use GraniteDS as the AMF remoting provider by initializing the application with the singleton Tide.
The initialization of the Tide application simply consists in a preinitialize handler in the main application :
<mx:Application preinitialize="Tide.getInstance().initApplication()"> <mx:Script> <![CDATA[ import org.granite.tide.Tide; ]]> </mx:Script> ... </mx:Application>
Tide.getInstance().initApplication() must be called in the application preinitialize handler. It will register the application with the Tide runtime.
Client-side setup for remoting
For some Tide server configurations, there is no need for a services-config.xml file.
In theses cases, it is then required to initialize manually the Flex remoting channels that will be used by Tide. The most simple way is to use the DefaultServiceInitializer component (of course don't forget to change the context root to your web app path) :
<mx:Application preinitialize="Tide.getInstance().initApplication()"> <mx:Script> <!CDATA[ import org.granite.tide.service.DefaultServiceInitializer; Tide.getInstance().addComponent("serviceInitializer", DefaultServiceInitializer, { contextRoot: "/my-app" }); ]]> </mx:Script> ... </mx:Application>
DefaultServiceInitializer is the default built-in implementation. It's however possible to use your own custom implementation. The class just has to implements IServiceInitializer.
