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 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
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);;
}
|