+ All Categories
Home > Documents > Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · •...

Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · •...

Date post: 17-Oct-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
32
Web Applications, Continuations, & Seaside CS 510 Advanced Programming Andrew P. Black 1
Transcript
Page 1: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Web Applications Continuations amp Seaside

CS 510 Advanced Programming

Andrew P Black

1

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

No shared state

Consider ldquologging inrdquo

bull ldquolog inrdquo button creates a new Login web page asking for user name and password

bull ldquosubmitrdquo button on the Login page passes the results of the fields to a validation routine which determines if login is successful

bull One of two response pages must be generated and displayed

3

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

login page

login request

submit

login OK

login failed

Compare with a desktop application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 2: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

No shared state

Consider ldquologging inrdquo

bull ldquolog inrdquo button creates a new Login web page asking for user name and password

bull ldquosubmitrdquo button on the Login page passes the results of the fields to a validation routine which determines if login is successful

bull One of two response pages must be generated and displayed

3

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

login page

login request

submit

login OK

login failed

Compare with a desktop application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 3: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

No shared state

Consider ldquologging inrdquo

bull ldquolog inrdquo button creates a new Login web page asking for user name and password

bull ldquosubmitrdquo button on the Login page passes the results of the fields to a validation routine which determines if login is successful

bull One of two response pages must be generated and displayed

3

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

login page

login request

submit

login OK

login failed

Compare with a desktop application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 4: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

No shared state

Consider ldquologging inrdquo

bull ldquolog inrdquo button creates a new Login web page asking for user name and password

bull ldquosubmitrdquo button on the Login page passes the results of the fields to a validation routine which determines if login is successful

bull One of two response pages must be generated and displayed

3

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

login page

login request

submit

login OK

login failed

Compare with a desktop application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 5: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Why are Web Apps hardbull Desktop applications

ask the user questionsbull Web apps put the web

browser in charge

2

App

licat

ion

Use

r

Tim

e

call

return

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

http get

response

No shared state

Consider ldquologging inrdquo

bull ldquolog inrdquo button creates a new Login web page asking for user name and password

bull ldquosubmitrdquo button on the Login page passes the results of the fields to a validation routine which determines if login is successful

bull One of two response pages must be generated and displayed

3

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

login page

login request

submit

login OK

login failed

Compare with a desktop application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 6: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Consider ldquologging inrdquo

bull ldquolog inrdquo button creates a new Login web page asking for user name and password

bull ldquosubmitrdquo button on the Login page passes the results of the fields to a validation routine which determines if login is successful

bull One of two response pages must be generated and displayed

3

Use

rrsquos W

eb b

row

ser

App

licat

ion

Serv

er

login page

login request

submit

login OK

login failed

Compare with a desktop application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 7: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Compare with a desktop application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 8: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 9: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 10: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application

4

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 11: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Compare with a desktop application

| user | user = self attemptAuthentication user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

bull Seaside lets you write more or less the same thing in a web application | user | user = self call AuthenticationComponent new user username = ifFalse [ self inform Login successful user username] ifTrue [ self inform Login failed ]

4

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 12: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

bull AuthenticationComponent is also straightforward

AuthenticationComponent gtgt renderContentOn html | user | user = AuthUser new html form [ html paragraph with [ html span with Username html textInput on username of user ] html paragraph with [ html span with Password html textInput on password of user ] html submitButton callback [ self answer user ] ]

5

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 13: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

bull The keys are the call and answer messages which save and resume a computation

bull They are implemented using continuations

6

How does this work

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 14: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Continuations in Smalltalk

bull Continuations are not ldquobuilt inrdquo to Smalltalk but Smalltalk has enough reflective capability to

build continuations into a library

bull thisContext is the sixth keyword in Smalltalk What are the other five

thisContext answers the current execution context usually a MethodContext or a BlockContext

7

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 15: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

uses of thisContext

bull Most obvious use is in the debugger the context objects make up the stack

each Context object is linked to the previous one using the sender instance variable

bull thisContext can also be used to implement Continutaions

8

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 16: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Class Continuation

bull letʼs look at the implementation

bull letʼs try some examples using continuations

9

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 17: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Seaside

bull Presentation based on a chapter from the as-yet-unpublished volume 2 of ldquoSqueak by Examplerdquo (on class web page)

10

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 18: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

How to get Seaside

bull The Seaside ldquoone click experiencerdquo available from httpwwwseasidest

designed for people who donʼt already know how to run Squeak

Multi-platform

All you really need is the Seaside image

11

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 19: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

In the Seaside imagehellip

bull There is a web server you have to start it

deg WAKom startOn 8080

and eventually stop itdeg WAKom stop

bull Then point your web browser at it httplocalhost8080seaside

12

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 20: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Componentsbull Seaside web pages are built from

Components subinstances of WAComponent

bull Similar to on-screen GUIs built from subinstances of Morph

bull Each Component is responsible for rendering itself onto an HTML ldquocanvassrdquo has application-specific state in its instance vars

13

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 21: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 22: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Componentsbull Components are reusable a component can be instantiated many times in

different contexts

bull Some components can be top-level ldquoapplicationsrdquo

14

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 23: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Examples Directory

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 24: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 25: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Examples Directory

bull Counter

bull Config page

bull MultiCounter

15

canBeRoot

WAComponent false

canBeRootinitializeinitializeincreasedecreaserenderContentOn htmlstates

countWACounter

truehtml heading counthtml anchor

callback [ self increase ]with ++

html spacehtml anchor

callback [ self decrease ]with --

Array with self

states

WAPresenter () self

registerAsApplication examplescounter

super initializeself count 0

count = count + 1

count = count ndash 1

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 26: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Cleint-side Editing

bull Toggle Halos gives access to class browser

object inspector

CSS Style editor

16

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 27: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

ldquoHello Worldrdquo in Seasidebull Define a subclass of WAComponent called

WAHelloWorld

bull Implement the renderContentOn method WAHelloWorldraquorenderContentOn html html text hello world

bull Tell Seaside that WAHelloWorld is an ldquoapplicationrdquo WAHelloWorld classraquocanBeRoot

uarr true

bull Configure seaside to launch the application Point the browser to http localhost8080seasideconfig

17

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 28: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Backtracking

bull When we went back to an earlier counter the state of the counter was correctly backtracked What makes this happen

bull Each component is sent the message states it answers the objects that should be (shallow) copied into a WASnapshot WACounterrsaquorsaquostates answers self

18

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 29: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Rendering

bull Rendering html is a bit like drawing onto a graphics canvas each component is responsible for drawing itself

the Seaside framework starts the process by creating the html canvas and asking the top-level component to draw itself

19

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 30: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Rendering the counter

renderContentOn html13 html heading count13 html anchor13 13 callback [ self increase ]13 13 with ++13 html space13 html anchor13 13 callback [ self decrease ]13 13 with --

20

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 31: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

Multicounterbull WAMulticounter has WACounters as

components

21

children

WAComponent ()

canBeRootinitializerenderContentOn htmlchildren

counters

WAMultiCounter true

counters

do [ each | html render each ]

separatedBy [ html horizontalRule ]

counters

super initialize

counters = (1 to 5) collect

[ each | WACounter new ]

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22

Page 32: Web Applications, Continuations, & Seasideweb.cecs.pdx.edu/~black/AdvancedProgramming... · • Seaside lets you write more or less the same thing in a web application: | user | user

WACanvasbull the ldquohtmlrdquo argument to a rendering method

is a WARenderCanvas it provides ldquobrushesrdquo for many html markups

22


Recommended