Dynamic descriptions

Jason Johnson jason.johnson.081 at gmail.com
Mon Nov 19 22:14:27 MET 2007


Hi all,

I'm using Magritte to model some objects of mine and basically if the
user edits the object I want the description to be the same, just the
"unique key" to become read only.  If they add then of course all
fields are modify-able.

I have done this by overriding #description on instance side to do
something like:

MyObject>>description
   |result|

  result :=  self class description.

  ^ someField
      ifNil: [ result ]          "new instance"
      ifNotNil: [
        result collect: [e|
            e label = 'Name Im interested in'
                ifTrue: [ e beReadonly; yourself ]
                ifFalse: [ e ] ] ]

Now of course what happens is, if I click edit first then the fields
are always read only and vice versa if I click new first, due to
caching.  That is, it works perfectly.... the first use, and from then
on #description is called.  Before I fought with this anymore I
thought I would check if there is a simpler way to do what I'm trying
to do.

Thanks in advance,
Jason


More information about the smallwiki mailing list