[Seaside] Component rendering
Avi Bryant
avi.bryant at gmail.com
Sat Jun 25 15:24:27 CEST 2005
On 6/21/05, Alain Fischer <alain.fischer at bluewin.ch> wrote:
> What is the simplest way to render a component ?
>
> In the past, I was using:
>
> > testSstTemplate
<snip>
Good question. The below seems to work (though duplicating a fair bit
of WARenderLoop>>render):
WAComponent class>>renderSampleInstance: aBlock
|session root context docRoot document|
session := WASession application: WAApplication new.
^ WACurrentSession use: session during:
[root := self new.
aBlock value: root.
context := WARenderingContext new request: WARequest new.
context actionUrl: (WAUrl new addToPath: 'action').
docRoot := WAHtmlRoot new.
root visiblePresentersDo: [:ea | ea updateRoot: docRoot].
document := WAHtmlStreamDocument root: docRoot.
context document: document.
root decorationChainDo: [:ea | ea renderWithContext: context].
document close.
document stream contents]
Use it like this:
"should return HTML for a counter of value 2"
WACounter renderSampleInstance: [:inst | inst increase; increase]
More information about the Seaside
mailing list