Hi,
I've noticed a problem with cookies enabled and Pier. The problem arises
when you browse to a URL without the continuation key, which causes a new
instance of the application to be created ie PRPierFrame new. You can see
the issue with the following single page WACounter Pier app:
| rootPage |
rootPage := (PRPage named: 'rootPage') contents: '+counter+'; yourself.
rootPage localEnvironment: ((PRComponent named: 'contents') componentClass:
PRContentsWidget; yourself).
rootPage addChild: ((PRComponent named: 'counter') componentClass:
WACounter; yourself).
PRKernel reset.
(PRPierFrame registerAsApplication: 'pier' kernel: (PRKernel named:
'testKernel' root: rootPage)) preferenceAt: #useCookies put: true.
Browse to localhost:xxxx/pier you should see the familiar counter component.
Increment the counter a few times. Now open a new tab, browse
to localhost:xxxx/pier and decrement the counter a couple of times. Return
to the first tab and try incrementing again. The counter will increment from
the value of the second counter.
I tested the same code snippet in Pier 1 on Seaside 2.8 and the component
increments from the value on the page ie it behaves as you'd expect a
Seaside component to behave.
The problem appears to arise in:
WASession>>#handleFiltered: aRequestContext
| key continuation |
key := aRequestContext request fields
at: self actionField
ifAbsent: [ ^ self start ].
continuation := continuations
at: key
ifAbsent: [ ^ self unknownRequest ].
continuation value
if there is no continuation key, #start is called on the session, which
creates a new root component. I have a fix, though it's in such a core part
of Seaside, I'm hesitant to suggest it. If I change WARenderLoopMain>>#start
from:
start
| root |
root := self createRoot.
self session properties at: #presenter put: root.
self prepareRoot: root.
((self application preferenceAt: #renderPhaseContinuationClass) new)
captureAndInvoke
to:
start
| root |
root := self session presenter.
root ifNil: [
root := self createRoot.
self session properties at: #presenter put: root.
self prepareRoot: root ].
((self application preferenceAt: #renderPhaseContinuationClass) new)
captureAndInvoke
...the root component is recovered from the session (if present) and no
longer created.
Is this a valid fix?
Thanks
Nick