• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting/Setting Arrays of DTOs in a DTO

Participant ,
Apr 19, 2007 Apr 19, 2007

Copy link to clipboard

Copied

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)

TrackDTO:
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:


TOPICS
Advanced techniques

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation