Passing Persistent Data to Modules
If you are able to load your flex module that has data that needs to save to a db and it works the first time, but then you close it and then it gives your a error when saving.
ERROR: [RPC Fault faultString="Unable to invoke CFC - Variable OBJ is undefined." faultCode="Server.Processing" faultDetail=""]
From time to time I end up banging my head against the wall for a couple of days. Since I have no classroom training. It is all been on the job. Sink or Swim….lol
Problem: You created a module with a form that uses CFC and Remote Object with a Valued Object in Flex 3 and when load the module for the first time. Tada, It works. Now close the module and open it back up. and try to save again. ERRRR
This is becuase we need to have send the persistant data that we have in our main application to be in our module. When you close the module, it basically kills the data to that module. I even tried to query from inside the module, with no luck
How to solve it?
ModuleLoader has a property called “ready”. This function is called before I open my module. This is where I can pass persistent data to my module or to other modules.
First, Identify which module you are loading, the ready property is called each time you load a module.
if(module.child is MD00Configuration){ }
Second, pass the data you need to your module.
var configuration:MD00Configruation = module.child as MD00Configuration; configuration.myObject = ConfigObj;
So here is some example code
//Main MXML Application <mx:ModuleLoader id="module" ready="readyHandler(event)"/>
//AS [Bindable] public var ConfigObj:Object = new Object(); private function readyHandler(event:Event):void { if(module.child is MD00Configuration){ var configuration:MD00Configruation = module.child as MD00Configuration; configuration.myObject = ConfigObj; } }
//Module <mx:TextInput text="ConfigObj.MyVariable"/>