I need help understanding the underlying LCDS mechanisms when a complex object hierarchy is managed in LCDS. I have a custom Assembler because I have specialized persistence requirements. My object hierarchy is basically the following:
Document is the [Managed] class. When a new Document is created, it is initialized with a Chapter. Pages and Text are created when the document is edited. I create new instance of Document and initialize it with an instance of Chapter. On the client, I invoke the DataService using the createItem method. My custom Assembler is called, I do the necessary persistence operation and return. Back on the client I receive the ItemReference containing the AS Document. This all works ok. I am now faced with the runtime operations when the user starts creating Chapters, Pages and entering text.
Given that I start the editing session with a single ItemReference, I don't understand how to handle the Document sub-tree. The LCDS documentation says the purpose of the [Managed] class tag is so the entire object tree does not need to be transmitted when a property changes on a child object. Its the responsibility of the sub class to keep the remote object in sync. But, I don't know the best way to go about doing this.
The [Managed] annotation makes the properties of the managed class bindable. I can add an event listener to the ItemReference to handle property changes on the Document, but what about the rest of the object tree? Do I explicitly make the properties of the child objects bindable? Do I make each parent object an event listener for its child object properties and propagate the event up the tree?
Any suggestions or patterns to make this a little more understandable would be greatly appreciated.
Ah. That certainly illuminates things a little better.
I currently have a single Assembler for Document and I have a hit a bit of a roadblock. I can create the full object tree. Document has a Chapter and the Chapter has a Page. But I want to edit the Page and sync any changes across multiple clients. So I need an ItemReference for the Page. I turn around a perform a getItem on the Page, but I get an error stating the item must be [Managed]. The reason I don't have it managed is because LCDS skips any class defined as [Managed] when building the object tree (on the server) prior to calling my Assembler. I figured out when you have a single Assembler, only the top object can have [Managed]. To get started, I was playing around with singletons and not collections of Chapters, etc. I hope that made sense.
Looking at your explanation using multiple Assemblers and managed collections might be the way to go. When a new Chapter or Page is created and added to the collection, then the sync-ing is done automatcally? I assume each class corresponding to an Assembler is [Managed]. I think this is what the documentation says.
I looked for some online examples, including Tour De LiveCycle, but didn't find any. I will look again.