I have quickly managed to get domain classes to be created via a REST POST, but am stuck on how to create multiple creates for a xml file with multiple objects of the same type in, eg where as I was successful with
<Track>
<trackAlbumName> Songs for Polar Bears </trackAlbumName>
<trackArtistName> Snow PAtrol </trackArtistName>
<trackSongTitle> First Song </trackSongTitle>
</Track>
I have added a UploadTrackGroup domain class, and now wish to create multiple Track objects in the same upload, eg I was hoping to POST something like;
<?xml version="1.0" encoding="utf-8"?>
<UploadTrackGroup>
<Track>
<trackAlbumName> Songs for Polar Bears </trackAlbumName>
<trackArtistName> Snow PAtrol </trackArtistName>
<trackSongTitle> First Song </trackSongTitle>
</Track>
<Track>
<trackAlbumName> Different Class </trackAlbumName>
<trackArtistName> Pulp </trackArtistName>
<trackSongTitle> Misshapes </trackSongTitle>
</Track>
<Track>
<trackAlbumName> F Sharp A Sharp </trackAlbumName>
<trackArtistName> Godspeed You Black Emperor </trackArtistName>
<trackSongTitle> Dead Flag BLues</trackSongTitle>
</Track>
</UploadTrackGroup>
But I’ll be damned if I can get it to work.
When I try to use the following code in my controller;
println params
params.UploadTrackGroup.each {
println "-->" + it
}
I only see a single track, eg
[action:create, controller:recognisedSong, UploadTrackGroup:[Track: F Sharp A Sharp Godspeed You Black Emperor Dead Flag BLues]]
-->Track= F Sharp A Sharp Godspeed You Black Emperor Dead Flag BLues
I was successful in achieving what I wanted by effectively ignoring the parent UploadTrackGroup node, and simply using
It would appear that as soon as I try to specify the exact qualified path to the Track nodes, ie
UploadTrackGroup.Track.eachor various variations thereof, it doesnt work.So it goes.