cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philipp Rech" <philipp.r...@gmx.de>
Subject RE: [sorry but not all done yet] RE: pass a variable from flowscript into cfrom text input field
Date Tue, 26 Oct 2004 12:31:58 GMT
hello again!

thanks Bart i will try that too. 
The general problem was posted by me before 
( but nobody answered that mail yet):

------------re post----------------------------------------

okay the scenario is a CForm form that goes over several pages. Wizard or
Registration like. Here I was wondering what people are using out there for
this common task and what are the options and best practise for that?

As far as i know there are 2 major ways to do this: 

1 - on big form def. and a on big template... from fields are hidden and
displayed via JavaScript and CSS (e.g. via <fi:styling type="tabs"/>). The
problem here is that validation occurs "on submit" and that could case many
errors and many "!" will get displayed which the user have to "find" first
(some are hidden via JS)! right?!?!?!? Another problem could be the heavy
use of client-side Javascript and CSS.

2 - split-up form definitions and templates and a submit button pointing to
the next page via the contuniation. The big problem here is that when i go
back and change values and submit again the fields on the 2nd (and so on)
page are empty! right?!?!?!? Also having one form definition and calling the
widgets from several templates doesnt work according to the developers, huh?

MY QUESTION: any other options i didn't think of (with CForms and Cocoon
2.1.5.1)? What are people using out there and what is good and bad about it?

----------------------------------------- end ---------------------


sorry for causing so much traffic today and thanks to all!
phil






> I don't know if I get your question right, but this may help: I'm using
> a similair approach in my project: first show form 1, then check for
> some condition and see if it must show form 2, then show a page with
> results with the option to edit the forms again. I've done it something
> like:
> 
> form1 = new Form("form1.xml");
> form1.createBinding("form1-binding.xml");
> 
> form2 = new Form("form2.xml");
> form2.createBinding("form2-binding.xml");
> 
> var finished = false;
> var data = ...; (your data)
> 
> while (!finished) {
>   form1.showForm("form1.html");
>   form1.save(data);
> 
>   if (data.isBla()) {
>     form2.showForm("form2.html");
>     form2.save(data);
>   }
> 
>   cocoon.sendPageAndWait("result.html", data);
>   finished = cocoon.request.getParameter("finished") == "true";
> }
> 
> So in my case, I don't set any boolean fields on the form to figure out
> if anything has changed.
> 
> But maybe I'm not understanding your question ;)
> 
> Bart.
> 
> > 
> > sorry i was too fast...
> > the solution
> > 
> > var test;
> > 
> > form = new Form("my-form.xml");
> > wid = form.lookupWidget("test");
> > wid.setValue(test);
> > 
> > form.showForm("registration-display-pipeline");
> > var test = cocoon.request.test;
> > 
> > 
> > only works fine with input field widgets but not with booleanfield
> > widgets. There i get an error:
> > 
> > java.lang.RuntimeException: Cannot set value of boolean field "test"
> to a
> > non-Boolean value.
> > 
> > Same as with the text field i use it to figure out if it has been
> > "changed"
> > before and redisplay its old value... all to solve my multi page from
> > problem.... user has enterd a falue in page 2 and submitetd it then
> goes
> > back to page 1 and changes something and submits page one. now i want
> page
> > 2
> > to be displayed again but with the data entered before!
> > 
> > 
> > thanks again!
> > phil
> > 
> > 
> > 
> > 
> > 
> > 
> > > thank you Bart it works now!
> > >
> > > what i like most about Cocoon
> > > is the community of users and
> > > developers! thanks guys!
> > >
> > > regards,
> > > phil
> > >
> > >
> > >
> > >
> > > > No, the code belongs to your flowscript.
> > > >
> > > > var name = "Cocoon";
> > > >
> > > > form = new Form("my-form.xml");
> > > > wid = form.lookupWidget("name");
> > > > wid.setValue(name);
> > > >
> > > > ...
> > > >
> > > > form.showForm("form-pipe");
> > > >
> > > > ...
> > > >
> > > > >
> > > > > Thank you Bart, Gunter and Nacho!
> > > > >
> > > > > still i am not shure how to use this:
> > > > >
> > > > > nameWidget = form.lookupWidget("name");
> > > > > nameWidget.setValue(name);
> > > > >
> > > > > can i put this in my Flowscript? Again i want to pass a variable
> > > > > from a flowscript and set it as default value for the widget.
> > > > > I guess the code above belongs in the cfrom template but how do
> i
> > pass
> > > > the
> > > > > variable "name" to it?
> > > > >
> > > > >
> > > > > > and with v2 of the javascript API, you could write:
> > > > > >
> > > > > > var form = new Form("form1.xml");
> > > > > > var wid = form.getWidget();
> > > > > > wid.name.value = name;
> > > > > >
> > > > > uhh, how can i use version 2 of the javascript API?
> > > > >
> > > >
> > > >
> >
> cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/v2/Form.
> > > > js");
> > > >
> > > > (ie load Form.js from the v2/ directory). But the code above
> should
> > work
> > > > with the regular (version 1) Form.js
> > > >
> > > > >
> > > > > Thanks again,
> > > > > phil
> > > > Bart
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > > For additional commands, e-mail: users-help@cocoon.apache.org
> > > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > For additional commands, e-mail: users-help@cocoon.apache.org
> > >
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


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


Mime
View raw message