1Webapp.autoFill(3kaya)       Kaya module reference      Webapp.autoFill(3kaya)
2
3
4

NAME

6       Webapp::autoFill - Automatically fill a HTML form
7

SYNOPSIS

9       Void  autoFill(  ElementTree  form,  DataSource  mainvars, Dict<String,
10       [String]>  extravars=Dict::new() )
11

ARGUMENTS

13       form The form element (or a subset of that if you only wish to automat‐
14       ically fill a part of the form.
15
16       mainvars The data source to use (e.g.  DataPost )
17
18       extravars  An  optional  dictionary mapping keys to lists of values, to
19       allow a form to be automatically filled from a database. You may or may
20       not need to use DataNone as your main data source in this case.
21

DESCRIPTION

23       Automatically  fill  a  HTML  form based on data from a particular data
24       source. This makes it easy to construct web forms with error handling -
25       see  the  webapp tutorial ⟨http://kayalang.org/tutorial/web/webapp⟩ for
26       more information.
27
28
29    ElementTree OnHello(Int dummy) {
30        div = anonymousBlock; // we create this temporarily.
31        fname = incomingValue("fname",DataPost);
32        lname = incomingValue("lname",DataPost);
33        if (fname != "" && lname != "") {
34            p = addParagraph(div,"Hello "+fname+" "+lname);
35            return p;
36        } else {
37            form = HelloForm();
38    // if they entered one of first and last name, make sure it's still in the
39   form
40            autoFill(form,DataPost);
41            return form;
42        }
43    }
44
45    ElementTree helloForm() {
46        parent = anonymousBlock;
47        form = addLocalForm(parent);
48        f1 = addFieldset(form,"Who are you?");
49        input = addLabelledInput(f1,"Your First Name",InputText,"fname","",0);
50        input = addLabelledInput(f1,"Your Last Name",InputText,"lname","",0);
51        submit = addLocalControlInput(f1,"Say hello",OnHello,1);
52        return form;
53    }
54

AUTHORS

56       Kaya   standard  library  by  Edwin  Brady,  Chris  Morris  and  others
57       (kaya@kayalang.org). For further information see http://kayalang.org/
58

LICENSE

60       The Kaya standard library is free software;  you  can  redistribute  it
61       and/or  modify  it  under  the  terms  of the GNU Lesser General Public
62       License (version 2.1 or any later version) as  published  by  the  Free
63       Software Foundation.
64
66       WebCommon.DataSource (3kaya)
67
68
69
70Kaya                             December 2010          Webapp.autoFill(3kaya)
Impressum