cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bart Molenkamp" <b.molenk...@bizzdesign.nl>
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:45:20 GMT
Philipp,

If you want to use one big form, or multiple forms depends on what your
target users (the ones you are developing for) want (I think). If you
want to use two or more forms, no problem. Remember that a form instance
doesn't lose it's values. E.g.

form1 = new Form("test.xml");
while (true) {
  form1.showForm("test.html");
  // do some data processing
}

When the form is shown for the second time, it still has the values when
it was submitted for the first time.

Another advise: use the binding framework. Might take a little time in
understanding how it works, but once you see how it works, you'll see
the benefits of it. You can bind the form data to XML documents or
JavaBeans with one command:

form.showForm("test.html");	// user fills in the form
form.save(user);			// bind the form values to the
user
cocoon.sendPageAndWait("result.html", {user: user});  // show results.

In my previous message to you, I show you how I did it. I have two
forms, two bindings, and one JavaBean on which both forms are mapped.
The second form is only shown when some widget on form1 is set to true
(is selected). After saving the form to the bean, I check on the bean if
that specific value is true. If so, I show form2, and after that save
form2 to the bean. Then the user decides if he wants to save the
results. My result page has two links:

<a href="#{$continuation/id}.continue?save=true">Save!</a>
<a href="#{$continuation/id}.continue">Edit again</a>

At the end of the while-loop, I check if I can find the request
parameter "save" and if it's value is "true". Something like:
finished = cocoon.request.getParameter("save") == "true";

When finished == true, my loop ends and I can save the data (e.g. in a
database).

I hope that this scenario helps a bit. I don't know if this is the best
way to do this, but there isn't much programming required, and the core
is very readible, and it works fine for me!

Bart.
> 
> 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


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


Mime
View raw message