[Seaside] defaultAction:

Bany, Michel mbany at cincom.com
Wed Mar 16 13:58:01 CET 2005


Avi,
I am busy porting 2.5b7 to VW so that it gets ready for VW 7.3.1.
There is something puzzling regarding defaultAction:

Consider the following

renderContentOn: html
	html form:
		[html defaultAction: ['default callback' inspect].
		html text: 'Input:'.
		html textInputWithValue: 'Change this'  callback: [: v |
v ].
		html break.
		html submitButtonWithAction: ['ok callback' inspect]
text: 'OK']

After entering some data and hiting the Return key the result is
different
depending on the browser.
With IE6, the default callback gets evaluated
With Mozilla or Firefox, the ok callback is used.

With this :

renderContentOn: html
	html form:
		[html submitButtonWithAction: ['default callback'
inspect]
			image: html transparent1X1Form.
		html text: 'Input:'.
		html textInputWithValue: 'Change this'  callback: [: v |
v ].
		html break.
		html submitButtonWithAction: ['ok callback' inspect]
text: 'OK']

Here too it depends on the browser.
With Mozilla or Firefox, the default callback is evaluated
With IE6, neither callback is used.

This gave me the idea to reimplement defaultAction: so that it provides
both techniques.

defaultAction: actionBlock
	self
		inputWithType: 'hidden'
		named: (self callbacks registerDefaultActionCallback:
actionBlock).
	self submitButtonWithAction: actionBlock image: self
transparent1X1Form.

With this new implementation, the first example (above) works as
expected
and equally with all three browsers.

Finally, we can also re-implement this

formWithDefaultAction: defaultBlock do: aBlock
	self form:
		[self defaultAction: defaultBlock.
		aBlock value]


Michel.




More information about the Seaside mailing list