Hi,
I myself prefer to handle these kind of things in the setters and getters, and not in the
descriptions, as this protects the domain integrity also against other “wrong usages”,
other then from Magritte. So I would recommend to have either
an accessor that returns an empty value if the value isn’t initialised:
someValue
^someValue ifNil: [ ‘’ ]
Or protect against writing a “nil” value:
someValue: anObject
anObject
ifNil: [ someValue := '' ]
ifNotNil: [ someValue := anObject ]
But if you want to solve this on the magritte side, the best solution would be to set the
reader to a reader that does not return nil if an empty string is written (stream atEnd).
Cheers,
Diego
On 06 Mar 2014, at 11:38, Otto Behrens <otto(a)finworks.biz> wrote:
Hi,
We'd like some help with how nil / undefined is handled in Magritte,
and specifically a MAStringDescription. The method MAStringReader >>
read:description: overrides the default behaviour to return nil. Is a
nil in Magritte seen as a "unpopulated" token?
Our problem more specifically is this:
We start with an object containing an string in an instance variable.
We use a MAStringDescription for this instance variable. We use the
magritte-seaside binding to edit this field on the UI. If the user
does not capture text in the text input, an empty string is "written".
The method on MAStringReader mentioned above intercepts this and
returns nil, so nil is written back to our domain object, where we
started off with an empty string.
We do not want nils to be written into our domain object where we
initialized it with an empty string.
How do we fix this? Is there a hook where we should be specifying
this? Or is there a fundamental way of working with Magritte-Seaside
where it will write nils and we have to manage that on our domain
object?
Thanks for your help.
Otto
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki