Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > cd38b09e3cb8d6c675b02d30393e68af > files > 53

kaya-doc-0.5.2-8.fc14.noarch.rpm

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();
    }
}