[Seaside] Using one component to render multiple views?
Keith Hodges
keith_hodges at yahoo.co.uk
Fri Aug 11 00:57:18 UTC 2006
Dear Rick,
It may not be necessary to have lots of different components, if you
have ever looked at SUnit, there is one class, but each time you
instanciate an instance you indicate which test case you want that
instance to run. The test case is run according to its selector.
This piece of smalltalk trickery is handled by Object>>#perform: aSelector
I tried the attached code, in which callbacks are able to switch the
viewSelector and it seemed to work quite well.
Keith
----
-------------- next part --------------
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 11 August 2006 at 1:53:51 am'!
WAFrameComponent subclass: #WAMultipleViewComponent
instanceVariableNames: 'viewSelector'
classVariableNames: ''
poolDictionaries: ''
category: 'Magma seaside'!
!WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:26'!
renderContentOn: html
^self perform: self viewSelector with: html! !
!WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:30'!
rendererClass
^ WARenderCanvas! !
!WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:28'!
setView: viewName
^ viewSelector := ('render' , viewName capitalized , 'On:' ) asSymbol
! !
!WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:25'!
viewSelector
^ viewSelector ifNil: [ #renderViewOn: ]! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
WAMultipleViewComponent class
instanceVariableNames: ''!
!WAMultipleViewComponent class methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:27'!
view: viewName
^ self new setView: viewName; yourself! !
-------------- next part --------------
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 11 August 2006 at 1:53:57 am'!
WAMultipleViewComponent subclass: #WAMultipleViewTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Magma seaside'!
!WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:47'!
renderAddOrganisationOn: html
html heading: 'Add Organisation'.
html anchor callback: [ self setView: 'View' ]; text: '(done)'.! !
!WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:36'!
renderConfigOn: html
self renderViewOn: html.
html horizontalRule.
html break; text: 'configuration options: '.
html anchor callback: [ self setView: 'EditOrganisation' ]; text: '(edit organisations)'.
html anchor callback: [ self setView: 'AddOrganisation' ]; text: '(add organisation)'.! !
!WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:47'!
renderEditOrganisationOn: html
html heading: 'Edit Organisation'.
html anchor callback: [ self setView: 'View' ]; text: '(done)'.! !
!WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:41'!
renderViewOn: html
html heading: 'Default View'.
html break; text: 'nothing doing'.
! !
More information about the Seaside
mailing list