Build your dataProvider e4x expression in the result handler (using
event.result, not lastResult) instead of binding, so you can make sure
it is correct.

 

Build it a step at a time, inspecting the xml using toXMLString();

 

When you can trace an XMLList that contains the nodes you want, we will
go from there.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of gabsaga
Sent: Friday, July 18, 2008 3:18 PM
To: [email protected]
Subject: RE: [flexcoders] Display XML in DataGrid

 


Tracy,

After making the change as you instructed, I see now that my DataGrid
has
horizontal scroll bars after the data is returned but still nothing gets
displayed. Here is my mxml file content:

<?xml version="1.0" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
xmlns:ns1="http://simpaq.com/service <http://simpaq.com/service> ">

<mx:Script>
<![CDATA[

import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.utils.ObjectUtil;
import mx.controls.Alert;
import mx.utils.StringUtil;

private function resultHandler(event:ResultEvent):void 
{
//used for debugging - shows details about result
//returned by the Java class method

//Alert.show( ObjectUtil.toString(event.result) );
}

private function faultHandler(event:FaultEvent):void
{
Alert.show( ObjectUtil.toString(event.fault) );
}

default xml namespace = "http://simpaq.com/service
<http://simpaq.com/service> ";
]]>
</mx:Script>

<mx:WebService id="ws" 
wsdl="http://localhost:8085/axis/services/ContactService?wsdl
<http://localhost:8085/axis/services/ContactService?wsdl> " 
useProxy="false" 
showBusyCursor="true" 
result="resultHandler(event)" 
fault="faultHandler(event)">
<mx:operation name="getContacts" resultFormat="e4x">
</mx:operation> 
</mx:WebService>

<mx:Panel x="10" y="10" width="540" height="460" layout="vertical"
title="Test Flex 3 Using Java" borderColor="#008040" fontFamily="Arial"
fontWeight="bold" fontSize="13">

<mx:TextArea id="myTextArea"
text="{ws.getContacts.lastResult.toXMLString()}" width="100%"
height="253" 
fontSize="12"/>

<mx:Spacer height="20"/>

<mx:DataGrid id="list"
dataProvider="{ws.getContacts.lastResult.getContactsReturn}"
width="100%"
height="100%" > 
<mx:columns>
<mx:DataGridColumn dataField="contactId" headerText="Contact ID" />
<mx:DataGridColumn dataField="firstName" headerText="First Name" />
<mx:DataGridColumn dataField="lastName" headerText="Last Name" />
<mx:DataGridColumn dataField="phoneNumber" headerText="Phone Number" />
<mx:DataGridColumn dataField="emailAddress" headerText="Email Address"
/> 
</mx:columns>
</mx:DataGrid>

<mx:Spacer height="20"/> 

<mx:Button label="Get Contacts" click="ws.getContacts()"/>

</mx:Panel>

</mx:Application>

Thanks.

Gabsaga

Tracy Spratt wrote:
> 
> Ah, no, this is a different "namespace". The attributes in the
> Application tag define class compilation namespaces, that is, it tells
> the compiler where to find a component source file.
> 
> 
> 
> XML namespace is different. That line is AS script code and in goes in
> a script block at the instance scope level, that is the "global"
level,
> outside of any function.
> 
> 
> 
> Tracy
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of gabsaga
> Sent: Friday, July 18, 2008 1:29 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] Display XML in DataGrid
> 
> 
> 
> 
> Tracy,
> 
> Thanks for your response. Is the entry going to look like the
following
> in
> my mxml file?
> 
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
default xml
> namespace="http://simpaq.com/service <http://simpaq.com/service>
<http://simpaq.com/service <http://simpaq.com/service> > ">
> 
> Thanks.
> 
> Gabsaga
> 
> Tracy Spratt wrote:
>> 
>> WebService XML tends to have namespace issues.
>> 
>> 
>> 
>> Try adding this at the instance scope level:
>> 
>> default xml namespace = "http://simpaq.com/service
<http://simpaq.com/service> 
> <http://simpaq.com/service <http://simpaq.com/service> > "; 
>> 
>> 
>> 
>> Tracy
>> 
>> ________________________________
>> 
>> From: [email protected]
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> [mailto:[email protected]
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> ] On
>> Behalf Of gabsaga
>> Sent: Thursday, July 17, 2008 4:59 PM
>> To: [email protected] <mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com> 
>> Subject: [flexcoders] Display XML in DataGrid
>> 
>> 
>> 
>> 
>> I have the following XML being returned to my Flex application. How
> can
>> parse
>> it so that it displays in a DataGrid?
>> 
>> I was able to get the XML to display in a textarea by using the
>> following
>> code:
>> 
>> <mx:TextArea id="myTextArea"
>> text="{ws.getContacts.lastResult.toXMLString()}" width="100%"
>> height="253" 
>> fontSize="12"/>
>> 
>> <getContactsResponse xmlns="http://simpaq.com/service
<http://simpaq.com/service> 
> <http://simpaq.com/service <http://simpaq.com/service> > 
>> <http://simpaq.com/service <http://simpaq.com/service>
<http://simpaq.com/service <http://simpaq.com/service> > > "
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> 
> <http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> > 
>> <http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> 
> <http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> > > "
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> 
> <http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> >

