Hello all,
In Ramon's blog [1] he mentions: "When creating a description for that collection, I can specify my custom #accessor: rather than using the default #selectorAccessor: which then writes to my domain object with #addUser: and #removeUser:." Looking at the code, I don't see how this is done. Isn't the write accessor going to get a complete collection? Is the idea to just diff the received collection from the one the object had and make calls to #add and #remove as appropriate, or is there a way to only be told about the new objects in the collection? Thanks, Jason [1] http://onsmalltalk.com/programming/smalltalk/using-magritte-with-seaside/ _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> In Ramon's blog [1] he mentions:
> > "When creating a description for that collection, I can > specify my custom #accessor: rather than using the default > #selectorAccessor: > which then writes to my domain object with #addUser: and > #removeUser:." > > Looking at the code, I don't see how this is done. Isn't the > write accessor going to get a complete collection? Is the > idea to just diff the received collection from the one the > object had and make calls to #add and #remove as appropriate, > or is there a way to only be told about the new objects in > the collection? > > Thanks, > Jason That's exactly what I do. When I encapsulate a collection, I always provide the following #pluralCopyOfCollection #addX: #removeX: So... #people #addPerson: #removePerson: This doesn't work with Magritte expecting to be able to set the whole collection, so I use a custom accessor that removes items not contained in the new collection, and adds items not contained in the old collection. It requires a little reflection and a pluralize method to infer the collection name from the singular selector it's invoked with, i.e. #person for above sample. Ramon Leon http://onsmalltalk.com _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
I have not had much success with the tree view in IE. It seems to cop
out at depths > 2 or 3 Is this a known issue? Keith _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
In reply to this post by Ramon Leon-5
Ah, I see. How hard do you think it would it be to create a new
MAToManyDescription (or Container or whatever) subclass that worked like this [1]? This seems like a common pattern so it might be a good extension to the framework, and I don't think it would be very hard. The component must already be calling add on a collection, so that add call just needs to be selected by the subclass. Another option might be to exchange the collection the memento uses now for a special collection that overrides the #add and #remove methods. I'll take a look at this today if I get a chance. Thanks for the clarification. I hope you find time/interest in doing more blog entries about doing things in Seaside/Magritte/Pier. :) [1] Just to be totally clear for all, by "like this" I mean; have a "read: whole collection", "modify: add to collection" and "modify: remove from collection", instead of just "read: whole collection"/"write: whole collection". On 10/17/07, Ramon Leon <[hidden email]> wrote: > > In Ramon's blog [1] he mentions: > > > > "When creating a description for that collection, I can > > specify my custom #accessor: rather than using the default > > #selectorAccessor: > > which then writes to my domain object with #addUser: and > > #removeUser:." > > > > Looking at the code, I don't see how this is done. Isn't the > > write accessor going to get a complete collection? Is the > > idea to just diff the received collection from the one the > > object had and make calls to #add and #remove as appropriate, > > or is there a way to only be told about the new objects in > > the collection? > > > > Thanks, > > Jason > > That's exactly what I do. When I encapsulate a collection, I always provide > the following > > #pluralCopyOfCollection > #addX: > #removeX: > > So... > > #people > #addPerson: > #removePerson: > > This doesn't work with Magritte expecting to be able to set the whole > collection, so I use a custom accessor that removes items not contained in > the new collection, and adds items not contained in the old collection. It > requires a little reflection and a pluralize method to infer the collection > name from the singular selector it's invoked with, i.e. #person for above > sample. > > Ramon Leon > http://onsmalltalk.com > > > _______________________________________________ > SmallWiki, Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki > _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Free forum by Nabble | Edit this page |