For author-defined classes, the emit
method is generated by
the compiler, as shown above. For built-in classes like
TextField
, it is defined by the implementor (me).
TextField
, for example, is specified to emit itself as an HTML
data-entry field with size and value defined by its attributes, and
with a name determined by its id
. Typically, its HTML
would look something like this:
<INPUT TYPE=TEXT SIZE=10 NAME="c137.Page.t" VALUE="0">
The WOM language is conceptually very sparse, most of the interesting behaviour lying in these built-ins. These include:
TextField
: as we just saw, this
is displayed as a normal HTML
data-entry field, for use within forms. It has
a value
attribute, which
can be interrogated by its getValue
method. This will contain
the data last entered by the user.
IntegerField
, RealField
, BooleanField
: these
are
similar to TextField
, but check the syntax of the user's data. If
it is incorrect, they redisplay themselves with an error message
by their side, and also set an error flag attribute.
TextMenu
: this displays a menu and transmits the user's
selection to the server. The menu can hold a translation table, so that
the user can select a string, but the server can
translate this into a number before it is passed to a program. One can
add and delete menu options dynamically.
WOMForm
: This name is used to avoid shielding the HTML
FORM
element. It denotes the built-in class which contains
fields and other input elements and operates on these via an
<OnSubmit>
when submitted.
ActionLink
:
This is a hypertext link which, when clicked on,
initiates some action via an internal OnSubmit
. It can be thought
of as a form with no contents other than some static text and a Submit
button.
Imagemap
: This is an imagemap whose attributes
specify the point last clicked on.
InstanceLink
:
This is another type of hypertext link. It points at an instance, and
is mainly useful for larger applications which consist of several
pages working together.
Text
: This is a slot for text which can be changed at
run-time.
Hider
: This container element holds text and other objects,
but
displays them only if a condition attribute is set. This makes it easy
to switch between displaying various different
pieces of information on a page.
File
: A File
's main attribute is the name of a
text file. The File
displays it. By using this class, one
can write a page which runs a program whose output will go to
temporary files, and which then displays that output.
Region
: This is like a File
, but has
extra attributes
giving byte start-
and end-positions within the file, for the reason given in
Section 2.8.
It displays the text
within this region. WOM uses Regions
so that the
compiled code can
refer to large chunks of the original non-WOM text in an input file
without storing it all in memory as explicit string constants.