[jifty-devel] Web wizards

Gaal Yahas gaal at forum2.org
Sun Oct 15 04:43:31 EDT 2006

On Mon, Oct 09, 2006 at 03:43:32PM +0200, Gaal Yahas wrote:
> A common pattern in web applications is emulating a native UI wizard.
> Typically, this means populating one model over a series of web pages,
> with "Next" and "Previous" navigation options, validation happening
> before leaving each page, and some action on the assembled data taking
> place only on the final page.
> How would you go about implementing such an application in Jifty?

Here's my interim plan for something not fancy, not very clever, but
that should work for basic stuff. There's some handwaving, please tell
me if you spot any pitfalls.

My model has a class for each wizard page. Each such model class refers
to the web session. These model classes don't mean much each on their
own, but the last action queries over them and constructs a meaningful

Templates contain Create actions, and have Next and Prev buttons that
run these actions but set different next page targets (I can't use
J::W::Form::next_page for this. Should I use J::W::Form::Link ?)

This also means I have several actual URLs the client sees. How do I
prevent access to pages out-of-order?

I know this is exactly what continuations are for and I should have been
using them, but they didn't workforme, so: in entering a Previous page,
how do I start up the view with existing data? I wish I didn't need to
use Create actions at first, just Updates (since the session id is a
unique key). Maybe that's precisely what I should do, and magically call
a create on each page before it is rendered, if its wizard model hasn't
been created yet?

The other issue is cleanup: I have to manually clear the model of stale
data from old sessions or from previous wizard runs in this session. Is
there a JDBI invocation that does that painlessly for me? "delete
records from tables qw/foo bar baz/ that refer to session quux".

Gaal Yahas <gaal at forum2.org>

More information about the jifty-devel mailing list