Sophie

Sophie

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

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

webapp autofill;

import Webapp;
import HTMLDocument;

HTMLDocument webmain()
{
    doc = new(HTML4Strict,"Hello program");
    h1 = addHeading(doc.body,1,"Hello Program");
    
    result = runHandler(@helloForm);
    appendExisting(doc.body,result);

    return doc;
}

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

ElementTree OnHello(String message)
{
    div = anonymousBlock; // we create this temporarily.
    fname = incomingValue("fname",DataPost);
    lname = incomingValue("lname",DataPost);
    if (fname != "" && lname != "") {
	p = addParagraph(div,message+" "+fname+" "+lname);
	return p;
    } else {
	form = helloForm();
	autoFill(form,DataPost);
	void(addParagraph(form,"You must enter a first name and last name!"));
	return form;
    } 
}