Sophie

Sophie

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

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

webapp webprog;

import Webapp;
import HTMLDocument;

HTMLDocument webmain() {

  doc = new(HTML4Strict,"Test webapp");
  
  h1 = addHeading(doc.body,1,"Test webapp");
  p = addParagraph(doc.body,"This webapp provides a simple proof of concept of the local form mechanism");

  try {
    text = runHandler(@noFunction);
    para = addParagraph(doc.body,"The result is ");
    strong = appendInlineElement(para,StrongEmphasis,text);
  } catch(e) {
    // we do this if there's no recognised function call
    form = addLocalForm(doc.body);
    fs1 = addFieldset(form,"Colour values");
    ct1 = addLabelledInput(fs1,"Red value",InputText,"redval","",10);
    ct2 = addLabelledInput(fs1,"Blue value",InputText,"blueval","",10);
    fs2 = addFieldset(form,"Choose a colour");
    ct3 = addLocalControlInput(fs2,"Make it red",@red_button,"crimson");
    ct4 = addLocalControlInput(fs2,"Make it blue",@blue_button,"azure");
  }
  return doc;
}

Exception NoFunction;

String noFunction() {
	throw(NoFunction);
}

String blue_button(String shade) {
  return "Blue: "+shade+": "+incomingValue("blueval",DataPost);
}

String red_button(String shade) {
  return "Red: "+shade+": "+incomingValue("redval",DataPost);;
}