[Seaside] trouble with submit buttons

Pavel Krivanek squeak3 at continentalbrno.cz
Fri Aug 5 21:12:50 CEST 2005


ShoreComponents try to solve this problem (nested forms). The Demo 
application contains example of this feature.

-- Pavel

> Julian Fitzell a écrit :
>
>>
>> How's it implemented, by the way, Michel?  Just looking up the stack 
>> on the renderer?
>>
> No look-up of the stack, I made it explicit by adding a "tagStack" 
> i-var to WAHtmlDocument
> and the following interface :
>    clearTagStack
>    isWithinTag:
>    popTag
>    pushTag:
> and by changing a handfull of classes to use this interface.
>
> I just tried it and found out that the distributed version of this 
> goodie (7.3.1) is broken.
> I am attaching a less-broken version of the code, this may help the 
> Squeak implementers.
> Not sure it works OK with canvas. Also, my code does not make the 
> feature configurable.
> Enjoy,
> Michel.
>
>------------------------------------------------------------------------
>
>'From VisualWorks®, 7.3.1 of mercredi 20 avril 2005 on vendredi 5 août 2005 at 9:10:18'!
>
>
>Smalltalk.Seaside defineClass: #WAHtmlDocument
>	superclass: #{Core.Object}
>	indexedType: #none
>	private: false
>	instanceVariableNames: 'root tagStack '
>	classInstanceVariableNames: ''
>	imports: ''
>	category: 'Seaside-Document'!
>
>!Seaside.WAFormTag methodsFor: 'as yet unclassified'!
>
>with: aBlock 
>	self isWithinForm 
>		ifFalse: [super with: aBlock]
>		ifTrue: 
>			[canvas nest: aBlock.
>			isClosed := true]! !
>
>!Seaside.WAFormTag methodsFor: 'stack operations'!
>
>isWithinForm
>	^self document isWithinTag: self tag! !
>
>
>!Seaside.WAHtmlCanvas methodsFor: 'as yet unclassified'!
>
>tag: aString 
>	aString = 'form' ifTrue: [^self form].
>	^self brush: (WAGenericTag tag: aString)! !
>
>
>!Seaside.WAAbstractHtmlBuilder methodsFor: 'basic markup'!
>
>tag: aString do: anObject 
>	(aString = 'form' and: [self isWithinForm]) 
>		ifTrue: 
>			[self error: 'Nested form'.
>			^self render: anObject].
>	self openTag: aString.
>	self render: anObject.
>	self closeTag: aString! !
>
>!Seaside.WAAbstractHtmlBuilder methodsFor: 'stack operations'!
>
>isWithinForm
>	^self document isWithinTag: 'form'! !
>
>
>!Seaside.WAHtmlRenderer methodsFor: 'convenience'!
>
>form: aBlock 
>	self isWithinForm 
>		ifTrue: 
>			[attributeBuffer := nil.
>			^aBlock value].
>	self 
>		formWithMethod: 'post'
>		action: context actionUrl urlString
>		do: 
>			[self div: 
>					[context actionUrl parameters keysAndValuesDo: 
>							[:k :v | 
>							self 
>								inputWithType: 'hidden'
>								named: k
>								value: v].
>					aBlock value]]! !
>
>
>!Seaside.WAHtmlDocument methodsFor: 'as yet unclassified'!
>
>initializeWithRoot: aRoot 
>	root := aRoot.
>	self clearTagStack! !
>
>!Seaside.WAHtmlDocument methodsFor: 'stack operations'!
>
>clearTagStack
>	tagStack := OrderedCollection new!
>
>isWithinTag: aString 
>	^tagStack includes: aString!
>
>popTag
>	^tagStack removeLast!
>
>pushTag: aString 
>	tagStack add: aString! !
>
>
>!Seaside.WAPrettyPrintedDocument methodsFor: 'as yet unclassified'!
>
>closeTag: aString 
>	indentLevel := indentLevel - 1.
>	indentCloseTags removeLast 
>		ifTrue: 
>			[html break.
>			indentLevel timesRepeat: [html space]].
>	(self shouldPrintCloseTagFor: aString) 
>		ifTrue: 
>			[html text: '</'.
>			html spanClass: (self cssClassFor: aString) with: [html text: aString].
>			html text: '>'].
>	self popTag!
>
>initializeWithRenderer: aRenderer 
>	html := aRenderer.
>	indentCloseTags := OrderedCollection with: false.
>	indentLevel := 0.
>	self clearTagStack!
>
>openTag: aString attributes: anAttributes 
>	html break.
>	indentLevel timesRepeat: [html space].
>	html text: '<'.
>	html spanClass: (self cssClassFor: aString) with: [html text: aString].
>	self attributes: anAttributes.
>	(self shouldPrintCloseTagFor: aString) 
>		ifFalse: 
>			[html
>				space;
>				text: '/'].
>	html text: '>'.
>	indentLevel := indentLevel + 1.
>	indentCloseTags
>		removeLast;
>		addLast: true;
>		addLast: false.
>	self pushTag: aString! !
>
>
>!Seaside.WAHtmlStreamDocument methodsFor: 'as yet unclassified'!
>
>closeTag: aString 
>	self writeCloseTag: aString on: self bodyStream.
>	self popTag!
>
>openTag: aString attributes: anAttributes 
>	self 
>		writeOpenTag: aString
>		attributes: anAttributes
>		on: self bodyStream.
>	self pushTag: aString! !
>
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Seaside mailing list
>Seaside at lists.squeakfoundation.org
>http://lists.squeakfoundation.org/listinfo/seaside
>  
>


More information about the Seaside mailing list