To: "Squeak List"
Subject: webtalk - web applications using squeak
WHAT IT IS
Webtalk allows one to write interactive web applications using
Squeak. It includes an RPN calculator application as a demo.
HOW IT WORKS
The web client invokes the Webtalk CGI script on the web server, =
either
by POSTing or GETing a form, or by explicitly calling it by URL.
The Webtalk CGI script, written in Perl, gathers information from the
system=B9s evironment variables and standard input (provided by the =
web
server), parses, packages and sends this information to the Smalltalk
image running on the same or another machine using TCP/IP sockets.
The Smalltalk image receives the information, parses it, and
instantiates a subclass of WebtalkPage as determined by the value of =
the
hidden field webtalkClass passed from the server and embedded =
originally
in the HTML form or the URL. All of the form data and standard
environment variables can be accessed from this object by using as
selectors the NAME paramter specified for the fields in the HTML file.
The newly created object processes the form information (if any) and
generates a HTML page (using the supplied classes) that is passed =
back
to the Perl script, and then ultimately to the web client.
State information between screens is maintained by instances of
WebtalkSession. An initial session is created for you which you can
store data in. To make this session information available to other
screens, you must specify the session when creating the form that =
will
contain the buttons that will lead to another screen. The sample
RPN calculator application uses sessions.
COMPARISONS TO COMMERCIAL PRODUCTS
I believe this is the same basic capability provide by the IBM and
ParcPlace products, with four major differences:
1.I don=B9t generate HTML screens from a GUI painter (which I think =
is of
dubious value anyway). I do include classes to generate HTML, though.
2.Webtalk costs nothing, as opposed to 1-n thousand dollars
3.Webtalk has not been tested / performance tuned for servers =
handling
jillions of hits per second.
4.If you have to use Squeak, I don=B9t think there is
any other available option (yet). Oh, the joys of monopoly!!!!
WHAT IT WORKS WITH
I imagine one should be able to get this system working on any web
server that supports CGI scripts and Perl, but I have only tested it =
on
Linux using the CERN 3.0A server. Also, I have only tested the =
Smalltalk
portion on the Macintosh and Windows versions of Squeak.
GETTING STARTED
Download the VSExcetpions, VSEvents, Connections, and Webtalk
packages from STP's webstie and install them in that order.
Download the perl script, webtalk.pl.cgi from the site as well.
Read and follow the directions in: WebtalkServer>>installation
CODE WRITTEN FOR THE CALCULATOR DEMO
process: session
"this method should be broken up, but has remained monolithic
so that i can have a complete demo in one method"
| page form calculator |
"process keystroke"
session isNew
ifTrue:
[calculator _ RPNCalculator new.
session data: calculator.]
ifFalse:
[calculator _ session data.
self entry ~=3D '' ifTrue: [calculator push: self entry asNumber].
(self clicked: 'enter')
ifTrue: [self entry =3D '' ifTrue: [calculator dup]].
(self clicked: 'drop') ifTrue: [calculator drop].
(self clicked: 'add') ifTrue: [calculator add].
(self clicked: 'subtract') ifTrue: [calculator subtract].
(self clicked: 'divide') ifTrue: [calculator divide].
(self clicked: 'multiply') ifTrue: [calculator multiply].
(self clicked: 'float') ifTrue: [calculator float].
(self clicked: 'rational') ifTrue: [calculator rational]].
"generate new html page, add header"
page _ HTMLPage title: 'Smalltalk RPN Calculator'.
page add: 'Smalltalk RPN Calculator' heading2.
page add: HorizontalRule newLine.
"add the stack"
calculator stack reversed
do: [:line | page add: line printString rightAligned].
page add: HorizontalRule newLine.
"add the buttons (with a form)"
form _ HTMLForm nextPage: 'RPNCalculatorPage' session: session.
form add:
(FormEntryField
name: 'entry'
value: ''
length: 20) rightAligned newLine.
form add:
((FormSubmitButton name: 'enter' label: 'Enter'),
(FormSubmitButton name: 'drop' label: 'Drop') , ' ' ,
(FormSubmitButton name: 'add' label: ' + ') ,
(FormSubmitButton name: 'subtract' label: ' - ') ,
(FormSubmitButton name: 'multiply' label: ' * ') ,
(FormSubmitButton name: 'divide' label: ' / ') , ' ' ,
(FormSubmitButton name: 'float' label: 'Float') ,
(FormSubmitButton name: 'rational' label: 'Rational')) rightAligned.
page add: form.
page add: NewLine.
"add quit option"
page add: ('quit' linkTo: =
'webtalk.pl.cgi?webtalkClass=3DMainTestPage').
^ page code! !
LICENSE
Webtalk is (c) 1997 by Thregecy Inc..
Webtalk may be used for any purpose on the Squeak platform;
however, using webtalk on any other Smalltalk system is
not permitted.
--
tim jones (tim@thregecy.com)
director and chair of thregecy, director of development
3210 foxcreek drive, richardson tx 75082 - (972)918-9877
supporting effective courtroom communication
]]>