1 Reply Latest reply on Apr 20, 2007 9:18 AM by joeDangelo

    Getting/Setting Arrays of DTOs in a DTO

    Dr._Goomba Level 1
      A couple questions:
      Is it bad practice to pass array collections of other DTOs in a DTO?
      Why am i unable to get CF to return a numeric value when i run arrayLen(theDTOarray)? Error says cannot convert string to an array, eventhough my DTO defines the array as an array.

      Here is a run down of what i am trying to accomplish. I have a DTO called Album and a DTO called Track. Inside AlbumDTO i have:
      AlbumID (numeric)
      AlbumArtist (string)
      AlbumTitle (string)
      AlbumTracks (array)

      TrackNum (numeric)
      TrackSong (string)
      TrackLength (numeric)
      AlbumID (numeric)

      It makes sense for me to just create an array of TrackDTO's as AlbumTracks in the AlbumDTO so i can easily pass around all this data as one.

      When i am ready to save the object, i send it to my DAO which i loop over the AlbumTracks to create a TrackDTO for each object, then send that object to its corresponding Gateway save method. It looks something like this:

        • 1. Re: Getting/Setting Arrays of DTOs in a DTO
          joeDangelo Level 1
          From an OO point-of-view, that is exactly the way that should be designed. Just as a heads-up, though... for some reason in CF6/7 object instantiation is a bit time consuming... 16-32ms apiece. If you're trying to invoke an album component which then invokes 20 track components, you're looking at somewhere between 300 and 700 ms, which may produce a somewhat laggy page. Some work has been done to correct this in the next release of CF, due out later this year.

          As far as your error, it seems probable that the problem would be that arguments.bean.gettracks() returns a string. Check the returntype of the function and if that doesnt work, try setting that variable into an intermediate value first... i've had some issues trying to use the results of a function call directly.