>> <http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema>
<http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> > >
> "
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> 
> <http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> > 
>> <http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> 
> <http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> > > ">
>> <getContactsReturn>
>> <ns1:contactId xmlns:ns1="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> >
<http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> >
>>
>> ">1111</ns1:contactId>
>> <ns2:emailAddress
>> xmlns:ns2="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">[EMAIL PROTECTED] <mailto:freddy.colmbs%40simpaq.com>
<mailto:freddy.colmbs%40simpaq.com>
> <mailto:freddy.colmbs%40simpaq.com>
>> </ns2:emailAddress>
>> <ns3:firstName xmlns:ns3="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> >
<http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> >
>>
>> ">Freddy</ns3:firstName>
>> <ns4:lastName xmlns:ns4="http://dto.simpaq.com
<http://dto.simpaq.com>  <http://dto.simpaq.com <http://dto.simpaq.com>
>
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">Colmbs</ns4:lastName>
>> <ns5:phoneNumber
>> xmlns:ns5="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">555-897-9855</ns5:phoneNumber>
>> </getContactsReturn>
>> <getContactsReturn>
>> <ns6:contactId xmlns:ns6="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> >
<http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> >
>>
>> ">2222</ns6:contactId>
>> <ns7:emailAddress
>> xmlns:ns7="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">[EMAIL PROTECTED] <mailto:john.doe%40cameroontrader.com>
<mailto:john.doe%40cameroontrader.com>
> <mailto:john.doe%40cameroontrader.com>
>> </ns7:emailAddress>
>> <ns8:firstName xmlns:ns8="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> >
<http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> >
>>
>> ">John</ns8:firstName>
>> <ns9:lastName xmlns:ns9="http://dto.simpaq.com
<http://dto.simpaq.com>  <http://dto.simpaq.com <http://dto.simpaq.com>
>
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">Doe</ns9:lastName>
>> <ns10:phoneNumber
>> xmlns:ns10="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">555-611-0081</ns10:phoneNumber>
>> </getContactsReturn>
>> <getContactsReturn>
>> <ns11:contactId xmlns:ns11="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> > 
>> <http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> > >
> ">3333</ns11:contactId>
>> <ns12:emailAddress
>> xmlns:ns12="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">[EMAIL PROTECTED] <mailto:mary.jane%40simpaq.com>
<mailto:mary.jane%40simpaq.com>
> <mailto:mary.jane%40simpaq.com>
>> </ns12:emailAddress>
>> <ns13:firstName xmlns:ns13="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> > 
>> <http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> > >
> ">Mary</ns13:firstName>
>> <ns14:lastName xmlns:ns14="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> >
<http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> >
>>
>> ">Jane</ns14:lastName>
>> <ns15:phoneNumber
>> xmlns:ns15="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">555-209-4389</ns15:phoneNumber>
>> </getContactsReturn>
>> <getContactsReturn>
>> <ns16:contactId xmlns:ns16="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> > 
>> <http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> > >
> ">4444</ns16:contactId>
>> <ns17:emailAddress
>> xmlns:ns17="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">[EMAIL PROTECTED] <mailto:cow.boy%40cameroontrader.com>
<mailto:cow.boy%40cameroontrader.com>
> <mailto:cow.boy%40cameroontrader.com>
>> </ns17:emailAddress>
>> <ns18:firstName xmlns:ns18="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> > 
>> <http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> > >
> ">Cow</ns18:firstName>
>> <ns19:lastName xmlns:ns19="http://dto.simpaq.com
<http://dto.simpaq.com> 
> <http://dto.simpaq.com <http://dto.simpaq.com> >
<http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> >
>>
>> ">Boy</ns19:lastName>
>> <ns20:phoneNumber
>> xmlns:ns20="http://dto.simpaq.com <http://dto.simpaq.com>
<http://dto.simpaq.com <http://dto.simpaq.com> >
> <http://dto.simpaq.com <http://dto.simpaq.com>  <http://dto.simpaq.com
<http://dto.simpaq.com> > >
>> ">555-298-9455</ns20:phoneNumber>
>> </getContactsReturn>
>> </getContactsResponse>
>> 
>> I tried the following to get it to display in a DataGrid but it
didn't
>> work.
>> 
>> <mx:DataGrid id="list"
>> dataProvider="{ws.getContacts.lastResult.getContactsReturn}"
>> width="100%"
>> height="100%" >
>> <mx:columns>
>> <mx:DataGridColumn dataField="contactId" headerText="Contact ID" />
>> <mx:DataGridColumn dataField="firstName" headerText="First Name" />
>> <mx:DataGridColumn dataField="lastName" headerText="Last Name" />
>> <mx:DataGridColumn dataField="phoneNumber" headerText="Phone Number"
> />
>> <mx:DataGridColumn dataField="emailAddress" headerText="Email
Address"
>> /> 
>> </mx:columns> 
>> </mx:DataGrid>
>> 
>> Any help will be greatly appreciated. 
>> 
>> Thanks.
>> 
>> Gabsaga
>> -- 
>> View this message in context:
>>
http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html>

>
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html>
>
> 
>>
>
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html>

>
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html>
>
>>
>> 
>> Sent from the FlexCoders mailing list archive at Nabble.com.
>> 
>> 
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18534217.html
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18534217.html>

>
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18534217.html
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18534217.html>
>
> 
> Sent from the FlexCoders mailing list archive at Nabble.com.
> 
> 
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18536094.html
<http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18536094.html>

Sent from the FlexCoders mailing list archive at Nabble.com.

 

Reply via email to