Discussion:
Multiple forms on one page
Reinhard Poetz
2004-11-22 10:12:23 UTC
Permalink
Hi,
I need to put two forms onto one page.
Scenario: a homepage showing a selection of 'products', displayed as a
repeater on a form, and a login form.
These need to be separate HTML forms, so that typing into a box and
pressing enter submits the relevant form.
Is there a way to do this without having to go all the way and aggregate
two completely separate pipelines? Having to do the this for just one
page would be a real pain.
Thanks for any ideas.
AFAIK this is an open issue for cForms. Therefore I move it over to dev-list.

I think one problem is our flowscript API:

var form = new Form("...");
form.show("mypipeline", bizdata);

This way you can only show one form a page. Maybe we can do somethink like

var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);

The next step would have to be an enhancement of the forms transformer because
it would have to render more than one form. This would probably require a unique
id in the forms template. This id needs to be the same as the id used in "new
Multiform(...)".

- o -

If you go the aggregation way, there could be problems with the generated HTML
and Javascript because there are some tags set in the header of the HTML page
and the body tag uses onload().

Does anybody have experiences with this (e.g. with the portal)?

--
Reinhard
Bruno Dumon
2004-11-22 10:24:54 UTC
Permalink
Post by Reinhard Poetz
Hi,
I need to put two forms onto one page.
Scenario: a homepage showing a selection of 'products', displayed as a
repeater on a form, and a login form.
These need to be separate HTML forms, so that typing into a box and
pressing enter submits the relevant form.
Is there a way to do this without having to go all the way and aggregate
two completely separate pipelines? Having to do the this for just one
page would be a real pain.
Thanks for any ideas.
AFAIK this is an open issue for cForms. Therefore I move it over to dev-list.
var form = new Form("...");
form.show("mypipeline", bizdata);
This way you can only show one form a page. Maybe we can do somethink like
var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);
The next step would have to be an enhancement of the forms transformer because
it would have to render more than one form. This would probably require a unique
id in the forms template. This id needs to be the same as the id used in "new
Multiform(...)".
The forms transformer can handle this, the ft:form-template element can
have a location attribute containing a jxpath expression that points to
the form object.
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
***@outerthought.org ***@apache.org
Reinhard Poetz
2004-11-22 10:38:10 UTC
Permalink
Post by Bruno Dumon
Post by Reinhard Poetz
var form = new Form("...");
form.show("mypipeline", bizdata);
This way you can only show one form a page. Maybe we can do somethink like
var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);
The next step would have to be an enhancement of the forms transformer because
it would have to render more than one form. This would probably require a unique
id in the forms template. This id needs to be the same as the id used in "new
Multiform(...)".
The forms transformer can handle this, the ft:form-template element can
have a location attribute containing a jxpath expression that points to
the form object.
What's the object this jxpath-expression is used on?
--
Reinhard
Bruno Dumon
2004-11-22 10:47:46 UTC
Permalink
Post by Reinhard Poetz
Post by Bruno Dumon
Post by Reinhard Poetz
var form = new Form("...");
form.show("mypipeline", bizdata);
This way you can only show one form a page. Maybe we can do somethink like
var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);
The next step would have to be an enhancement of the forms transformer because
it would have to render more than one form. This would probably require a unique
id in the forms template. This id needs to be the same as the id used in "new
Multiform(...)".
The forms transformer can handle this, the ft:form-template element can
have a location attribute containing a jxpath expression that points to
the form object.
What's the object this jxpath-expression is used on?
the flow context, and with a few variables declared (request,
session, ...). See FormsPipelineConfig.createConfig where the jxpath
context is created.
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
***@outerthought.org ***@apache.org
oceatoon
2004-11-22 14:32:29 UTC
Permalink
Are there any docs on this?
or use cases ?
We have done a solution where we have one huge form model, and then the
template is devide in multiple tabs ,It all works great but now we're
trying to structure the validation system (freshly speaking)
This MultiForms might be the solution to our problems :)

