REST service in seaside Smalltalk

871 Views Asked by At

I have the following class in Pharo

WARestfulHandler subclass: #PgUserAddHandler
instanceVariableNames:  ' employeeId'
classVariableNames: ''
poolDictionaries: ''
category: 'abc-Model'

I want to implement a function which renders a page of a WAComponent class, something like shown below from within the above class.

searchFor: aString
<get>
<path: '/userAdd?add={aString}'>
self render: (PgEmployeeRegisterComponent new) employeeId:aString.

Please help !!

Thanks in advance !!

1

There are 1 best solutions below

0
On

Replace your last line with:

^ WAHtmlCanvas builder render: WACounter new

The WAHtmlCanvas builder render: returns a string of the rendered data. To have more flexibility you can also pass in a block, like to any brush:

^ WAHtmlCanvas builder render: [ :html |
    html heading level: 1; with: 'Counter'.
    html div 
        class: 'counter';
        with: WACounter new ]

Note that a new instance of your component will be created for each request. No state is automatically preserved and callbacks do not work out of the box.