[Seaside] Bug in Set backtracking
David Shaffer
cdshaffer at acm.org
Tue Oct 18 03:40:31 UTC 2005
I've been having problems with the WATree component and tracked it down
to the snapshotCopy mechanism performing only a shallow copy of the Set
used to track expanded nodes. Maybe this has been fixed in later
Seaside/Squeak versions but as of Seaside2.5/Squeak3.7 this doesn't
work. Attached are a test case (and component) which demonstrate the
problem and a fix. I'll post the fix to the Seaside MC repo unless I
hear that there is a problem with it...
David
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 17 October 2005 at 11:38:08 pm'!
WAComponent subclass: #SCSetBacktrackingComponent
instanceVariableNames: 'set value'
classVariableNames: ''
poolDictionaries: ''
category: 'SeasideTesting-Examples'!
!SCSetBacktrackingComponent methodsFor: 'rendering' stamp: 'cds 10/17/2005 23:21'!
renderContentOn: html
html form:
[html cssId: 'input'.
html textInputWithCallback: [:v | value := v].
html submitButtonWithAction: [set add: value] text: 'add'.
html submitButtonWithAction: [set remove: value] text: 'remove']! !
!SCSetBacktrackingComponent methodsFor: 'initialization' stamp: 'cds 10/17/2005 23:12'!
initialize
super initialize.
self session registerObjectForBacktracking: (set := Set new).
! !
!SCSetBacktrackingComponent methodsFor: 'accessing' stamp: 'cds 10/17/2005 23:19'!
set
^set! !
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 17 October 2005 at 11:38:17 pm'!
SCComponentTestCase subclass: #SCSetBacktrackingTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SeasideTesting-Examples'!
!SCSetBacktrackingTest methodsFor: 'tests' stamp: 'cds 10/17/2005 23:22'!
testAdd
| form input |
self newApplicationWithRootClass: SCSetBacktrackingComponent.
self establishSession.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
self assert: (self component set includes: 'entry1')! !
!SCSetBacktrackingTest methodsFor: 'tests' stamp: 'cds 10/17/2005 23:22'!
testRemove
| form input |
self newApplicationWithRootClass: SCSetBacktrackingComponent.
self establishSession.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
self assert: (self component set includes: 'entry1').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
! !
!SCSetBacktrackingTest methodsFor: 'tests' stamp: 'cds 10/17/2005 23:27'!
testSequence
| form input |
self newApplicationWithRootClass: SCSetBacktrackingComponent.
self establishSession.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry2'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry3'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
self assert: (self component set includesAllOf: (Array with: 'entry1' with: 'entry2' with: 'entry3')).
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
self back.
self backAndRefresh.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
! !
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 17 October 2005 at 11:38:36 pm'!
!Set methodsFor: '*seaside2' stamp: 'cds 10/17/2005 23:30'!
snapshotCopy
^self copy! !
More information about the Seaside
mailing list