You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Duncan McLean <du...@blueyonder.co.uk> on 2006/01/22 16:45:18 UTC

(Hopefully!) simple question about recalling data in field in cocoon form

Hi

I've been playing with one of the cforms samples (registration) that 
comes with Cocoon and have noticed that if you type in data and submit, 
and return to that page and reload, that values in the text boxes disappear.

I thought these get preserved, or is there some programmatic effort in 
retrieving them?

Following a similar (2-step) example, carselector, which uses selection 
lists, I notice that if you submit and then return to the page, the 
values are preserved even after a reload. I notice that in the template 
there are "submit-on-change" tags for each of the drop-downs.

Can someone explain to this layman, the differences and how I can 
recall/reload already submitted data that don't have this 
submit-on-change instruction.

Thanks in advance

Duncan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: (Hopefully!) simple question about recalling data in field in cocoon form

Posted by Duncan McLean <du...@blueyonder.co.uk>.
Jason Johnston wrote:

> Duncan McLean wrote:
>
>> 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!
>>
>
>
> I'm flying a bit blind here without trying this out, but here's what 
> I'm guessing is happening.  When you hit the back button, you're 
> actually going back to the continuation that is created as part of the 
> first form.showForm() loop.  The script then continues from that 
> point, exits the showForm() method, creates the registration form anew 
> with blank values and displays it.
>
> If you had created the registration Form before the first 
> form.showForm() I believe you would get the behavior you expect 
> because then that object would be reused rather than recreated.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
Hit the nail right on the head there! Thanks again - promise that's all!

Duncan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: (Hopefully!) simple question about recalling data in field in cocoon form

Posted by Jason Johnston <co...@lojjic.net>.
Duncan McLean wrote:
> 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!
> 


I'm flying a bit blind here without trying this out, but here's what I'm 
guessing is happening.  When you hit the back button, you're actually 
going back to the continuation that is created as part of the first 
form.showForm() loop.  The script then continues from that point, exits 
the showForm() method, creates the registration form anew with blank 
values and displays it.

If you had created the registration Form before the first 
form.showForm() I believe you would get the behavior you expect because 
then that object would be reused rather than recreated.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: (Hopefully!) simple question about recalling data in field in cocoon form

Posted by Duncan McLean <du...@blueyonder.co.uk>.
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: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>>
> Jason - brilliant thanks - that gives me a great start...!
>
> Duncan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: (Hopefully!) simple question about recalling data in field in cocoon form

Posted by Duncan McLean <du...@blueyonder.co.uk>.
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: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
Jason - brilliant thanks - that gives me a great start...!

Duncan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: (Hopefully!) simple question about recalling data in field in cocoon form

Posted by Jason Johnston <co...@lojjic.net>.
> 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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: (Hopefully!) simple question about recalling data in field in cocoon form

Posted by Duncan McLean <du...@blueyonder.co.uk>.
Jason Johnston wrote:

> Duncan McLean wrote:
>
>> Hi
>>
>> I've been playing with one of the cforms samples (registration) that 
>> comes with Cocoon and have noticed that if you type in data and 
>> submit, and return to that page and reload, that values in the text 
>> boxes disappear.
>>
>> I thought these get preserved, or is there some programmatic effort 
>> in retrieving them?
>>
>> Following a similar (2-step) example, carselector, which uses 
>> selection lists, I notice that if you submit and then return to the 
>> page, the values are preserved even after a reload. I notice that in 
>> the template there are "submit-on-change" tags for each of the 
>> drop-downs.
>>
>> Can someone explain to this layman, the differences and how I can 
>> recall/reload already submitted data that don't have this 
>> submit-on-change instruction.
>
>
> I believe the difference is that the values are only preserved when 
> you are going back to a continuation.  In the first sample it sounds 
> like you are going back to the form's initial URL (not a continuation) 
> whereas in the second example you're going back to the page that's a 
> result of a continuation (triggered by the submit-on-change).
>
> Here's the general rule:  If you go back to the first page request in 
> a form's flow, the fields will all be blank, because the initial URL 
> starts a new flow and creates a new (blank) Form object.  If you go 
> back to a continuation, then the fields will display the values that 
> were last submitted by the user, because those are the values carried 
> in the Form object shared by all those continuations.  That last part 
> is an important detail: the flow does not keep track of the form state 
> for each and every continuation, only the current state of the form as 
> a whole.
>
> Hope that helps
> --Jason
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
Hi Jason

Thanks for the prompt reply! If you'll indulge me for a bit longer, can 
I take this a bit further?

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?

Thanks again

Duncan





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: (Hopefully!) simple question about recalling data in field in cocoon form

Posted by Jason Johnston <co...@lojjic.net>.
Duncan McLean wrote:
> Hi
> 
> I've been playing with one of the cforms samples (registration) that 
> comes with Cocoon and have noticed that if you type in data and submit, 
> and return to that page and reload, that values in the text boxes 
> disappear.
> 
> I thought these get preserved, or is there some programmatic effort in 
> retrieving them?
> 
> Following a similar (2-step) example, carselector, which uses selection 
> lists, I notice that if you submit and then return to the page, the 
> values are preserved even after a reload. I notice that in the template 
> there are "submit-on-change" tags for each of the drop-downs.
> 
> Can someone explain to this layman, the differences and how I can 
> recall/reload already submitted data that don't have this 
> submit-on-change instruction.

I believe the difference is that the values are only preserved when you 
are going back to a continuation.  In the first sample it sounds like 
you are going back to the form's initial URL (not a continuation) 
whereas in the second example you're going back to the page that's a 
result of a continuation (triggered by the submit-on-change).

Here's the general rule:  If you go back to the first page request in a 
form's flow, the fields will all be blank, because the initial URL 
starts a new flow and creates a new (blank) Form object.  If you go back 
to a continuation, then the fields will display the values that were 
last submitted by the user, because those are the values carried in the 
Form object shared by all those continuations.  That last part is an 
important detail: the flow does not keep track of the form state for 
each and every continuation, only the current state of the form as a whole.

Hope that helps
--Jason



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org