How to solve common web application problems using Cocoon

In this article I will explain how to solve certain problems and implement various things commonly seen in web application development.

Eventually these may turn into full-fledged HOWTOs or Tutorials. -- TonyCollen


Problem: You wish to display a "please wait" page while a long-running process or query takes place.

Solution: Use the Flowscript to periodically check to see if a process has finished.

Example:

function main() {
  var done = false;
  while (!done) {
      cocoon.sendPageAndWait("wait", {});
      done = EnterpriseSystem.checkQuery();
  }
  cocoon.sendPage("done", {});
}

Discussion: Using the Flowscript, keep sending the user to a page which will automatically redirect back into continuation. Here, EnterpriseSystem.checkQuery() is not actually defined, but you would write your own logic (probably in a Java class) to see if the user's query has finished. Implementation details are left as an exercise for the reader.


Problem: You wish to verify that someone exists by sending them a unique URL over email.

Solution: After the initial registration page, send them a URL containing their Continuation ID to the email address that they specified.

Example: (TODO)

SolvingProblemsWithCocoon (last edited 2009-09-20 23:39:51 by localhost)