next up previous
Next: Plain text and standard HTML inside pages
Up: The WOM language
Previous: How do attributes get their values?

Instances inside pages

 

Suppose we had a WOM source file, example.wom, which contained just two WOM elements and nothing else:

<TextField size=10 value="0">
<TextField size=11 value="1">
Then the compiler would translate it into a class of the form
::class example subclass Page public

  ::method init
    expose contents
    contents = .list~of(,
                         .TextField~new()~~setsize(10)~~setvalue("0"),,
                         .TextField~new()~~setsize(11)~~setvalue("1"),
                       )
    return

  ::method emit
    expose contents
    use arg output_stream
    do item over contents
      item~emit( output_stream )
    end
    return

The idea is that when an instance of the page is created, it initialises itself with a list containing one instance of each TextField. When the page instance is asked to emit itself, it runs over its contents asking these fields to do the same.



Jocelyn Ireson-Paine
Fri May 30 14:03:06 BST 1997