Best Regards
Tibor
Post by Bruno Dumon
Post by Reinhard Poetz
Post by Bruno Dumon
Post by Reinhard Poetz
var form = new Form("...");
form.show("mypipeline", bizdata);
This way you can only show one form a page. Maybe we can do somethink like
var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);
The next step would have to be an enhancement of the forms transformer
because it would have to render more than one form. This would probably
require a unique id in the forms template. This id needs to be the same
as the id used in "new Multiform(...)".
The forms transformer can handle this, the ft:form-template element can
have a location attribute containing a jxpath expression that points to
the form object.
What's the object this jxpath-expression is used on?
the flow context, and with a few variables declared (request,
session, ...). See FormsPipelineConfig.createConfig where the jxpath
context is created.
Bruno Dumon
2004-11-22 14:57:36 UTC
Permalink
Post by oceatoon
Are there any docs on this?
Over here:
http://cocoon.apache.org/2.1/userdocs/forms/templatetransformer.html
Post by oceatoon
or use cases ?
I wouldn't know, I haven't ever had the need. Upayavira had one.
Post by oceatoon
We have done a solution where we have one huge form model, and then the
template is devide in multiple tabs ,It all works great but now we're
trying to structure the validation system (freshly speaking)
This MultiForms might be the solution to our problems :)
Keep in mind that when there are multiple forms, there's always only one
form which gets submitted, so it's different from having one big form.
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
***@outerthought.org ***@apache.org
oceatoon
2004-11-22 17:43:44 UTC
Permalink
Post by Bruno Dumon
Post by oceatoon
Are there any docs on this?
http://cocoon.apache.org/2.1/userdocs/forms/templatetransformer.html
Thx.
Post by Bruno Dumon
Post by oceatoon
or use cases ?
I wouldn't know, I haven't ever had the need. Upayavira had one.
ok
Post by Bruno Dumon
Post by oceatoon
We have done a solution where we have one huge form model, and then the
template is devide in multiple tabs ,It all works great but now we're
trying to structure the validation system (freshly speaking)
This MultiForms might be the solution to our problems :)
Keep in mind that when there are multiple forms, there's always only one
form which gets submitted, so it's different from having one big form.
yes this is clear to me, but I'm still not sure which case would be more
efficient a Mono Huge Form (that I have now) or a Multiple Form in the aim
of having them all simultaneously in the same xhtml page in a tab
structure ??

Thanks for all inner and outer-thoughts ;)
Regards
Tibor
Glen Ezkovich
2004-11-22 23:06:44 UTC
Permalink
It seems to me that what we want are multiple forms on a page and what
is being proposed is a way to have one big form that gets processed in
pieces. To me the stumbling block seems to be in Forms.js. When we
display a form using showForm the only form it knows about is its self.
In order to process multiple Forms something needs to know about
multiple Forms. In order not to break encapsulation, it is essential
that each form have its own separate definition. I may be missing
something here, but it seems to me that if you want to show multiple
forms on a page you need to move the showForm method to a place where
multiple forms can be collected, examined, validated, bound and
processed. Say, right along side sendPageAndWait.

I have more to say on this and I have another e-mail in process that
will take a bit more thought before its complete. I just wanted to
throw this out there and any comments are more than welcome.


Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com



A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Sylvain Wallez
2004-11-22 15:19:09 UTC
Permalink
Post by oceatoon
Are there any docs on this?
or use cases ?
We have done a solution where we have one huge form model, and then the
template is devide in multiple tabs ,It all works great but now we're
trying to structure the validation system (freshly speaking)
This MultiForms might be the solution to our problems :)
Isn't what you need something similar to the new multi-page form demo
using widget states?

Sylvain
--
Sylvain Wallez Anyware Technologies
http://www.apache.org/~sylvain http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
oceatoon
2004-11-22 17:37:49 UTC
Permalink
Post by Sylvain Wallez
Post by oceatoon
Are there any docs on this?
or use cases ?
We have done a solution where we have one huge form model, and then the
template is devide in multiple tabs ,It all works great but now we're
trying to structure the validation system (freshly speaking)
This MultiForms might be the solution to our problems :)
Isn't what you need something similar to the new multi-page form demo
using widget states?
Sylvain
Indeed, I did check out the Multiple form example but that is simply a Flow
use case to go from one form to another, but I found interesting the
possibility of creating multiple forms in one declaration, with each form
having its own ft:form-template hence it's own validation and maybe even
out of one model or would the validation problem persist in this case?

