3

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 !!

MKroehnert
  • 3,637
  • 2
  • 34
  • 43
VARUN ISAC
  • 443
  • 3
  • 13

1 Answers1

3

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.

Lukas Renggli
  • 8,754
  • 23
  • 46