[Seaside] Rendering Component in a WAPragmaBasedRestfulHandler

Julian Fitzell jfitzell at gmail.com
Wed Apr 13 16:28:10 UTC 2011

Unless, you're re-using some of the rendering code in multiple places,
you might find it cleaner to simply subclass
WAPragmaBasedRestfulHandler to provide a renderer. It could even be
implemented with an additional pragma instead of hardcoding:

MyFilter>>#listingOfProject: projectName on: html
       <Path: '/{projectName}'>
       <Renderer: #WARenderCanvas>
       "Or, alternatively just: <Canvas>"

       html text: 'hello world'

You could of course then "html render: anObject", though I'd suggest
that you don't really want to use components here, because you have no
session and thus no state for them to maintain. You would probably be
better to subclass WAPainter if you want to re-use some rendering code
in several places.


On Wed, Apr 13, 2011 at 5:10 PM, Tobias Pape <Das.Linux at gmx.de> wrote:
> Am 2011-04-13 um 17:38 schrieb Camillo Bruni:
>> Hi,
>> I am onto building test website in seaside which should have nice urls. I stumbled upon the Seaside-REST package, which seems like a nice solution to map the urls onto state and components.
>> However so far I could not figure out how I should render a component from within a WAPragmaBasedRestfulHandler method.
>> This is how I imagine it should work:
>> request -> stateful request handler -> choose component and initialize state -> render component
>> What is the proper way to do this?
> Think of this:
> MyFilter>>#listingOfProject: projectName
>        <GET>
>        <Path: '/{projectName}'>
>        MyComponent new respondRendered
> with
> MyComponent>>#respondRendered
>        self requestContext respond: [:response |
>                response
>                        contentType: WAMimeType textHtml;
>                        nextPutAll: (   WARenderCanvas builder
>                                fullDocument: true;
>                                rootBlock: [ :root |
>                                        self updateRoot:root ];
>                                render: [ :canvas |
>                                        self renderContentOn: canvas ])].
> This merely emulates a normal seaside run.
> But more elaborate versions are possible.
> So Long,
>        -Tobias_______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list