|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Data structure question (an array of a cfc object)
I just picked up coldfusion about a month ago, so my coldfusion lingo sucks. I have been programming in C++ for over 5 years now and will be using a lot of C++ terminology to help avoid any confusion. I am writing a cfc function that preforms web servicing. This function needs to return an object/class that is defined in another cfc file. I can do this without a problem if I only need to return one instance of this object. However, I cannot seem to return an array of this object (I need to return multiple instances of this object, kind of like a query, but for programming purposes it needs to stay as an object).
It seems that the webservicing function hates my return type. If I try to make an array of the object, it does not like array or the object as the return type. However, when I take this function out of the cfc, and make it a cfm, it gets the array of objects just fine. So, I think I am having issues with the return type on the <cffunction> tag. So I came up with the idea of creating another object which will hold an array of the first object and using the second object as the return type. Here is some psuedo code of the function I am working on: <cffunction name="SelectGames" access="remote" returntype="ArrayOfGames" output="false"> <!-- arguments ---> <!--- query ---> <cfobject component = "myArray" name> <cfobject component="games" name="test"> <cfset counter = 0> <cfloop query="getevents"> <cfset counter = counter + 1> <cfset test.Game_id = event_id> <cfset test.gameDate = eventdate> <cfset test.Starttime = starttime> <cfset test.Place = place> <cfset test.Level = level> <cfset test.Sport = sport> <cfset test.Gender = division> <cfset test.Opponent = opponent_id> <cfset test.Type = type> <cfset test.Link = spec_name> <cfset myArray.gamesArray[counter] = test> </cfloop> <cfreturn myArray> </cffunction> It keeps telling me that it does not recognize the return type. Here are examples of the two objects I am using from the 2 dif. cfc files: <cfcomponent> <cfproperty name="gamesArray" type="array"> </cfcomponent> <cfcomponent> <cfproperty name="Game_id" type="numeric"> <cfproperty name="gameDate" type="date"> <cfproperty name="Starttime" type="string"> <cfproperty name="Place" type="string"> <cfproperty name="Level" type="string"> <cfproperty name="Sport" type="string"> <cfproperty name="Gender" type="string"> <cfproperty name="Opponent" type="string"> <cfproperty name="Type" type="string"> <cfproperty name="Link" type="string"> </cfcomponent> Feel free to post any questions to clear anything up, I know this is confusing and I probably did a poor job of explaining my problem. Also, if I throw this code into a cfm and try to make an array of games, it works, this is the code I got it to work with: <cfset myArray = newArray(1)> <cfloop query="getevents"> <cfset counter = counter + 1> <cfset test.Game_id = event_id> <cfset test.gameDate = eventdate> <cfset test.Starttime = starttime> <cfset test.Place = place> <cfset test.Level = level> <cfset test.Sport = sport> <cfset test.Gender = division> <cfset test.Opponent = opponent_id> <cfset test.Type = type> <cfset test.Link = spec_name> <cfset myArray[counter] = test> </cfloop> I guess my problem is I do not know how to specify a type for an array. |
|
#2
|
|||
|
|||
|
I am having the same problem
I am having the same problem. I am trying to return the array of custom Java class from the cfc as the return type, and I spent several days trying to find out how, but failed so far.
If you know how to do it by now, could you be kind enough to post it here or email to me? Thank you very much. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Cold Fusion Development > Data structure question (an array of a cfc object) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|