[Seaside] Nested form tags

Michel Bany m.bany at wanadoo.fr
Thu Nov 3 22:56:04 CET 2005

I believe I found the bug that causes the weird effects that have been 
observed when nesting forms.

When there are nested <form> in the html and when a submit button is 
pressed, the resulting http
request contains the "_s" and the "_k" hidden fields many times (once 
for each form).
As a result the http fields in the request are holding collection of 
strings rather than just strings
(the field dictionary object is too smart !) In such situations, Seaside 
is not able to retrieve the
session and shows the expiration screen.

I found that the consequences of the bug can be in corrected 
where the request fields can be computed differently. The implementation 
in the attachment
eliminates the false expiration.

This does not occur in VisualWorks where the computation of the request 
fields are always
and consistently available as collections or strings.

The attached change set  includes both the fix and a test component with 
nested <form>


-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 3 November 2005 at 10:28:53 pm'!
WAComponent subclass: #WANestedForms
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Seaside-Examples-Test'!

!WAKom methodsFor: 'as yet unclassified' stamp: 'mb 11/3/2005 22:28'!
convertRequest: aKomRequest 
	| request fields waFields |
	self processMultipartFields: aKomRequest.
	fields := aKomRequest method = 'POST'
				ifTrue: [aKomRequest postFields]
				ifFalse: [aKomRequest getFields].
	waFields := Dictionary new.				
		keysAndValuesDo: [:k :v | v isString
				ifFalse: [waFields at: k put: v first]
				ifTrue: [waFields at: k put: v]].
	request := WARequest
				method: aKomRequest method
				url: aKomRequest url unescapePercents
				headers: aKomRequest header
				fields: waFields
				cookies: aKomRequest cookies
				nativeRequest: aKomRequest.
	aKomRequest method = 'PUT'
		ifTrue: [request fields
				at: 'PUTData'
				put: (aKomRequest stream next: aKomRequest contentLength)].
	^ request! !

!WANestedForms methodsFor: 'rendering' stamp: 'mb 11/3/2005 22:17'!
renderContentOn: html
	html heading: 'Buttons in nested forms'.
	html text: 'Click the buttons and get an expired session !!'. 
		form: [html
				submitButtonWithAction: [self inform: 'Button1']
				text: 'Button1'.
				form: [html
						submitButtonWithAction: [self inform: 'Button2']
						text: 'Button2']]! !

!WANestedForms class methodsFor: 'initialize-release' stamp: 'mb 11/3/2005 22:13'!
	self registerAsApplication: 'NestedForms'! !

WANestedForms initialize!

!WANestedForms class reorganize!
('initialize-release' initialize)

!WANestedForms reorganize!
('rendering' renderContentOn:)

More information about the Seaside mailing list