Flex XMLList to CFC
I have an XMLList dataProvider in Flex that I want to pass to a cfc and insert the data into the database. How do I received the XMLList on the CF side and insert the data into the database?
my hierarchical XML is pretty basic:
<Nodes>
<Node level="0" tabID="1" tab="reports" cb="true">
<Node level="1" tabID="11" tab="reports quality" cb="true">
<Node level="2" tabID="21" tab="quality design" cb="true">
<Node level="3" tabID="33" tab="quality design summary" cb="true"/>
<Node level="3" tabID="32" tab="quality design reviews" cb="false"/>
</Node>
</Node>
</Node>
...
...
</Nodes>
I pass an XML string from Flex via RemoteObject call
Flex client side
private function saveRole():void{
var myObj:Object = new Object();
myObj.roleID = roleID.text;
myObj.role = role.text;
myObj.roleTabs = tabsXML.toXMLString();
cfdata.saveRoleUsers({mydata:myObj});
}
cfdata is the remoteObject call not shown
coldfusion cfc side
<CFFUNCTION NAME="SAVEROLEUSERS" ACCESS="REMOTE" RETURNTYPE="VOID">
<CFARGUMENT NAME="MYDATA" TYPE="STRUCT" REQUIRED="YES">
I need to read in #mydata.roleTabs# , which is the XML String and loop trough all nodes and insert
how do read the XML string and loop through it, and insert?
<CFQUERY NAME="INSERT" DATASOURCE="#DSN#">
INSERT INTO ROLES_TABS (roleID,tabID,cb)
VALUES (#mydata.roleID#,#?????#,#???#)
</CFQUERY>
Secondly, as a test I'm just trying to see what is contained in mydata.roleTabs on the cfc side. I keep getting error message that say mydata.roleTabs is empty when I try to dump the variable to a PDF. But, I see in the Flex Network monitor that the roleTabs XML string is there and being sent. CF9 just isn't seeing it or my code is wrong?
<cfdocument format="PDF" overwrite="yes" filename="xml.pdf">
<cfdump var="#mydata.roleTabs#">
</cfdocument>
or
<cfdocument format="PDF" overwrite="yes" filename="xml.pdf">
<cfoutput>
'#mydata.roleTabs#'
</cfoutput>
</cfdocument>
So, I need to figure out why CF isn't getting the XML and they learn how to loop through it to insert.
I'd appreciate any assistance with either issue.
Thanks,
Don Kerr
