Magritte usage pattern

Lukas Renggli renggli at iam.unibe.ch
Sat Mar 31 20:07:01 MEST 2007


Hi Norbert,

> For customization I put every little bit in a wrapper class
> around the generated Magritte component. This is for customizing
> the generated component as well as to do some manual html if
> it isn't avoidable. I have the feeling that this is not the
> right way to do but I have no better idea. To minimize the effort
> to do a component for a model component I've built a base class
> which should ease the customization of the component.

are your convenience classes available somewhere? I think that many  
people could profit from these extensions and they could maybe even  
be integrated somehow into the core package?

> - really complex layout cases
>   I have one case where it is necessary to put css classes to some of
>   the components of a form. The best way I found so far (being dirty)
>   is to use propertyAt:put: at description level and use this in a
>   specialized renderer

You could use #attributes of the descriptions:

	aDescription attributes class: 'foo'

> So far so good. I like to hear your oppions and experiences doing this
> kind of stuff.

Your approach sounds fine to me, I also found myself doing similar  
things.

> Another problem I have no solution til now is the mixture of models  
> into
> one component. Sometimes you build your data model and then page  
> layout
> forces you to edit two objects at the same time. I have no problem to
> mix descriptions in a desired way. But by invoking asComponentOn: they
> would have all the same model which is wrong for a subset of the
> descriptions. Is there any clever way to mix descriptions, set the  
> model
> accordingly and then produce the component?

Indeed you can do that by modifying the accessors of the descriptions  
of referenced objects. I am copying an example from an earlier post  
to this mailing list, where #billingAddress and #shippingAddress are  
weaved into the description of anOrder:

composedDescription := anOrder description copy
     addAll: (anOrder billingAddress description collect: [ :each |
         each copy accessor: (MACascadeAccessor
             accessor: (MASelectorAccessor selector: #billingAddress)
             next: each accessor) ]);
     addAll: (anOrder shippingAddress description collect: [ :each |
         each copy accessor: (MACascadeAccessor
             accessor: (MASelectorAccessor selector: #shippingAddress)
             next: each accessor) ]);
     asComponentOn: anOrder

This looks terribly complicated, but with a simple helper function it  
could made look much simpler.

Cheers,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch




More information about the smallwiki mailing list