[Seaside] Seaside FAQ - Newbie Examples

dirk newbold dirkdirk at gmail.com
Wed Sep 26 11:38:59 UTC 2007


Skipped content of type multipart/alternative-------------- next part --------------

CLASS SIDE METHODS

initialize
	(self registerAsApplication: 'TieredList') libraries add: Seaside.SULibrary

carBrandList
	^#(#BMW #Ford #Toyota)

bmwModelList
	^#(#'5 Series' #'7 Series')

bmw5SeriesColourList
	^#(#'GER-Black' #'GER-Red' #'GER-White')

bmw7SeriesColourList
	^#(#'GER-Blue')

fordModelList
	^#(#'Cobra' #'Mustang')

fordCobraColourList
	^#(#'USA-Purple' #'USA-Black' #'USA-Orange')

fordMustangColourList
	^#(#'USA-Red')

toyotaModelList
	^#(#'Hi-Lux' #'Land Crusier')

toyotaHiLuxColourList
	^#(#'JAP-Red' #'JAP-Green' #'JAP-Blue')

toyotaLandCrusierColourList
	^#(#'JAP-White')

/**********************************************************************************/

INSTANCE SIDE METHODS

initialize
	super initialize.
	selectList := 1.

list1
	^self class carBrandList

list2
	val1 == nil ifTrue: [ ^self class bmwModelList ].
	val1 == #BMW ifTrue: [ ^self class bmwModelList ].
	val1 == #Ford ifTrue: [ ^self class fordModelList ].
	val1 == #Toyota ifTrue: [ ^self class toyotaModelList ].

list3
	val2 == nil ifTrue: [ ^self class bmw5SeriesColourList ].
	val2 == #'5 Series' ifTrue: [ ^self class bmw5SeriesColourList ].
	val2 == #'7 Series' ifTrue: [ ^self class bmw7SeriesColourList ].
	val2 == #Mustang ifTrue: [ ^self class fordMustangColourList ].
	val2 == #Cobra ifTrue: [ ^self class fordCobraColourList ].
	val2 == #'Hi-Lux' ifTrue: [ ^self class toyotaHiLuxColourList ].
	val2 == #'Land Crusier' ifTrue: [ ^self class toyotaLandCrusierColourList ].

renderContentOn: html
	html div id: 'page'; with: [	
		self renderSelectListOn: html ]

renderSelectListOn: html 
		html div id: 'box1';
			with: [ self renderSelect1: html ].
		html div id: 'box2';
			with: [ self renderSelect2: html ].
		html div id: 'box3';
			with: [ self renderSelect3: html ].

renderSelect1: html
	html select
		id: 'select1';
		list: self list1;
		selected: self list1 first;
		callback: [ : valBox1 | val1 := valBox1. val2 := self list2 first. val3 := self list3 first ];
		onChange: (html updater
			id: 'box2';
			triggerFormElement: 'select1';
			callback: [ :r | self renderSelect2: r ];
			onSuccess: (html updater
				id: 'box3';
				callback: [ :r | self renderSelect3: r ])).

renderSelect2: html
	html select
		id: 'select2';
		list: self list2;
		selected: (self list2 first);
		callback: [ :valBox2 | val2 := valBox2 ];
		onChange: (html updater
			id: 'box3';
			triggerFormElement: 'select2';
			callback: [ :r | self renderSelect3: r ]) .

renderSelect3: html
	html select
		selected: (self list3 first);
		list: self list3;
		callback: [ :valBox3 | val3 := valBox3 ];
		onChange: (html request
			triggerFormElement: 'select2')
style
	^'
	body { align: center; }

	#page {
		width: 560px;
		margin-left: auto;
		margin-right: auto;
		text-align: center;
		border: 1px solid black;
	}

	#box1 {
		float: left;
		width: 150px;
		border: 1px solid black;
		margin: 10px 10px 10px 10px;
		padding: 5px 5px 5px 5px;
	}

	#box2 {
		float: left;
		width: 150px;
		border: 1px solid black;
		margin: 10px 10px 10px 10px;
		padding: 5px 5px 5px 5px;
	}

	#box3 {
		float: left;
		width: 150px;
		border: 1px solid black;
		margin: 10px 10px 10px 10px;
		padding: 5px 5px 5px 5px;
	}

'
-------------- next part --------------
<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.5 of April 16, 2007 on September 26, 2007 at 1:08:39 pm</time-stamp>
<!-- Package TieredList* -->


<class>
<name>BrandModelColour</name>
<environment>Smalltalk</environment>
<super>Seaside.SUComponent</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>val1 val2 val3 selectList </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>DirkTest</category>
<attributes>
<package>TieredList</package>
</attributes>
</class>


<methods>
<class-id>BrandModelColour class</class-id> <category>instance creation</category>

<body package="TieredList" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>

<body package="TieredList" selector="initialize">initialize
	(self registerAsApplication: 'TieredList') libraries add: Seaside.SULibrary</body>
</methods>

<methods>
<class-id>BrandModelColour class</class-id> <category>accessing</category>

<body package="TieredList" selector="bmw7SeriesColourList">bmw7SeriesColourList
	^#(#'GER-Blue')</body>

