RE: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-29 Thread Tracy Spratt
Or, if you are committed to WebService:

ResultFormat = object causes Flex to convert the WebService SOAP xml
into a tree of dynamic objects.  This has many drawbacks and few
benefits.

 

Set resultFormat=e4x and either use the XML directly, or wrap the
desired XMLList in an XMLListCollection, or loop over the XMLList and
build an ArrayCollection of strongly typed value objects.

 

If you go this way, be sure to inspect the result xml.  SOAP adds
several layers you will need to navigat through to get to your real
data.

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Amy
Sent: Wednesday, January 28, 2009 11:47 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Setting data from web service to
ArrayCollection.

 

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Wally Kolcz wko...@... wrote:

 Well, since this is question only contains a single example, the 
issue of not knowing is going to be more for other items in this 
project such as a list of ALL the projects, or ALL the teams, or ALL 
the users, etc. I suppose returning a single object with the logged in 
user's information is the best way to approach my login, but when it 
comes to the next items, I am still going to have the issue with not 
knowing how to capture all the information. Guess I'll have to wait and 
see.

I think you said that your resultFormat was set to Object. That 
being the case, Flex isn't going to take that one Object and make an 
ArrayCollection out of it.

Why are you bothering with the extra hassle of WebServices anyway? Why 
not use Remoting?

 



