seaside tutorial. outline ● focus on components ● rendering basics ● rendering anchors with...
TRANSCRIPT
![Page 1: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/1.jpg)
Seaside Tutorial
![Page 2: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/2.jpg)
Outline
● Focus on components● Rendering basics● Rendering anchors with callbacks (next,
previous)● Call: of a built-in component (call the
STSDateSelectorDialog)
![Page 3: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/3.jpg)
Component Rendering
● Seaside components:– Subclass WAComponent– Implement #renderContentOn:– Argument is “renderer” (WAHtmlRenderer
instance)
![Page 4: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/4.jpg)
ExamplerenderContentOn: html
html paragraph: 'This is a paragraph'.html unorderedList:
[html listItem: 'Item 1'.html listItem: 'Item 2'.html listItem: 'Item 3'].
![Page 5: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/5.jpg)
Calendar
● Browse WAHtmlRenderer and especially superclass
● Complete STSCalendar● Demo
![Page 6: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/6.jpg)
Anchors and callbacks
● Method #anchorWithAction:text: takes block and invokes it in response to following anchor
● Render loop (so far):– Handle callbacks– Render component
renderContentOn: htmlhtml
anchorWithAction: [self doSomething] text: 'Do something'
![Page 7: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/7.jpg)
Anchors and callbacks
● Add “next” and “previous” buttons to calendar
![Page 8: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/8.jpg)
Tasks and sequencing
● WAComponent>>#call:– Displays argument
● WAComponent>>#answer:– Returns from call:– Argument is return value of call:
![Page 9: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/9.jpg)
Tasks
● Components whose primary responsibility are sequencing
● Subclass WATask and override #go● Complete ReservationTask:
– Create and call: a STSDateSelectorDialog– demo
![Page 10: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/10.jpg)
Calendar should answer
● Modify STSCalendar so that it answers when user clicks date.
● Change ReservationTask so that it uses your calendar
![Page 11: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/11.jpg)
Embedding components
● One component can nest other components:– Create child components in #initialize– Answer child components array in
#children– Send “html render: child” in
renderContentOn:
![Page 12: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/12.jpg)
Catching answer
● In some cases parent component needs to “catch” answer of subcomponent.
● Use #onAnswer:
![Page 13: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/13.jpg)
initializesuper initialize.startDateSelector := STSCalendar new.endDateSelector := STSCalendar new.
startDateSelector onAnswer: [:v | self updateArrival: v].endDateSelector onAnswer: [:v | self updateDeparture: v].
![Page 14: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/14.jpg)
children^ Array with: startDateSelector with: endDateSelector
![Page 15: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/15.jpg)
renderContentOn: html“.... omitted code for form and button ....”html table:
[html tableHeadings: #('Arrival Date' 'Departure Date').html
tableRowWith: [html render: startDateSelector]with: [html render: endDateSelector]].
![Page 16: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/16.jpg)
![Page 17: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/17.jpg)
Task: Guessing game step 1
● Your image STSGuessingGame● Subclass WATask● Use #inform: and #request: to display
messages and get input● Demo
![Page 18: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/18.jpg)
Task: Guessing game step 2
● Add counter for “number of tries”● Try both method-local variable and i-var● Compare behavior of above when using
“back” button
![Page 19: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/19.jpg)
Task: Guessing game step 2
● Seaside's use of continuations captures values of method-local variables (back button “backs them up”) but not i-vars
● Add #initialize
initializesuper initialize.self session registerObjectForBacktracking: self.
![Page 20: Seaside Tutorial. Outline ● Focus on components ● Rendering basics ● Rendering anchors with callbacks (next, previous) ● Call: of a built-in component](https://reader036.vdocuments.mx/reader036/viewer/2022080223/5697bfef1a28abf838cba0ca/html5/thumbnails/20.jpg)
Snapshotting
● Objects registered for backtracking are sent #snapshot– Default impl is shallowCopy
● Restoring snapshot done with #restoreFromSnapshot: