From vinref@gmail.com@21:1/5 to All on Sat Mar 20 04:11:04 2021
I have a class Guest, which has parameters #isAttending (Boolean) and #person (Person class). Person class has the given names, family name and title.
Guest UI is a Dialog that contains #isAttending (a checkbox) and Person (a Presenter).
In Guest>>#model: I have an aspectBuffer to buffer changes. However the changes to person are always written even if I send #cancel. The change to #isAttending is always buffered.
Is there a way around this? I followed the PersonalMoney example, specifically PersonalAccountTransactionDialog>>#model: where the aspectBuffer is used.
From vinref@gmail.com@21:1/5 to All on Tue Mar 23 04:10:03 2021
I had to override copy. The changes in the Dialog are correctly buffered and discarded when I press 'Cancel' and written to the backing model when I press 'Save'.
super model: anObject.
aspectBuffer := self model.
self person model: (aspectBuffer aspectValue: #person).
self isAttending model: (aspectBuffer aspectValue: #isAttending)
The class comment for AspectBuffer says: "In order to be correctly used with an AspectBuffer, a subject object must be able to be sensibly duplicated using #copy."
So I implemented the following:
Guest>>#copy
^ self species new
person: self person copy;
isAttending: self isAttending copy