Uploaded by JamesGFoster on Feb 17, 2010
In chapter 7 of "Learning Web Development with Seaside" we look at continuations and subroutine calls.
We launch the Seaside One-Click Experience and create a new component that will present a user interface for selecting a date and time. Add an initialize method to create subcomponents for the date selector and the time selector. Add the #'children' method to let Seaside know about the subcomponents. Add a setter method to assign initial values to the selection components.
As mentioned earlier, the #'renderContentOn:' method is the heart of Seaside's HTML generation. In our new component we will define a form and a table to provide layout (proper CSS formatting will be addressed in a later chapter). The form will consist of labels, the date selector, the time selector, and a submit button. Note that we do not specify the actual HTML widgets to be used for the date and time entry, but allow subcomponents to provide that functionality. This demonstrates code and component reuse.
Finally, we add a #'submit' method to handle the callback when the user selects a date/time. Note that when the user makes a selection, the #'submit' method answers the new value. This answer is essentially a subroutine return.
We now have defined the code for a new component. To demonstrate the component, we can register it as an application named 'when' and then view the component in a web browser. It will, of course, be more useful to use this component in our FlightInfo application.
To do that we go to the FlightInfoComponent class and add a method to call our new component. When this method is called, it creates a new component, sets the date/time to the current value, and then calls the new component. The new component presents a web page, waits for the user to select a new date/time, and then returns that date/time.
The important thing to note here is that we have called a subroutine and are waiting for it to return from an interaction with the user. This ability to continue execution after a user interaction is what we get from a using a Smalltalk continuation and it is a striking departure from the typical web framework in which execution starts at the beginning for each request.
Now that we have a method to call the date/time selection component, we add a link to the primary user interface to call the new component. We have an anchor with a callback.
We can go to the web browser and view the new component in action. Note that we can select a new date/time and when we return to the primary component, it will be immediately displayed.
when we are done, we can save our Smalltalk code and quit the Seaside One-Click Experience application.
-
0 likes, 0 dislikes
9:37How To Write A Subroutine codeby 72iSkY47769 views
6:26How To Make A Subroutine Code (Ps2Dis)by LinuXRappY862 views
6:06PLC JSR Jump to Subroutineby jfalbo2,044 views
5:48Lesson 9 Subroutines and Integrated Circuitsby tom02202000472 views
5:48Understanding Subroutine Calls at the Machine L...by profSchramm433 views
9:12VB.NET tutorial 13 - Part 1: Subroutinesby mkaatr1,068 views
1:13CPS in Schemeby smlnjunderemacs629 views
10:33Blog 102 (Continuations)by rammad2792 views
7:08Supporting User Loginby JamesGFoster295 views
3:03Queen - Bicycle Raceby Cosbydawg91470,214 views
2:29Smalltalk IDE as XULRunner remote XUL applicati...by xkriva801,512 views
6:29Issues in Concurrencyby JamesGFoster329 views
3:55Incorporating Images and CSSby JamesGFoster204 views
3:22Smalltalk in Under Five Minutesby jarober1,171 views
3:51Associating Domain Objects with Componentsby JamesGFoster428 views
2:14Fishing Lures & Baits : Types of Fishing Spoonsby trails36,778 views
0:52Drawing gravity in three dimensions.by Balphaus119,673 views
8:32MS Acccess creation of Subroutines in VBA progr...by myaccessprogram8,863 views
1:02Haywood Community College Electronics Engineeri...by jfalbo379 views
50:20Lecture 23 | Programming Paradigms (Stanford)by StanfordUniversity9,412 views
- Loading more suggestions...
Link to this comment:
All Comments (0)