<body package="TieredList" selector="bmwModelList">bmwModelList
	^#(#'5 Series' #'7 Series')</body>

<body package="TieredList" selector="toyotaModelList">toyotaModelList
	^#(#'Hi-Lux' #'Land Crusier')</body>

<body package="TieredList" selector="carBrandList">carBrandList
	^#(#BMW #Ford #Toyota)</body>

<body package="TieredList" selector="fordModelList">fordModelList
	^#(#'Cobra' #'Mustang')</body>

<body package="TieredList" selector="fordMustangColourList">fordMustangColourList
	^#(#'USA-Red')</body>

<body package="TieredList" selector="toyotaHiLuxColourList">toyotaHiLuxColourList
	^#(#'JAP-Red' #'JAP-Green' #'JAP-Blue')</body>

<body package="TieredList" selector="bmw5SeriesColourList">bmw5SeriesColourList
	^#(#'GER-Black' #'GER-Red' #'GER-White')</body>

<body package="TieredList" selector="toyotaLandCrusierColourList">toyotaLandCrusierColourList
	^#(#'JAP-White')</body>

<body package="TieredList" selector="fordCobraColourList">fordCobraColourList
	^#(#'USA-Purple' #'USA-Black' #'USA-Orange')</body>
</methods>


<methods>
<class-id>BrandModelColour</class-id> <category>rendering</category>

<body package="TieredList" selector="style">style
	^'
	body { align: center; }

	#page {
		width: 560px;
		margin-left: auto;
		margin-right: auto;
		text-align: center;
		border: 1px solid black;
	}

	#box1 {
		float: left;
		width: 150px;
		border: 1px solid black;
		margin: 10px 10px 10px 10px;
		padding: 5px 5px 5px 5px;
	}

	#box2 {
		float: left;
		width: 150px;
		border: 1px solid black;
		margin: 10px 10px 10px 10px;
		padding: 5px 5px 5px 5px;
	}

	#box3 {
		float: left;
		width: 150px;
		border: 1px solid black;
		margin: 10px 10px 10px 10px;
		padding: 5px 5px 5px 5px;
	}

'</body>

<body package="TieredList" selector="renderContentOn:">renderContentOn: html
	html div id: 'page'; with: [	
		self renderSelectListOn: html ]</body>

<body package="TieredList" selector="renderSelect2:">renderSelect2: html
	html select
		id: 'select2';
		list: self list2;
		selected: (self list2 first);
		callback: [ :valBox2 | val2 := valBox2 ];
		onChange: (html updater
			id: 'box3';
			triggerFormElement: 'select2';
			callback: [ :r | self renderSelect3: r ]) .</body>

<body package="TieredList" selector="renderSelect3:">renderSelect3: html
	html select
		selected: (self list3 first);
		list: self list3;
		callback: [ :valBox3 | val3 := valBox3 ];
		onChange: (html request
			triggerFormElement: 'select2')</body>

<body package="TieredList" selector="renderSelect1:">renderSelect1: html
	html select
		id: 'select1';
		list: self list1;
		selected: self list1 first;
		callback: [ : valBox1 | val1 := valBox1. val2 := self list2 first. val3 := self list3 first ];
		onChange: (html updater
			id: 'box2';
			triggerFormElement: 'select1';
			callback: [ :r | self renderSelect2: r ];
			onSuccess: (html updater
				id: 'box3';
				callback: [ :r | self renderSelect3: r ])).</body>

<body package="TieredList" selector="renderSelectListOn:">renderSelectListOn: html 
		html div id: 'box1';
			with: [ self renderSelect1: html ].
		html div id: 'box2';
			with: [ self renderSelect2: html ].
		html div id: 'box3';
			with: [ self renderSelect3: html ].</body>
</methods>

<methods>
<class-id>BrandModelColour</class-id> <category>accessing</category>

<body package="TieredList" selector="list2">list2
	val1 == nil ifTrue: [ ^self class bmwModelList ].
	val1 == #BMW ifTrue: [ ^self class bmwModelList ].
	val1 == #Ford ifTrue: [ ^self class fordModelList ].
	val1 == #Toyota ifTrue: [ ^self class toyotaModelList ].</body>

<body package="TieredList" selector="list3">list3
	val2 == nil ifTrue: [ ^self class bmw5SeriesColourList ].
	val2 == #'5 Series' ifTrue: [ ^self class bmw5SeriesColourList ].
	val2 == #'7 Series' ifTrue: [ ^self class bmw7SeriesColourList ].
	val2 == #Mustang ifTrue: [ ^self class fordMustangColourList ].
	val2 == #Cobra ifTrue: [ ^self class fordCobraColourList ].
	val2 == #'Hi-Lux' ifTrue: [ ^self class toyotaHiLuxColourList ].
	val2 == #'Land Crusier' ifTrue: [ ^self class toyotaLandCrusierColourList ].</body>

<body package="TieredList" selector="list1">list1
	^self class carBrandList</body>
</methods>

<methods>
<class-id>BrandModelColour</class-id> <category>initialize-release</category>

<body package="TieredList" selector="initialize">initialize
	super initialize.
	selectList := 1.</body>
</methods>



<initialize>
<class-id>BrandModelColour</class-id>
</initialize>

</st-source>


More information about the seaside mailing list