- Forum
- Usenet
- COMP.LANG.SMALLTALK.DOLPH
-
Dialog class and aspectBuffer
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.
Vince
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
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'.
The structure is as follows. The models:
Model subclass: #Guest
instanceVariableNames: 'person isAttending'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''
Model subclass: #Person
instanceVariableNames: 'title givenNames familyName dateOfBirth'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''
Guest>>#person
^ person ifNil: [ person := Person new ]
The Ui classes:
Presenter subclass: #PersonUi
instanceVariableNames: 'title givenNames familyName dateOfBirth'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''
Dialog subclass: #NppGuestView
instanceVariableNames: 'person isAttending'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''
Guest>>#model: anObject
| aspectBuffer |
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
Vince
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)