The Cocoon project has introduced FlowScript. Flowscript is a
modified
version of javascript which supports continuations and is used to write web applications that span pages.
Here is an example from the site of a calculator application which uses multiple pages to request the numbers and
operator.
"In this example, the calculator function is called to start the calculator application. We'd like the sendPageAndWait function to be a special function, that takes as arguments an HTML file to be sent as response, and some optional data that needs to be placed dynamically in it. We would like sendPageAndWait to send the response page and then block the executing thread, until the user clicks on a link in the response page, which sends a request back to the server. This request resumes the processing at the point it was left, right after the call to sendPageAndWait."
function calculator()
{
var a, b, operator;
cocoon.sendPageAndWait("getA.html");
a = cocoon.request.get("a");
cocoon.sendPageAndWait("getB.html");
b = cocoon.request.get("b");
cocoon.sendPageAndWait("getOperator.html");
operator = cocoon.request.get("op");
try {
if (operator == "plus")
cocoon.sendPage("result.html", {result: a + b});
else if (operator == "minus")
cocoon.sendPage("result.html", {result: a - b});
else if (operator == "multiply")
cocoon.sendPage("result.html", {result: a * b});
else if (operator == "divide")
cocoon.sendPage("result.html", {result: a / b});
else
cocoon.sendPage("invalidOperator.html", {operator: operator});
}
catch (exception) {
cocoon.sendPage("error.html", {message: "Operation failed: " + exception.toString()});
}
}
Recent comments
16 weeks 4 days ago
16 weeks 4 days ago
16 weeks 4 days ago
38 weeks 5 days ago
43 weeks 13 hours ago
44 weeks 4 days ago
44 weeks 4 days ago
47 weeks 2 days ago
51 weeks 6 days ago
52 weeks 1 hour ago