newbie needs help

goran.hultgren at bluefish.se goran.hultgren at bluefish.se
Tue May 21 11:20:50 UTC 2002


Avi Bryant <avi at beta4.com> wrote:
> On Mon, 20 May 2002, Rob Whitfield wrote:
> 
> > I've been playing with Comanche.  Real cool.  I've modified a few simple
> > demos but I'm having trouble getting the turtle demo to work - the demo is
> > documented at http://minnow.cc.gatech.edu/swiki/7
> >
> > When I submit the form I get "Cannot find server or DNS Error". Do you know
> > any other good Comanche demos for processing a form submission?
> 
> Rob, if you're building web apps, I might as well plug Seaside:
> http://beta4.com/seaside .  It uses Comanche underneath (or can, anyway),
> but does a lot more for you - more at the level of WebObjects or, say,
> Zope (although, naturally, much cooler than either ;-).
> 
> There are a couple of tutorials to get you started, and a mailing list
> and swiki for the rest.
> 
> Cheers,
> Avi

Ok, then I just can't help plug "HttpView" too! :-) It's not nearly as
polished or ambitious as Seaside but it has an interesting design and I
think it can appeal to some people/projects:

1. It's ALL in Smalltalk. (That's right - no HTML files). You build
pages like you build UIs programmatically using a "builder" object.
2. It's small - about 20 classes of which you really only need to know 2
intimately. :-) (1300 LOC including comments)
3. It's just a changeset ontop of Comanche. Easy and simple.
4. It handles Forms in a IMHO pretty cool way making the code MINIMAL. 

I intend to pack it up at:

http://anakin.bluefish.se:8000/gohu/6

...in the coming days, but if anyone is interested I can produce a
snapshot - just mail privately.

A silly example, I just wrote this page below and tested it, it took me
exactly 3 minutes and 10 seconds to write from scratch and test
successfully. :-) Of course I am a pretty slow typer and I already had a
running system with a class to add the method to... This is a webpage
with a textfield and a submit button and when you press submit the
entered text is shown below the submit button - a screenshot is
attached.

I have added a comment on each line to show you what it is/does:

helloworld
	"Hello world!"

	| b text var |
	b _ self builder. "an inherited method in superclass HVHttpView that
instantiates a HVHtmlBuilder"
	b start; h1: 'Sample'; postForm. "Start the HTML page with a default
beginning, add a heading, start a form using POST" 
	textField _ b html: 'Type something: '; inputText. "Add some HTML
verbatim, add a text field. The textfield is returned as an instance of
HVHtmlInputText"
	b br; submit; endForm. "Add a linebreak, a submit button and end the
form."
	var _ b var. "Add a variable that can be given it's value further down
before returning the builder to Comanche."
	b end. "End the HTML page with a default ending."
	b ifPost: [var value: text value]. "Ask the builder if this request was
in fact a POST of the form instead of a GET of the page. If it was a
POST - insert the value of the textField (a String) as the value of the
embedded variable."
	^b "Return the builder to Comanche which will ask the builder to
produce the end resulting page and return it to the browser."

A few things to note:

-No HTML page needs to be written.
-No ids required to match Form fields etc.
-The same code is run (by default) to process the GET as the POST. In
both scenarios we typically want to construct more or less the same
page.

So, is it short enough? :-)

regards, Göran
-------------- next part --------------
A non-text attachment was scrubbed...
Name: helloworld.jpg
Type: application/octet-stream
Size: 31916 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020521/bd90625e/helloworld.obj


More information about the Squeak-dev mailing list