« Return to Thread: MAMultilpleOption vs. MAToManyRelation

Re: MAMultilpleOption vs. MAToManyRelation

by Ch Lamprecht :: Rate this Message:

Reply to Author | View in Thread

Ch Lamprecht wrote:

> Lukas Renggli schrieb:
>
>>>if an Object holds a collection of other Objects (like a group of  
>>>Persons), and
>>>these (Persons) should not be created/edited but a list to choose  
>>>from should be
>>>presented - would a MAMultipleOptionDescription be appropriate? If  
>>>so, how can
>>>the options presented be made dynamic.
>>
>>
>>There are several ways to make properties of descriptions dynamic.
>>
>>1. Override #description on the instance-side and build your  
>>descriptions programmatically. Don't forget to copy the descriptions,  
>>in case you call super to get modify the default behavior.
>>
>>2. Pass the property a block that you send #asDynamicObject. See the  
>>senders of this message for examples. This approach is simple and  works
>>in most cases, there are some possible drawbacks however: (1)  the
>>implementation uses a proxy object that might not get properly  resolved
>>in all cases, (2) the proxy object references a block context  that
>>might not be serializeable with your preferred persistency  mechanism,
>>(3) proxies are hard to debug, and (4) from within the  block you don't
>>have access to the described object.
>
>
>
> I could work around by creating a new description class and corresponding
> MAStringWriter subclass then setting the reference attribute to it:
>
> MASingleOptionDescription  new
>     label: 'Label' ;
> reference: MAMyStringDescription new;
>    selectorAccessor: #myAccessor;
>             options: [WAPersonManager persons]asDynamicObject;
>
> Then MAPersonModel >> printString returns lastName or something useful.
>
> That way everything works fine and the choices are dynamic (hitting reload in
> the browser updates the list)

>
> I hope this made sense... Cheers, Christoph

Hmm, maybe it did not...

Is #reference: meant for 'public' use with MA*OptionDescription ?

Thank you, Christoph

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

 « Return to Thread: MAMultilpleOption vs. MAToManyRelation