Darren,

 

 

If your XML nodes have attributes (ie. <node label=”foo”></node>) – you can use the ‘labelField’ attribute to control the labels.

 

            <mx:Tree id="myTree" labelField="@label"/>

 

 

If they don’t (ie. <foo>bar</foo>) – or if you want to do any sort of custom label logic, you need to use the ‘labelFunction’ attribute to set the values appropriately.

 

<mx:Tree id="myTree2 labelFunction="myLabelFunc"/>

 

                        public function myLabelFunc (item:XML):String{

                                     

                                    //if node has children

                                    if(item.children().toString() != ''){

                                                return item.name();

                                    }

                                    //no children, it’s a leaf so get the value

                                    else{

                                                return item.toXMLString();

                                    }

                        }

 

 

regards,

peter

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Darren Houle
Sent: Monday, August 21, 2006 4:33 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] How to cast a WebService lastResult when CFC returnType="xml"

 

Bump??

Darren

>From: "Darren Houle" <[EMAIL PROTECTED]com>
>Reply-To: [EMAIL PROTECTED]ups.com
>To: [EMAIL PROTECTED]ups.com
>Subject: [flexcoders] How to cast a WebService lastResult when CFC
>returnType="xml"
>Date: Fri, 18 Aug 2006 23:08:44 -0400
>
>I have a ColdFusion Component (web service) that looks like...
>
><cffunction name="getEmployees" access="remote" output="false"
>returntype="xml">
> <cfxml variable="myxml">
> <people>
> <person>
> <firstname>John</firstname>
> <lastname>Smith</lastname>
> <job>
> <title>Doctor</title>
> <description>blah blah blah</description>
> </job>
> </person>
> <person>
> <firstname>Jane</firstname>
> <lastname>Doe</lastname>
> <job>
> <title>Lawyer</title>
> <description>blah blah blah</description>
> </job>
> </person>
> </people>
> </cfxml>
> <cfreturn myxml>
></cffunction>
>
>and some Flex code that looks like...
>
><?xml version="1.0" encoding="utf-8"?>
><mx:Application
> xmlns:mx="http://www.adobe.com/2006/mxml"
> creationComplete="TestService.getEmployees.send();">
> <mx:WebService id="TestService" wsdl="http://localhost/hr.cfc?wsdl">
> <mx:operation name="getEmployees" />
> </mx:WebService>
> <mx:Tree
> id="myTree"
> width="50%"
> height="50%"
> showRoot="false"
> dataProvider="{TestService.getEmployees.lastResult}"/>
></mx:Application>
>
>But what I get is a Tree that looks like:
>
>Flex doesn't seem to be able to extract the XML from the SOAP message,
>which
>is just SOAP XML wrapping my XML data.
>
>Changing the Operation's resultFormat from "e4x" to "xml" to "object"
>changes the amount of junk in the Tree, but doesn't fix the problem. As a
>matter of fact, it works best when I leave off this attribute and let the
>Operation decide what resultFormat to use.
>
>Casting lastResult as XML or XMLList doesn't seem to help either, and
>neither does
>ArrayUtil.toArray(TestService.getEmployee.lastResult)
>
>Is there something I need to do to the lastResult to get it to work in
>Trees, DataGrids, etc? Like cast it as some other data type? Why doesn't
>e4x parse the SOAP message properly and extract my XML?
>
>Just about every example I can find out there shows people using
>HTTPService
>to pull back just the XML data without the SOAP webservice stuff, or else
>shows how to create XML inside the mxml code itself using <mx:XML> but I
>can
>find nothing that shows how to return XML from a CFC web service and
>use/parse it in Flex properly (as easy as, say, a CFC that returns a Query
>object.)
>
>Darren

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to