Answered my own question. In my managed Room class, I set the default value of my id property to -1. Problem solved.
Tom On 4/3/06, Tom Bray <[EMAIL PROTECTED]> wrote: > I'm trying to build a very simple app based on the Contact Manager > sample application. A lot of it is working but when I try to create > new items, I'm getting the following error: > > Error: faultCode:Local.Call.Failed faultString:'Item with id '0' > already exists. Error on destination 'Room'' faultDetail:'null' > at > mx.data::ConcreteDataService/http://www.adobe.com/2006/flex/mx/internal::dispatchFaultEvent() > at mx.rpc::AsyncDispatcher/::timerEventHandler() > at flash.util::Timer/flash.util:Timer::tick() > > > In the Contact Manager example, you create new Contact objects and add > them to the DataService using createItem( contact ). These contact > objects are populated with all properties _except_ the contactId > because that gets created server-side. I'm trying to do the same > thing below but with my Room objects. Note the line that's commented > out. If I uncomment that, I can create as many rooms as I want with > roomIds getting set on the server. What do I need to do to get around > the error above without my kludgy fix? > > [Bindable] > public var rooms:ArrayCollection; > > [Bindable] > public var room:Room; > > public var foo:Number = 100; > > private var ds:DataService; > > private function initApp():void > { > rooms = new ArrayCollection(); > room = new Room(); > ds = new DataService("Room"); > ds.fill(rooms); > } > > private function newRoom():void > { > room = new Room(); > //if I uncomment this next line, the app works fine > //room.roomId = foo == 100 ? 101 : 100; > room.name = roomName.text; > room.description = description.text; > ds.createItem(room); > } > > ... > <mx:Button label="Submit" click="newRoom()"/> > ... > > Thanks, > > Tom > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

