Magritte usage pattern
Norbert Hartl
norbert at hartl.name
Sat Mar 31 20:43:47 MEST 2007
On Sat, 2007-03-31 at 20:07 +0200, Lukas Renggli wrote:
> 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?
>
You are right. I will finish them a little and post them here.
> > - 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'
>
Oh, I should have found that :) Looks much better.
> > 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
>
Ok, I only imagined to carry more than one model. But to chain selector
invocation is much more clever. It will only work if the objects related
directly but I doubt you need to combine model objects often when they
are not related directly.
For further assistance please remember that you renamed
MACascadeAccessor to MAChainAccessor :) It was in Magritte-Model-206 ;)
> This looks terribly complicated, but with a simple helper function it
> could made look much simpler.
I didn't try it but it looks not too complicated.
thanks very much,
Norbert
More information about the smallwiki
mailing list