I am kinda looking for the right direction here as I freshly started today
sorting out how I was going to do (show)validation in my Big Huge 136
widget element form ;). All validation being perfectly done by Cforms, I
was wondering if anybody was working or planning a client side JS
validation generated from the CForm model?

Thanks for the thoughts
Regards
Tibor
By the way, thanks for the macro-jx module, it helps us a lot and opened new
ideas :)
Glen Ezkovich
2004-11-23 21:52:34 UTC
Permalink
Some how I missed this yesterday when I sent my post and consequently
sent garbage. I apologize for the noise.
Post by Reinhard Poetz
Hi,
I need to put two forms onto one page.
Scenario: a homepage showing a selection of 'products', displayed as
a repeater on a form, and a login form.
These need to be separate HTML forms, so that typing into a box and
pressing enter submits the relevant form.
Is there a way to do this without having to go all the way and
aggregate two completely separate pipelines? Having to do the this
for just one page would be a real pain.
Thanks for any ideas.
AFAIK this is an open issue for cForms. Therefore I move it over to dev-list.
This is exactly what I was thinking.
Post by Reinhard Poetz
var form = new Form("...");
form.show("mypipeline", bizdata);
This way you can only show one form a page. Maybe we can do somethink like
var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);
I think where we see thing differently is that I would rather have the
forms as just part of a page, i.e.
cocoon.sendFormPage("formTemplate.xml", {"bizdata": bizdata},
{"formURI1", "formURI2", ..., "formURIn"})

Actually, I would like it better if the forms can just be referenced in
the template and sendFormPage returns an array of Forms. I'm not sure
what type of performance hit this might cause.
Post by Reinhard Poetz
The next step would have to be an enhancement of the forms transformer
because it would have to render more than one form. This would
probably require a unique id in the forms template. This id needs to
be the same as the id used in "new Multiform(...)".
One of the ideas I've been tossing about is the notion of named forms.
Now when I say named forms I don't necessarily mean an arbitrary name,
since it seems obvious that names should be unique. It could simply be
the URI of the form; forms/myForm.xml. This, I think would work for
your unique ID as well.

In a recent proof of concept project not only did we needed multiple
forms per page but we discovered that we had many forms that shared
groups of information such as address information. It would have been
nice to be able to create the form definition and the form template
just once and just include it in other forms that needed to display or
collect that information. (I know it is possible but not
straightforward)

As an example of what I have in mind is something along the lines of
the following:

In wholeForm.xml:

<fd:form>
<fd:widgets>
<fd:include name="name" submit="false"/>
<fd:include name="address" submit="true"/>
<fd:include name="someOtherStuff" submit="action"
action-command="doThis" on-action="whatever"/>
<fd:submit id="alldone" action-command="..." validate="true">
<fd:label>Submit</fd:label>
<fd:help>...</fd:help>
<fd:hint>...</fd:hint>
<fd:on-action>
...
</fd:on-action>
</fd:widgets>
</fd:form>

And in wholeFormTemplate.xml

<ft:form-template action="#{$continuation/id}.continue" method="POST">
<ft:include name="name"/>
<ft:include name="address"/>
<ft:include name="someOtherStuff"/>
<ft:widget id="alldone"/>
</ft:form-template>

My thinking at the time was that named forms would solve both multiple
forms per page and shared form elements. I now see the two issues are
independent but named forms would make the use of multi-form pages
easier by simply allowing passing the form names to the showFormPage
function.

As I mentioned above, form names could be just their URI, but they
could also be specified in the sitemap allowing for simple form
replacement. While I realize this is a huge undertaking since it
touches many pieces, it does not have to break backwards compatibility.

If the project proceeds I will scratch this itch. If it doesn't I may
have a lot of time on my hands ;-0 and a lot of nervous scratching
might take place anyway.

Again, any thoughts on this would be greatly appreciated.

Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com



