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/02/01 12:32:52 UTC

Re: 'Losing data' when hiding/showing group in form

> Hi
>
> Hope someone can help.
>
> I have a relatively simple form, which amongst other things will
> hide/show a group of fields depending on the state of a radio button.
>
> There are two groups "Life1" and "Life2".
>
> - Life1 is always shown
> - Life2 is only shown when the radio button is set to "Joint" (and has an
> initial state of "invisible".
>
> The hiding/showing mechanism works fine, however, when I submit the form
> after selecting Joint and entering data, and later revisit that form, the
> data in the Life2 group is not preserved. Life1 group is unaffected.
>
> Anybody know why this is occurring?
>
> Relevant parts of form:
>
> Radio button def:
>
>     <fd:field id="kwdSingleJoint">
> 		<fd:label>Is this policy a Single Life or Joint Life policy?</fd:label>
> 		<fd:datatype base="string"/>
>         <fd:initial-value>Single</fd:initial-value>
> 		<fd:selection-list>
> 			<fd:item value="Single"/>
> 			<fd:item value="Joint"/>
> 		</fd:selection-list>
> 		<fd:on-value-changed>
> 			<javascript>
> 			  var value = event.source.value;
> 			  var life2widget = event.source.lookupWidget("../life2");
> 			  if (value == "Joint")
> 			  {
> 				life2widget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
> 			  }
> 			  else
> 			  {
> 				life2widget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
> 			  }
> 			</javascript>
> 		</fd:on-value-changed>
> 	</fd:field>
>
>
> and part of Life2 def:
>
> 	<fd:group id="life2" state="invisible">
> 	  <fd:widgets>
> 		<fd:field id="title2">
> 		  <fd:label>Title</fd:label>
> 		  <fd:datatype base="string" />
> 		  <fd:selection-list>
> 			   <fd:item value="Mr"/>
> 			   <fd:item value="Mrs"/>
> 			   <fd:item value="Miss"/>
> 			   <fd:item value="Ms"/>
> 			   <fd:item value="Dr"/>
> 			   <fd:item value="Fr"/>
> 			   <fd:item value="Br"/>
> 			   <fd:item value="Sr"/>
> 			   <fd:item value="Rev"/>
> 		  </fd:selection-list>
> 		</fd:field>
>
> 		<fd:field id="firstName2">
> 			<fd:label>First Name</fd:label>
> 			<fd:datatype base="string" />
> 		</fd:field>
>
>                 etc...
>
>          <fd:group>
>
> Thanks in advance
>
> Duncan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>

Digging a bit deeper, I find that upon first submit of the form (and only
choosing Life1 as clicking the radio button causes a submit action) then
going back in the browser, the data is retained.

If I even update any other field on the page then do another submit, this
data is not retained - why is it then that only the initial submit data is
"saved"?

Should also put the simplified "stripped down" flow in as well:
~
~
    var form = new Form("forms/start_def.xml");
    var form2 = new Form("forms/clientdetails_def.xml");
    var form3 = new Form("forms/policydetails_sib_def.xml");

    form.showForm("start-display-pipeline");

    //causing me problems at the moment
    form2.showForm("clientdetails-display-pipeline");


    form3.showForm("policydetails_sib-display-pipeline");
~
~

Thanks


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


Re: 'Losing data' when hiding/showing group in form

Posted by Duncan McLean <du...@blueyonder.co.uk>.
>> Hi
>>
>> Hope someone can help.
>>
>> I have a relatively simple form, which amongst other things will
>> hide/show a group of fields depending on the state of a radio button.
>>
>> There are two groups "Life1" and "Life2".
>>
>> - Life1 is always shown
>> - Life2 is only shown when the radio button is set to "Joint" (and has
>> an
>> initial state of "invisible".
>>
>> The hiding/showing mechanism works fine, however, when I submit the form
>> after selecting Joint and entering data, and later revisit that form,
>> the
>> data in the Life2 group is not preserved. Life1 group is unaffected.
>>
>> Anybody know why this is occurring?
>>
>> Relevant parts of form:
>>
>> Radio button def:
>>
>>     <fd:field id="kwdSingleJoint">
>> 		<fd:label>Is this policy a Single Life or Joint Life
>> policy?</fd:label>
>> 		<fd:datatype base="string"/>
>>         <fd:initial-value>Single</fd:initial-value>
>> 		<fd:selection-list>
>> 			<fd:item value="Single"/>
>> 			<fd:item value="Joint"/>
>> 		</fd:selection-list>
>> 		<fd:on-value-changed>
>> 			<javascript>
>> 			  var value = event.source.value;
>> 			  var life2widget = event.source.lookupWidget("../life2");
>> 			  if (value == "Joint")
>> 			  {
>> 				life2widget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
>> 			  }
>> 			  else
>> 			  {
>> 				life2widget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
>> 			  }
>> 			</javascript>
>> 		</fd:on-value-changed>
>> 	</fd:field>
>>
>>
>> and part of Life2 def:
>>
>> 	<fd:group id="life2" state="invisible">
>> 	  <fd:widgets>
>> 		<fd:field id="title2">
>> 		  <fd:label>Title</fd:label>
>> 		  <fd:datatype base="string" />
>> 		  <fd:selection-list>
>> 			   <fd:item value="Mr"/>
>> 			   <fd:item value="Mrs"/>
>> 			   <fd:item value="Miss"/>
>> 			   <fd:item value="Ms"/>
>> 			   <fd:item value="Dr"/>
>> 			   <fd:item value="Fr"/>
>> 			   <fd:item value="Br"/>
>> 			   <fd:item value="Sr"/>
>> 			   <fd:item value="Rev"/>
>> 		  </fd:selection-list>
>> 		</fd:field>
>>
>> 		<fd:field id="firstName2">
>> 			<fd:label>First Name</fd:label>
>> 			<fd:datatype base="string" />
>> 		</fd:field>
>>
>>                 etc...
>>
>>          <fd:group>
>>
>> Thanks in advance
>>
>> Duncan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>
> Digging a bit deeper, I find that upon first submit of the form (and only
> choosing Life1 as clicking the radio button causes a submit action) then
> going back in the browser, the data is retained.
>
> If I even update any other field on the page then do another submit, this
> data is not retained - why is it then that only the initial submit data is
> "saved"?
>
> Should also put the simplified "stripped down" flow in as well:
> ~
> ~
>     var form = new Form("forms/start_def.xml");
>     var form2 = new Form("forms/clientdetails_def.xml");
>     var form3 = new Form("forms/policydetails_sib_def.xml");
>
>     form.showForm("start-display-pipeline");
>
>     //causing me problems at the moment
>     form2.showForm("clientdetails-display-pipeline");
>
>
>     form3.showForm("policydetails_sib-display-pipeline");
> ~
> ~
>
> Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Hi

Sorry to keep replying to my own mails, but I just tried a similar test on
the Car Selector example in the cocoon form samples.

This uses submit-on-change using a number of selection lists. All I did
was add a text box at the bottom.

I made some selections (each one causing the form submit event to fire)
then put
some text into my test text field and submitted.
- Went back in the browser and refreshed to make sure it was recalled - it
was.
- I then changed the text and re-submitted.
- Went back in the browser again and refreshed again, this time the old
value (i.e. not my new one) came back.

Is this a problem with continuations then, as I notice if the submit on
change isn't used, data seems to recall fine.

Is there anyway around this, or am I going to have to bind the form using
a javabean to allow users to recall the data correctly?

Thanks again

Duncan



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