[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-28 Thread Amy
--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 Don't understand the question. Please educate me :-)

Collection=multiple things
Unique=1 thing

Usually, in a database you have a field that acts as a primary key, 
which means that there's only ever going to be one record in the table 
with that value.  Uniquename strongly suggests that it's intended to 
work that way.  So why would you be expecting to receive back an 
ArrayCollection when you're only ever going to get one thing based on 
your query?



re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-28 Thread Wally Kolcz
Well, since this is question only contains a single example, the issue of not 
knowing is going to be more for other items in this project such as a list of 
ALL the projects, or ALL the teams, or ALL the users, etc. I suppose returning 
a single object with the logged in user's information is the best way to 
approach my login, but when it comes to the next items, I am still going to 
have the issue with not knowing how to capture all the information. Guess I'll 
have to wait and see.


From: Amy amyblankens...@bellsouth.net
Sent: Wednesday, January 28, 2009 5:09 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Setting data from web service to  ArrayCollection. 

--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:



 Don't understand the question. Please educate me :-)

Collection=multiple things

Unique=1 thing

Usually, in a database you have a field that acts as a primary key, 

which means that there's only ever going to be one record in the table 

with that value.  Uniquename strongly suggests that it's intended to 

work that way.  So why would you be expecting to receive back an 

ArrayCollection when you're only ever going to get one thing based on 

your query?





[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-28 Thread valdhor
If you could provide the location of the Web Service and the WSDL, I
could put together a quick example.


--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 I am using mx:WebService and I have the resultFormat set to object.
 
 
 From: Tracy Spratt tspr...@...
 Sent: Tuesday, January 27, 2009 1:20 PM
 To: flexcoders@yahoogroups.com
 Subject: RE: [flexcoders] Re: Setting data from web service to 
ArrayCollection. 
 
 I do not know Cold Fusion, but.   Which RPC protocol are you actually
 using?  Have you set resultFormat? 
 
 Tracy Spratt 
  Lariat Services  
 
 Flex development bandwidth available  
 
  From: flexcoders@yahoogroups.com
[mailto:flexcod...@yahoogroups.com] On Behalf Of Wally Kolcz
 Sent: Tuesday, January 27, 2009
 3:39 PM
 To:flexcoders@yahoogroups.com
 Subject: Re: [flexcoders] Re:
 Setting data from web service to ArrayCollection.   
 
 Ok, lets
 take this the other way. Here is my simple CFC. How can I modify
this to return
 a result to Flex to which I can then set to an ArrayCollection that
I can use?
 
 cfcomponent
 
 cffunction name=login
 access=remote returntype=query output=false
 hint=I attempt a login
 
 cfargument name=username
 type=string required=yes /
 
 cfargument
 name=password type=string required=yes
 /
 
 cfquery name=result
 datasource=PRMC_Projects
 
 Select * FROM users
 
 WHERE
 uniqname = cfqueryparam value=#arguments.username#
 AND password = cfqueryparam value=#arguments.password#
 /
 
 /cfquery
 
 cfreturn result /
 
 /cffunction
 
 /cfcomponent





[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-28 Thread Amy
--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 Well, since this is question only contains a single example, the 
issue of not knowing is going to be more for other items in this 
project such as a list of ALL the projects, or ALL the teams, or ALL 
the users, etc. I suppose returning a single object with the logged in 
user's information is the best way to approach my login, but when it 
comes to the next items, I am still going to have the issue with not 
knowing how to capture all the information. Guess I'll have to wait and 
see.

I think you said that your resultFormat was set to Object.  That 
being the case, Flex isn't going to take that one Object and make an 
ArrayCollection out of it.

Why are you bothering with the extra hassle of WebServices anyway?  Why 
not use Remoting?



[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread valdhor
Perhaps you have an arrayCollection of arrayCollections (What does the
debugger show as the result type?). You may like to try...

var resultArrColl:ArrayCollection = e.result.source;
var firstResult:ArrayCollection = resultArrColl[0];
Alert.show(firstResult[0]);


--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 I moved my CFC and database to my localhost so I can debug the
webservice output and see it. I am a wee bit confused. The results
panel is saying something like this:
 
 e -- result -- source -- [0] -- firstName (etc)
 
 How do I set that local? 
 
 I tried myData = e.result.source as ArrayCollection and then tried
to trace myData.getItemAt(0).firstName but got an error. 
 
 
 From: Wally Kolcz wko...@...
 Sent: Tuesday, January 27, 2009 5:30 AM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Setting data from web service to ArrayCollection. 
 
 I am so trying to wrap my head around web services and use them for
my projects since we Blue Dragon here at the U. I have my CFCs and
they seem to work fine. However, I have no idea on how to set the
'return value' for a web service to an arraycollection to use it. I am
used to RemoteObjects that I can just set and then use
myData.getItemAt(0).name...
 
 I have a query to my database that returns one row of records
through a web service. It is returned to my Flex app and I am trying
to get it to an ArrayCollection variable for use in the application. I
was watching a Lynda video that uses something like:
 
 myData = e.result.Tables.Table0.Rows as ArrayCollection. Now is that
how you can set that row's columns at the value of the
ArrayCollections? Or is this only going to work for the video scenerio?
 
 Thanks for any info!





Re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Fotis Chatzinikos
Why do not you try Alert.show(ObjectUtil.toString(e.result)) //replace
e.result with e to see the whole event

ObjectUtil is very useful in situation like this as it show a textual
representation of any object graph

On Tue, Jan 27, 2009 at 5:37 PM, valdhor valdhorli...@embarqmail.comwrote:

   Perhaps you have an arrayCollection of arrayCollections (What does the
 debugger show as the result type?). You may like to try...

 var resultArrColl:ArrayCollection = e.result.source;
 var firstResult:ArrayCollection = resultArrColl[0];
 Alert.show(firstResult[0]);


 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Wally
 Kolcz wko...@... wrote:
 
  I moved my CFC and database to my localhost so I can debug the
 webservice output and see it. I am a wee bit confused. The results
 panel is saying something like this:
 
  e -- result -- source -- [0] -- firstName (etc)
 
  How do I set that local?
 
  I tried myData = e.result.source as ArrayCollection and then tried
 to trace myData.getItemAt(0).firstName but got an error.
 
  
  From: Wally Kolcz wko...@...
  Sent: Tuesday, January 27, 2009 5:30 AM
  To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com
  Subject: [flexcoders] Setting data from web service to ArrayCollection.
 
  I am so trying to wrap my head around web services and use them for
 my projects since we Blue Dragon here at the U. I have my CFCs and
 they seem to work fine. However, I have no idea on how to set the
 'return value' for a web service to an arraycollection to use it. I am
 used to RemoteObjects that I can just set and then use
 myData.getItemAt(0).name...
 
  I have a query to my database that returns one row of records
 through a web service. It is returned to my Flex app and I am trying
 to get it to an ArrayCollection variable for use in the application. I
 was watching a Lynda video that uses something like:
 
  myData = e.result.Tables.Table0.Rows as ArrayCollection. Now is that
 how you can set that row's columns at the value of the
 ArrayCollections? Or is this only going to work for the video scenerio?
 
  Thanks for any info!
 

  




-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
fotis.chatzini...@gmail.com,


Re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Wally Kolcz
thisindex (@150ba0a1)
emx.rpc.events.ResultEvent (@1516eaa9)
[inherited]
headersnull
resultmx.collections.ArrayCollection (@151f2701)
[inherited]
[0]mx.utils.ObjectProxy (@1516eee1)
DEPARTMENTPRMC
FIRSTNAMEWally
ISACTIVE1
LASTNAMEKolcz
objectObject (@15247ce1)
PASSWORD2113
POSITIONSenior ColdFusion Architect
ROLEadmin
typenull
uid3D083FE4-4B87-A1E6-B185-18D99C4193BD
UNIQNAMEwkolcz
sourceArray (@1537ef21)
[0]mx.utils.ObjectProxy (@1516eee1)
length1
statusCode0
resultArrCollundefined
firstResultundefined


From: Fotis Chatzinikos fotis.chatzini...@gmail.com
Sent: Tuesday, January 27, 2009 7:42 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Setting data from web service to  
ArrayCollection. 

Why do not you try Alert.show(ObjectUtil.toString(e.result)) //replace e.result 
with e to see the whole event

ObjectUtil is very useful in situation like this as it show a textual 
representation of any object graph 

On Tue, Jan 27, 2009 at 5:37 PM, valdhor valdhorli...@embarqmail.com wrote:

Perhaps you have an arrayCollection of arrayCollections (What does the

debugger show as the result type?). You may like to try...

var resultArrColl:ArrayCollection = e.result.source;

var firstResult:ArrayCollection = resultArrColl[0];

Alert.show(firstResult[0]);

--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:



 I moved my CFC and database to my localhost so I can debug the

webservice output and see it. I am a wee bit confused. The results

panel is saying something like this:

 

 e -- result -- source -- [0] -- firstName (etc)

 

 How do I set that local? 

 

 I tried myData = e.result.source as ArrayCollection and then tried

to trace myData.getItemAt(0).firstName but got an error. 

 

 

 From: Wally Kolcz wko...@...

 Sent: Tuesday, January 27, 2009 5:30 AM

 To: flexcoders@yahoogroups.com

 Subject: [flexcoders] Setting data from web service to ArrayCollection. 

 

 I am so trying to wrap my head around web services and use them for

my projects since we Blue Dragon here at the U. I have my CFCs and

they seem to work fine. However, I have no idea on how to set the

'return value' for a web service to an arraycollection to use it. I am

used to RemoteObjects that I can just set and then use

myData.getItemAt(0).name...

 

 I have a query to my database that returns one row of records

through a web service. It is returned to my Flex app and I am trying

to get it to an ArrayCollection variable for use in the application. I

was watching a Lynda video that uses something like:

 

 myData = e.result.Tables.Table0.Rows as ArrayCollection. Now is that

how you can set that row's columns at the value of the

ArrayCollections? Or is this only going to work for the video scenerio?

 

 Thanks for any info!



-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
fotis.chatzini...@gmail.com, 





Re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Wally Kolcz
Using Alert.show(ObjectUtil.toString(e.result)) This is what I got:

(mx.collections::ArrayCollection)#0
  filterFunction = (null)
  length = 1
  list = (mx.collections::ArrayList)#1
length = 1
source = (Array)#2
  [0] (Object)#3
DEPARTMENT = PRMC
FIRSTNAME = Wally
ISACTIVE = 1
LASTNAME = Kolcz
PASSWORD = 2113
POSITION = Senior ColdFusion Architect
ROLE = admin
UNIQNAME = wkolcz
uid = C7A50498-377F-0EE0-A170-18E1C0C2D677
  sort = (null)
  source = (Array)#2

How can I set it to userData:ArrayCollection and then call the firstName 
variable?


From: Fotis Chatzinikos fotis.chatzini...@gmail.com
Sent: Tuesday, January 27, 2009 7:42 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Setting data from web service to  
ArrayCollection. 

Why do not you try Alert.show(ObjectUtil.toString(e.result)) //replace e.result 
with e to see the whole event

ObjectUtil is very useful in situation like this as it show a textual 
representation of any object graph 

On Tue, Jan 27, 2009 at 5:37 PM, valdhor valdhorli...@embarqmail.com wrote:

Perhaps you have an arrayCollection of arrayCollections (What does the

debugger show as the result type?). You may like to try...

var resultArrColl:ArrayCollection = e.result.source;

var firstResult:ArrayCollection = resultArrColl[0];

Alert.show(firstResult[0]);

--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:



 I moved my CFC and database to my localhost so I can debug the

webservice output and see it. I am a wee bit confused. The results

panel is saying something like this:

 

 e -- result -- source -- [0] -- firstName (etc)

 

 How do I set that local? 

 

 I tried myData = e.result.source as ArrayCollection and then tried

to trace myData.getItemAt(0).firstName but got an error. 

 

 

 From: Wally Kolcz wko...@...

 Sent: Tuesday, January 27, 2009 5:30 AM

 To: flexcoders@yahoogroups.com

 Subject: [flexcoders] Setting data from web service to ArrayCollection. 

 

 I am so trying to wrap my head around web services and use them for

my projects since we Blue Dragon here at the U. I have my CFCs and

they seem to work fine. However, I have no idea on how to set the

'return value' for a web service to an arraycollection to use it. I am

used to RemoteObjects that I can just set and then use

myData.getItemAt(0).name...

 

 I have a query to my database that returns one row of records

through a web service. It is returned to my Flex app and I am trying

to get it to an ArrayCollection variable for use in the application. I

was watching a Lynda video that uses something like:

 

 myData = e.result.Tables.Table0.Rows as ArrayCollection. Now is that

how you can set that row's columns at the value of the

ArrayCollections? Or is this only going to work for the video scenerio?

 

 Thanks for any info!



-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
fotis.chatzini...@gmail.com, 





Re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Fotis Chatzinikos
Try the following:

userData:ArrayCollection = event.result as ArrayCollection ;

Then it seems that the array contains untyped object (Dictionary/hashmap
type) so:

userData.getItemAt(0)[FIRSTNAME] should give you :Wally ;

do not have a compiler in hand at the moment ... if the previous line does
not work for any reason:

var object:Object = userData.getItemAt(0) ;
var firstName:String = object[FIRSTNAME] ;

PS: I would recomment to change your backend script a bit in order to return
an ArrayCollection of typed User objects

PS2: Passwords are normally kept on the server and not transfered on the
client , at least not in text form...

On Tue, Jan 27, 2009 at 6:19 PM, Wally Kolcz wko...@isavepets.com wrote:

   Using Alert.show(ObjectUtil.toString(e.result)) This is what I got:

 (mx.collections::ArrayCollection)#0
   filterFunction = (null)
   length = 1
   list = (mx.collections::ArrayList)#1
 length = 1
 source = (Array)#2
   [0] (Object)#3

 DEPARTMENT = PRMC
 FIRSTNAME = Wally
 ISACTIVE = 1
 LASTNAME = Kolcz
 PASSWORD = 2113
 POSITION = Senior ColdFusion Architect
 ROLE = admin
 UNIQNAME = wkolcz
 uid = C7A50498-377F-0EE0-A170-18E1C0C2D677
   sort = (null)
   source = (Array)#2

 How can I set it to userData:ArrayCollection and then call the firstName
 variable?


 --
 *From*: Fotis Chatzinikos fotis.chatzini...@gmail.com
 *Sent*: Tuesday, January 27, 2009 7:42 AM
 *To*: flexcoders@yahoogroups.com
 *Subject*: Re: [flexcoders] Re: Setting data from web service to
 ArrayCollection.

 Why do not you try Alert.show(ObjectUtil.toString(e.result)) //replace
 e.result with e to see the whole event

 ObjectUtil is very useful in situation like this as it show a textual
 representation of any object graph

 On Tue, Jan 27, 2009 at 5:37 PM, valdhor valdhorli...@embarqmail.comwrote:

 Perhaps you have an arrayCollection of arrayCollections (What does the
 debugger show as the result type?). You may like to try...

 var resultArrColl:ArrayCollection = e.result.source;
 var firstResult:ArrayCollection = resultArrColl[0];
 Alert.show(firstResult[0]);


 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Wally
 Kolcz wko...@... wrote:
 
  I moved my CFC and database to my localhost so I can debug the
 webservice output and see it. I am a wee bit confused. The results
 panel is saying something like this:
 
  e -- result -- source -- [0] -- firstName (etc)
 
  How do I set that local?
 
  I tried myData = e.result.source as ArrayCollection and then tried
 to trace myData.getItemAt(0).firstName but got an error.
 
  
  From: Wally Kolcz wko...@...
  Sent: Tuesday, January 27, 2009 5:30 AM
  To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com
  Subject: [flexcoders] Setting data from web service to ArrayCollection.
 
  I am so trying to wrap my head around web services and use them for
 my projects since we Blue Dragon here at the U. I have my CFCs and
 they seem to work fine. However, I have no idea on how to set the
 'return value' for a web service to an arraycollection to use it. I am
 used to RemoteObjects that I can just set and then use
 myData.getItemAt(0).name...
 
  I have a query to my database that returns one row of records
 through a web service. It is returned to my Flex app and I am trying
 to get it to an ArrayCollection variable for use in the application. I
 was watching a Lynda video that uses something like:
 
  myData = e.result.Tables.Table0.Rows as ArrayCollection. Now is that
 how you can set that row's columns at the value of the
 ArrayCollections? Or is this only going to work for the video scenerio?
 
  Thanks for any info!
 




 --
 Fotis Chatzinikos, Ph.D.
 Founder,
 Phinnovation
 fotis.chatzini...@gmail.com,


  




-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
fotis.chatzini...@gmail.com,


Re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Wally Kolcz

I seem to be missing something. I tried the suggested way:

public function loginHandler(e:ResultEvent):void {
userData = e.result as ArrayCollection;
var object:Object = userData.getItemAt(0) ;
var firstName:String = object[FIRSTNAME] ;
Alert.show(firstName);
}

and I am getting this error:

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
at index/loginHandler()
at index/___index_Operation3_result()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
at 
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at DirectHTTPMessageResponder/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()

How can I  
change my backend script a bit in order to return an 
ArrayCollection of typed User objects? Any examples?

Also, I normally don't return all user info, but just using '*' till I can get 
this figured out:

Thanks for the help so far 



From: Fotis Chatzinikos 
fotis.chatzini...@gmail.com
Sent: Tuesday, January 27, 2009 8:49 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Setting data from web service to  
ArrayCollection. 

Try the following:

userData:ArrayCollection = event.result as ArrayCollection ;

Then it seems that the array contains untyped object (Dictionary/hashmap type) 
so:

userData.getItemAt(0)[FIRSTNAME] should give you :Wally ;

do not have a compiler in hand at the moment ... if the previous line does not 
work for any reason:

var object:Object = userData.getItemAt(0) ;
var firstName:String = object[FIRSTNAME] ;

PS: I would recomment to change your backend script a bit in order to return an 
ArrayCollection of typed User objects

PS2: Passwords are normally kept on the server and not transfered on the client 
, at least not in text form...

On Tue, Jan 27, 
2009 at 6:19 PM, Wally Kolcz wko...@isavepets.com wrote:

Using Alert.show(ObjectUtil.toString(e.result)) This is what I got:

(mx.collections::ArrayCollection)#0
  filterFunction = (null)
  length = 1
  list = (mx.collections::ArrayList)#1
length = 1

source = (Array)#2
  [0] (Object)#3
DEPARTMENT = PRMC
FIRSTNAME = Wally
ISACTIVE = 1
LASTNAME = Kolcz
PASSWORD = 2113
POSITION = Senior ColdFusion Architect
ROLE = admin
UNIQNAME = wkolcz
uid = C7A50498-377F-0EE0-A170-18E1C0C2D677

  sort = (null)
  source = (Array)#2

How can I set it to userData:ArrayCollection and then call the firstName 
variable?


From: Fotis Chatzinikos fotis.chatzini...@gmail.com
Sent: Tuesday, January 27, 2009 7:42 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Setting data from web service to  
ArrayCollection. 

Why do not you try Alert.show(ObjectUtil.toString(e.result)) //replace e.result 
with e to see the whole event

ObjectUtil is very useful in situation like this as it show a textual 
representation of any object graph 

On Tue, Jan 27, 2009 at 5:37 PM, valdhor valdhorli...@embarqmail.com wrote:

Perhaps you have an arrayCollection of arrayCollections (What does the

debugger show as the result type?). You may like to try...

var resultArrColl:ArrayCollection = e.result.source;

var firstResult:ArrayCollection = resultArrColl[0];

Alert.show(firstResult[0]);

--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:



 I moved my CFC and database to my localhost so I can debug the

webservice output and see it. I am a wee bit confused. The results

panel is saying something like this:

 

 e -- result -- source -- [0] -- firstName (etc)

 

 How do I set that local? 

 

 I tried myData = e.result.source as ArrayCollection and then tried

to trace myData.getItemAt(0).firstName but got an error. 

 

 

 From: Wally Kolcz wko...@...

 Sent: Tuesday, January 27, 2009 5:30 AM

 To: flexcoders@yahoogroups.com

 Subject: [flexcoders] Setting data from web service to ArrayCollection. 

 

 I am so trying to wrap my head around web services and use them for

my projects since we Blue Dragon here at the U. I have my CFCs and

they seem to work fine. However, I have no idea on how to set the

'return value' for a web service to an arraycollection to use it. I am

used to RemoteObjects that I can just set and then use

myData.getItemAt(0).name...

 

 I have a query to my database that returns one row of records

through a web service. It is returned to my Flex app and I am trying

[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Amy
--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 I moved my CFC and database to my localhost so I can debug the 
webservice output and see it. I am a wee bit confused. The results 
panel is saying something like this:
 
 e -- result -- source -- [0] -- firstName (etc)
 
 How do I set that local? 
 
 I tried myData = e.result.source as ArrayCollection and then tried to 
trace myData.getItemAt(0).firstName but got an error. 

Try

myData = ArrayCollection(e.result.source);

Your CFC may be returning an Array.



[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Amy
--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 
   I seem to be missing something. I tried the suggested 
way:
 
 public function loginHandler(e:ResultEvent):void {
 userData = e.result as ArrayCollection;
 var object:Object = userData.getItemAt(0) ;
 var firstName:String = object[FIRSTNAME] ;
 Alert.show(firstName);
 }
 
 and I am getting this error:
 
 TypeError: Error #1009: Cannot access a property or method of a 
null object reference.
 at index/loginHandler()
 at index/___index_Operation3_result()
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at 
mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::
dispatchRpcEvent()
 at 
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::re
sultHandler()
 at mx.rpc::Responder/result()
 at mx.rpc::AsyncRequest/acknowledge()
 at DirectHTTPMessageResponder/completeHandler()
 at flash.events::EventDispatcher/dispatchEventFunction()
 
 How can I  
   change my backend script a bit in order to return an 
ArrayCollection of typed User objects? Any examples?
 

You might find this example useful:
http://flexdiary.blogspot.com/2009/01/lazy-loading-tree-example-file-
posted.html



re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Wally Kolcz
I get this error:

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
at index/loginHandler()
at index/___index_Operation3_result()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
at 
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at DirectHTTPMessageResponder/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

My CFC is returning a Query. Does that help?


From: Amy amyblankens...@bellsouth.net
Sent: Tuesday, January 27, 2009 10:42 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Setting data from web service to ArrayCollection. 

--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:



 I moved my CFC and database to my localhost so I can debug the 

webservice output and see it. I am a wee bit confused. The results 

panel is saying something like this:

 

 e -- result -- source -- [0] -- firstName (etc)

 

 How do I set that local? 

 

 I tried myData = e.result.source as ArrayCollection and then tried to 

trace myData.getItemAt(0).firstName but got an error. 

Try

myData = ArrayCollection(e.result.source);

Your CFC may be returning an Array.





Re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Wally Kolcz
Ok, lets take this the other way. Here is my simple CFC. How can I modify this 
to return a result to Flex to which I can then set to an ArrayCollection that I 
can use?

cfcomponent
cffunction name=login access=remote returntype=query output=false 
hint=I attempt a login
cfargument name=username type=string required=yes /
cfargument name=password type=string required=yes /
cfquery name=result datasource=PRMC_Projects
Select * FROM users
WHERE uniqname = cfqueryparam value=#arguments.username# AND 
password = cfqueryparam value=#arguments.password# /
/cfquery
cfreturn result /
/cffunction
/cfcomponent



RE: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Tracy Spratt
I do not know Cold Fusion, but...

 

Which RPC protocol are you actually using?  Have you set resultFormat?

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Wally Kolcz
Sent: Tuesday, January 27, 2009 3:39 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Setting data from web service to
ArrayCollection.

 

Ok, lets take this the other way. Here is my simple CFC. How can I
modify this to return a result to Flex to which I can then set to an
ArrayCollection that I can use?

cfcomponent
cffunction name=login access=remote returntype=query
output=false hint=I attempt a login
cfargument name=username type=string required=yes /
cfargument name=password type=string required=yes /
cfquery name=result datasource=PRMC_Projects
Select * FROM users
WHERE uniqname = cfqueryparam value=#arguments.username#
AND password = cfqueryparam value=#arguments.password# /
/cfquery
cfreturn result /
/cffunction
/cfcomponent

 



[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread valdhor
This tutorial will probably help:

http://tutorial6.flexcf.com/

NB. I don't use coldfusion - I use PHP with WebORB.


--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 Ok, lets take this the other way. Here is my simple CFC. How can I 
modify this to return a result to Flex to which I can then set to an 
ArrayCollection that I can use?
 
 cfcomponent
 cffunction name=login access=remote returntype=query 
output=false hint=I attempt a login
 cfargument name=username type=string required=yes /
 cfargument name=password type=string required=yes /
 cfquery name=result datasource=PRMC_Projects
 Select * FROM users
 WHERE uniqname = cfqueryparam 
value=#arguments.username# AND password = cfqueryparam 
value=#arguments.password# /
 /cfquery
 cfreturn result /
 /cffunction
 /cfcomponent





[flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Amy
--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:

 Ok, lets take this the other way. Here is my simple CFC. How can I 
modify this to return a result to Flex to which I can then set to an 
ArrayCollection that I can use?
 
 cfcomponent
 cffunction name=login access=remote returntype=query 
output=false hint=I attempt a login
 cfargument name=username type=string required=yes /
 cfargument name=password type=string required=yes /
 cfquery name=result datasource=PRMC_Projects
 Select * FROM users
 WHERE uniqname = cfqueryparam 
value=#arguments.username# AND password = cfqueryparam 
value=#arguments.password# /
 /cfquery
 cfreturn result /
 /cffunction
 /cfcomponent

If the name is unique, why are you expecting a collection?




RE: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Wally Kolcz
I am using mx:WebService and I have the resultFormat set to object.


From: Tracy Spratt tspr...@lariatinc.com
Sent: Tuesday, January 27, 2009 1:20 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Setting data from web service to  
ArrayCollection. 

I do not know Cold Fusion, but.   Which RPC protocol are you actually
using?  Have you set resultFormat? 

Tracy Spratt 
 Lariat Services  

Flex development bandwidth available  

 From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Wally Kolcz
Sent: Tuesday, January 27, 2009
3:39 PM
To:flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re:
Setting data from web service to ArrayCollection.   

Ok, lets
take this the other way. Here is my simple CFC. How can I modify this to return
a result to Flex to which I can then set to an ArrayCollection that I can use?

cfcomponent

cffunction name=login
access=remote returntype=query output=false
hint=I attempt a login

cfargument name=username
type=string required=yes /

cfargument
name=password type=string required=yes
/

cfquery name=result
datasource=PRMC_Projects

Select * FROM users

WHERE
uniqname = cfqueryparam value=#arguments.username#
AND password = cfqueryparam value=#arguments.password#
/

/cfquery

cfreturn result /

/cffunction

/cfcomponent  





re: [flexcoders] Re: Setting data from web service to ArrayCollection.

2009-01-27 Thread Wally Kolcz
Don't understand the question. Please educate me :-)


From: Amy amyblankens...@bellsouth.net
Sent: Tuesday, January 27, 2009 3:20 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Setting data from web service to  ArrayCollection. 

--- In flexcoders@yahoogroups.com, Wally Kolcz wko...@... wrote:



 Ok, lets take this the other way. Here is my simple CFC. How can I 

modify this to return a result to Flex to which I can then set to an 

ArrayCollection that I can use?

 

 cfcomponent

 cffunction name=login access=remote returntype=query 

output=false hint=I attempt a login

 cfargument name=username type=string required=yes /

 cfargument name=password type=string required=yes /

 cfquery name=result datasource=PRMC_Projects

 Select * FROM users

 WHERE uniqname = cfqueryparam 

value=#arguments.username# AND password = cfqueryparam 

value=#arguments.password# /

 /cfquery

 cfreturn result /

 /cffunction

 /cfcomponent

If the name is unique, why are you expecting a collection?