Automatic readonly descriptions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Automatic readonly descriptions

Frank Shearar
Hi everyone,

I sometimes want to render domain objects as read only, and sometimes as
editable entities.

I wrote description methods that allow editing, as per normal.

Then I wrote this class method:

readOnlyDescription
   ^ self description collect: [:description | description beReadonly].

which seems to work just dandy. I then render this in Seaside like so:

renderContentOn: html
   html render: (recipe class readOnlyDescription asComponentOn: recipe)

So: first, Magritte rocks me.

Second, is the above "idiomatic" Magritte? Are there better ways of
doing this?

frank
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Automatic readonly descriptions

Frank Shearar
Frank Shearar wrote:

> Hi everyone,
>
> I sometimes want to render domain objects as read only, and sometimes as
> editable entities.
>
> I wrote description methods that allow editing, as per normal.
>
> Then I wrote this class method:
>
> readOnlyDescription
>   ^ self description collect: [:description | description beReadonly].
>
> which seems to work just dandy. I then render this in Seaside like so:
>
> renderContentOn: html
>   html render: (recipe class readOnlyDescription asComponentOn: recipe)
>
> So: first, Magritte rocks me.
>
> Second, is the above "idiomatic" Magritte? Are there better ways of
> doing this?


Ah. Yes. "self description beReadonly" does the same thing!

frank
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Automatic readonly descriptions

Lukas Renggli
>> Second, is the above "idiomatic" Magritte? Are there better ways of doing
>> this?
>
> Ah. Yes. "self description beReadonly" does the same thing!

That's correct, but you should copy the description beforehand:
<http://www.lukas-renggli.ch/smalltalk/magritte/faq>.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki