Marc, himself, his blogs, and you reading them.

May 27, 2004
FlowScript Fun

Just stumbled (while reading up on the results of some student's end term thesis work) across a nice sample showing how Cocoon's flowscript coding naturally helps you with the classic 'stateless'-threshold of the web-app-coding paradigm.

See this silly function:

function askYesNo(msg) {
  var form = new Form("cforms/common/ask-yesno-def.xml");
  var info = form.lookupWidget('/info');
  info.setValue(msg);
  
  form.showForm("screen/ask-yesno-form");
  if (form.submitId=="submitYes") return true;
  else return false;
}

It's (obvious) goal is to just ask the end user for a confirmation on his action (using a cforms dialog-form). The power of flowscript however makes that adding this into your web application flow does not require more redesign then this:

Snippet Before:

...
} else if (form.submitId=="remove") {
    itemService.remove(item);
    info.setValue("Item removed.");
    form.showForm("screen/info-form");
}
...

Snippet After:

...
} else if (form.submitId=="remove") {
  if (askYesNo("Removal cannot be reverted! Are you sure?")) {
    itemService.remove(item);
    info.setValue("Item removed.");
    form.showForm("screen/info-form");
  }
  else info.setValue("Item Not Removed");
}
...

Scary? Or just scaringly easy?

# Posted by mpo at 05:32 PM | TrackBack
Comments

Scaringly cool!

Posted by: Bertrand Delacrétaz at May 28, 2004 10:54 AM
Post a comment









Remember personal info?





Please enter the security code you see here