HV intro (was Re: Squeak SSP-- huh?)

Avi Bryant avi at beta4.com
Thu Apr 4 09:45:28 UTC 2002


On Thu, 4 Apr 2002 goran.hultgren at bluefish.se wrote:

> In HV you build webpages much like you build UIs programmatically - you
> know - create window, add button, add field etc. Here is a small example
> from some of my current code, it is a page with a form for editing a
> "channel" object:
>
> default
> 	"Edit a channel."
>
> 	| b resource protocol name description |
> 	b _ self builder.
> 	b start; h1: model name; postForm.
> 	b html: 'Type: ', model type name asString, ' Address: ', model
> computeAddress printString.
> 	name _ b br; br; html: 'Name: '; inputTextValue: model name.
> 	description _ b br; html: 'Description: '; inputTextValue: model
> description.
> 	resource _ b br; html: 'Resource: '; selectObjects: model account
> resourcesWithoutTypes value: model resource.
> 	protocol _ b br; html: 'Protocol: '; selectObjects: model
> availableProtocols value: model protocol.
> 	b br; submit: 'Save'; reset: 'Restore'; endForm; linkBackParent; hr;
> srcLink; end.
> 	b ifPost: [
> 		model name ~= name value ifTrue:[model name: name value].
> 		model description: description value.
> 		model resource: resource value.
> 		model protocol: protocol value.
> 		^self redirectToDefault
> 	].
> 	^b

Göran,

I thought you might be interested in how the above method would look in
Seaside.  It could in fact be entirely done in HTML - you would need a
Seaside component class with a 'model' instance variable and the following
#html method:

html
^ '
  <h1>[model.name]</h1>
  <form action="@reload">
   Type: [model.type.name]
   Address: [model.computeAddress]
   <br><br>
   Name: <input type="text" name="@model.name">
   <br>
   Description: <input type="text" name="@model.description">
   <br>
   Resource:
    <select list="@resource/model.account.resourcesWithoutTypes">
      <option item="@model.resource">[resource]</option>
    </select>
   <br>
   <input type="submit" value="Save">
   <input type="reset" value="Restore">
  </form>
  <a action="@return">(back)</a>
 '

The semantics are the same - submitting the form will reload the current
page (that's the 'action="@reload"' part) and will update all the model's
values.  And I think I the HTML is the same, although I may be wrong about
exactly what your builder outputs.

Cheers,
Avi




More information about the Squeak-dev mailing list