cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Ezkovich <g...@hard-bop.com>
Subject Re: Multiple forms on one page
Date Wed, 24 Nov 2004 19:33:06 GMT

On Nov 24, 2004, at 2:31 AM, Reinhard Poetz wrote:
<snip/>
>>>
>>> I think one problem is our flowscript API:
>> This is exactly what I was thinking.
>>>
>>>  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.

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


Mime
View raw message