Duncan McLean wrote:

Jason Johnston wrote:

Imagine I have a set of form pages that are logically linked (i.e. Page A -> Page B -> Page C etc which continue to some kind of final processing), is it possible to present a breadcrumb trail for the user, i.e. if they have completed Page A, B, C,etc, can we include some kind of mechanism that will take them back to any of the pages they have previously filled in and be presented with their data? Will I have to bookmark each continuation at each page so I can return to that particular point, or is there something far simpler involved?


There are a few different ways to approach the multi-page form problem. One of them is to use a single Form object with multiple widget groups and use widget states to show one group at a time, which is demonstrated in the multipage form sample: http://cocoon.zones.apache.org/demos/release/samples/blocks/forms/do-multipage.flow

If for some reason your application requires a separate Form object for each page, you can still accomplish the same effect, it just takes some more creative use of flowscript to keep all the Form objects around and switch between them. Off the top of my head something like the following should give you a start:

function multipage_flow() {
   var forms = [
      new Form("form1.xml"),
      new Form("form2.xml"),
      new Form("form3.xml")
   ];
   var currentFormIndex = 0;

   var finished = false;
   while(!finished) {
      var form = forms[currentFormIndex];
      form.showForm(...);
      switch(String(form.submitId)) {
         case "gotoNextForm":
            currentFormIndex++; break;
         case "gotoPreviousForm":
            currentFormIndex--; break;
         case "finishForm":
            finished = true; break;
      }
   }

   // all forms are completed, now handle the result...
}







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Jason - brilliant thanks - that gives me a great start...!

Duncan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Hi Jason

Tried to slightly refactor the registration example, and am still getting empty fields -

I added an extra start form that all it did was submit, the flow then moved on the registration page and finally the results.

Going back from the results page to the registration and a reload of the page and the data disappears as I had seen before - any ideas - apologies yet again if this is a bit trivial, but its helping my understanding! Thanks

Flow:

function registration() {
 //this just displays a simple submit form
   var form = new Form("forms/reg.xml");
   form.showForm("reg-display-pipeline");

   var form = new Form("forms/registration.xml");

   // The showForm function will keep redisplaying the form until
   // everything is valid
   form.showForm("registration-display-pipeline");

//going back from here to the previous page and a reload results in data being cleared...
   var model = form.getModel();
   var bizdata = { "username" : model.name }
   cocoon.sendPage("registration-success-pipeline.jx", bizdata);
}

(I tried creating a different form object for each page, but it didn't work). I think there's something fundamental that I'm not getting here!

Cheers again

Duncan





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]