File: helloperson.k

package info (click to toggle)
kaya 0.4.4-6.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,200 kB
  • ctags: 2,015
  • sloc: cpp: 9,556; haskell: 7,253; sh: 3,060; yacc: 910; makefile: 816; perl: 90
file content (28 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
webapp helloperson;

import Webapp;
import HTMLDocument;

HTMLDocument webmain() {
  doc = new(HTML4Strict,"Hello World");
  appendExisting(doc.body,runHandler(@helloForm));
  return doc;
}

ElementTree helloForm() {
  form = addLocalForm(anonymousBlock);
  f1 = addFieldset(form,"Who are you?");
  input = addLabelledInput(f1,"Your Name",InputText,"name","",0);
  submit = addLocalControlInput(f1,"Say hello",OnHello,"Hello");
  return form;
}

ElementTree OnHello(String message) {
    if (incomingExists("name",DataPost)) {
        return addParagraph(anonymousBlock,message+" "+
                            incomingValue("name",DataPost));
    } else {
// it should be there, but isn't. Let's try displaying the form again
        return helloForm();
    }
}