A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Reinhard Poetz
2004-11-24 08:31:40 UTC
Permalink
Post by Glen Ezkovich
Some how I missed this yesterday when I sent my post and consequently
sent garbage. I apologize for the noise.
Post by Reinhard Poetz
Hi,
I need to put two forms onto one page.
Scenario: a homepage showing a selection of 'products', displayed as
a repeater on a form, and a login form.
These need to be separate HTML forms, so that typing into a box and
pressing enter submits the relevant form.
Is there a way to do this without having to go all the way and
aggregate two completely separate pipelines? Having to do the this
for just one page would be a real pain.
Thanks for any ideas.
AFAIK this is an open issue for cForms. Therefore I move it over to dev-list.
This is exactly what I was thinking.
Post by Reinhard Poetz
var form = new Form("...");
form.show("mypipeline", bizdata);
This way you can only show one form a page. Maybe we can do somethink like
var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);
I think where we see thing differently is that I would rather have the
forms as just part of a page, i.e.
cocoon.sendFormPage("formTemplate.xml", {"bizdata": bizdata},
{"formURI1", "formURI2", ..., "formURIn"})
This wouldn't work because this way you would have to care of validation and
"continuation management" in every controller using forms.
Post by Glen Ezkovich
Actually, I would like it better if the forms can just be referenced in
the template and sendFormPage returns an array of Forms. I'm not sure
what type of performance hit this might cause.
Post by Reinhard Poetz
The next step would have to be an enhancement of the forms transformer
because it would have to render more than one form. This would
probably require a unique id in the forms template. This id needs to
be the same as the id used in "new Multiform(...)".
One of the ideas I've been tossing about is the notion of named forms.
Now when I say named forms I don't necessarily mean an arbitrary name,
since it seems obvious that names should be unique. It could simply be
the URI of the form; forms/myForm.xml. This, I think would work for your
unique ID as well.
In a recent proof of concept project not only did we needed multiple
forms per page but we discovered that we had many forms that shared
groups of information such as address information. It would have been
nice to be able to create the form definition and the form template just
once and just include it in other forms that needed to display or
collect that information. (I know it is possible but not straightforward)
As an example of what I have in mind is something along the lines of the
<fd:form>
<fd:widgets>
<fd:include name="name" submit="false"/>
<fd:include name="address" submit="true"/>
<fd:include name="someOtherStuff" submit="action"
action-command="doThis" on-action="whatever"/>
<fd:submit id="alldone" action-command="..." validate="true">
<fd:label>Submit</fd:label>
<fd:help>...</fd:help>
<fd:hint>...</fd:hint>
<fd:on-action>
...
</fd:on-action>
</fd:widgets>
</fd:form>
And in wholeFormTemplate.xml
<ft:form-template action="#{$continuation/id}.continue" method="POST">
<ft:include name="name"/>
<ft:include name="address"/>
<ft:include name="someOtherStuff"/>
<ft:widget id="alldone"/>
</ft:form-template>
My thinking at the time was that named forms would solve both multiple
forms per page and shared form elements. I now see the two issues are
independent but named forms would make the use of multi-form pages
easier by simply allowing passing the form names to the showFormPage
function.
I don't understand the include syntax. what does it include?
Post by Glen Ezkovich
As I mentioned above, form names could be just their URI, but they could
also be specified in the sitemap allowing for simple form replacement.
While I realize this is a huge undertaking since it touches many pieces,
it does not have to break backwards compatibility.
If the project proceeds I will scratch this itch. If it doesn't I may
have a lot of time on my hands ;-0 and a lot of nervous scratching might
take place anyway.
Again, any thoughts on this would be greatly appreciated.
--
Reinhard
Glen Ezkovich
2004-11-24 19:33:06 UTC
Permalink
On Nov 24, 2004, at 2:31 AM, Reinhard Poetz wrote:
<snip/>
Post by Reinhard Poetz
Post by Glen Ezkovich
This is exactly what I was thinking.
Post by Reinhard Poetz
var form = new Form("...");
form.show("mypipeline", bizdata);
This way you can only show one form a page. Maybe we can do
somethink like
var multiform = new Multiform({form1 : form1, form2 : form2);
multiform.show("myMultiformPipeline", bizdata);
I think where we see thing differently is that I would rather have
the forms as just part of a page, i.e.
cocoon.sendFormPage("formTemplate.xml", {"bizdata": bizdata},
{"formURI1", "formURI2", ..., "formURIn"})
This wouldn't work because this way you would have to care of
validation and "continuation management" in every controller using
forms.
I'm not sure I expressed this well. What I meant was that I would
rather not create 3 forms and a multiform in the controller. I would
rather invoke a method on cocoon passing the necessary parameters. I'm
sure that a Multiform would be necessary and I suspect that a Multiform
might need to be returned by an invocation of showFormPage. My original
thinking was just an array of forms would be returned, but I think
there is more the controller will need to know upon resumption then
just which forms exist, such as which form was submitted and the
continuation ID. The less that has to be done in the controller the
better.

One of the problems with multiple forms per page is the possibility of
a form switching controllers. This is a problem with which any
implementation will have to deal. I'm not sure how to approach it. My
inclination at the moment is to ignore it and say just don't do it. It
is evil.
Post by Reinhard Poetz
Post by Glen Ezkovich
Actually, I would like it better if the forms can just be referenced
in the template and sendFormPage returns an array of Forms. I'm not
sure what type of performance hit this might cause.
I still think this would be great, but lets return a Multiform instead
of an array of Forms. The way I look at it, the less the controller
needs to know about the view and the model the better.

<snip/>
Post by Reinhard Poetz
Post by Glen Ezkovich
In a recent proof of concept project not only did we needed multiple
forms per page but we discovered that we had many forms that shared
groups of information such as address information. It would have been
nice to be able to create the form definition and the form template
just once and just include it in other forms that needed to display
or collect that information. (I know it is possible but not
straightforward)
As an example of what I have in mind is something along the lines of
<fd:form>
<fd:widgets>
<fd:include name="name" submit="false"/>
<fd:include name="address" submit="true"/>
<fd:include name="someOtherStuff" submit="action"
action-command="doThis" on-action="whatever"/>
<fd:submit id="alldone" action-command="..."
validate="true">
<fd:label>Submit</fd:label>
<fd:help>...</fd:help>
<fd:hint>...</fd:hint>
<fd:on-action>
...
</fd:on-action>
</fd:widgets>
</fd:form>
And in wholeFormTemplate.xml
<ft:form-template action="#{$continuation/id}.continue"
method="POST">
<ft:include name="name"/>
<ft:include name="address"/>
<ft:include name="someOtherStuff"/>
<ft:widget id="alldone"/>
</ft:form-template>
My thinking at the time was that named forms would solve both
multiple forms per page and shared form elements. I now see the two
issues are independent but named forms would make the use of
multi-form pages easier by simply allowing passing the form names to
the showFormPage function.
I don't understand the include syntax. what does it include?
In include in the form definition would include another form definition
defined by the name. I like the idea of being able to name forms so the
above example used simple names. Below, I use a file name.

Given the following two two form definitions

Form A defined in whole.xml:
<fd:form>
<fd:widgets>
<fd:include name="name.xml" submit="false"/>
<fd:submit id="..." action-command="..." validate="true|false">
<fd:label>Submit Whole Form</fd:label>
<fd:on-action>
...
</fd:on-action>
</fd:submit>
</fd:widgets>
</fd:form>

FormB defined in name.xml:
<fd:form>
<fd:widgets>
<fd:field id="name" required="true">
<fd:label>Name:</fd:label>
<fd:datatype base="string"/>
<fd:validation>
<fd:length min="2"/>
</fd:validation>
</fd:field>
<fd:submit id="..." action-command="..." validate="true|false">
<fd:label>Submit Name</fd:label>
<fd:on-action>
...
</fd:on-action>
</fd:submit>
</fd:widgets>
</fd:form>

FormA would be equivalent to:

<fd:form>
<fd:widgets>
<fd:field id="name" required="true">
<fd:label>Name:</fd:label>
<fd:datatype base="string"/>
<fd:validation>
<fd:length min="2"/>
</fd:validation>
</fd:field>
<fd:submit id="name" action-command="changeName" validate="true">
<fd:label>Submit Whole Form</fd:label>
<fd:on-action>
...
</fd:on-action>
</fd:submit>
</fd:widgets>
</fd:form>

Where all of FormB, except for the submit widget, is inserted in place
of the include element. The exact same thing would happen with form
templates.


Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com



A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow

Continue reading on narkive:
Loading...