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/03/13 13:13:25 UTC

Question about union

Hi

We have a situation where there is a dropdown list that contains one
of two options.

On one option, we want a group of fields to display and the other set of
fields to display, but be in a disabled state.
The other option will still show the first set of fields, but the second
set of fields will now be enabled as well.

Can anyone tell me whether it is possible to achieve this with a union -
as all the examples I have seen seem to conditionally show one set of
fields or another, not the scenario I have described.

Thanks

Duncan


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


Re: Question about union

Posted by Duncan McLean <du...@blueyonder.co.uk>.
Hi Jason

Bingo! The div workaround did the trick in this case.

Cheers

Duncan

> Duncan McLean wrote:
>> Hi Simone
>>
>> Thanks for this...
>>
>> The reason I asked this question is that we were trying this exact
>> approach
>> (though not using a union), but since we are using Ajax, we have been
>> getting an error...
>>
>> This is part of the definition for the form in question
>> It works correctly when we don't use Ajax, however
>> using Ajax we get the javascript alert error message:
>>
>> "No element "life2" defined in document" after the item is selected.
>
> This is due to the fact that (at least in 2.1.8) there is no placeholder
> HTML element generated for ft:group, so when an ajax update occurs it
> doesn't know where in the document to insert the result.  This is just
> one of those widgets that isn't fully supported under ajax mode yet.
>
> I'm trying to remember... I think you can work around this by wrapping
> the contents of your ft:group template with a div or span of the same
> id.  For example:
>
>   <ft:group id="life2">
>     <div id="life2">
>       <!-- all your content markup and sub-widgets... -->
>     </div>
>   </ft:group>
>
> ...though I think this might only work if the life2 group is visible on
> initial load.  Not sure, but worth a try.
>
> --Jason
>
> ---------------------------------------------------------------------
> 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


Re: Question about union

Posted by Jason Johnston <co...@lojjic.net>.
Duncan McLean wrote:
> Hi Simone
> 
> Thanks for this...
> 
> The reason I asked this question is that we were trying this exact approach
> (though not using a union), but since we are using Ajax, we have been
> getting an error...
> 
> This is part of the definition for the form in question
> It works correctly when we don't use Ajax, however
> using Ajax we get the javascript alert error message:
> 
> "No element "life2" defined in document" after the item is selected.

This is due to the fact that (at least in 2.1.8) there is no placeholder
HTML element generated for ft:group, so when an ajax update occurs it
doesn't know where in the document to insert the result.  This is just
one of those widgets that isn't fully supported under ajax mode yet.

I'm trying to remember... I think you can work around this by wrapping
the contents of your ft:group template with a div or span of the same
id.  For example:

  <ft:group id="life2">
    <div id="life2">
      <!-- all your content markup and sub-widgets... -->
    </div>
  </ft:group>

...though I think this might only work if the life2 group is visible on
initial load.  Not sure, but worth a try.

--Jason

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


Re: Question about union

Posted by Duncan McLean <du...@blueyonder.co.uk>.
Hi Simone

Thanks for this...

The reason I asked this question is that we were trying this exact approach
(though not using a union), but since we are using Ajax, we have been
getting an error...

This is part of the definition for the form in question
It works correctly when we don't use Ajax, however
using Ajax we get the javascript alert error message:

"No element "life2" defined in document" after the item is selected.

(If kwdJointSingle is set to Single then only Life1 is enabled, otherwise
Life2 is also enabled)

Any ideas?

		<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 dob1Starwidget = event.source.lookupWidget("../life1/dob1Star");
			  dob1Starwidget.setValue(" * ");

			  var life2widget = event.source.lookupWidget("../life2");
			  var title2widget = event.source.lookupWidget("../life2/title2");
			  var firstName2widget = event.source.lookupWidget("../life2/firstName2");
			  var lastName2widget = event.source.lookupWidget("../life2/lastName2");

			  var gender2widget = event.source.lookupWidget("../life2/gender2");
  			  var gender2Starwidget =
event.source.lookupWidget("../life2/gender2Star");
  			  gender2Starwidget.setValue(" * ");

			  var dob2widget = event.source.lookupWidget("../life2/dob2");
  			  var dob2Starwidget = event.source.lookupWidget("../life2/dob2Star");
  			  dob2Starwidget.setValue(" * ");


			  if (value == "Joint")
			  {
				life2widget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
				gender2Starwidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
				dob2Starwidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
			  }
			  else
			  {

				life2widget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.DISABLED);
				title2widget.setValue(null);
				firstName2widget.setValue(null);
				lastName2widget.setValue(null);
				gender2widget.setValue(null);
				gender2Starwidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
				dob2widget.setValue(null);
				dob2Starwidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
			  }

			</javascript>
			</fd:on-value-changed>
		</fd:field>

	        ~
		~
		~

		<fd:group id="life1">
			<fd:widgets>
			~
			some fields defined
			~
			</fd:widgets>
		</fd:group>
		<fd:group id="life2">
			<fd:widgets>
			~
			some other fields defined
			~
			</fd:widgets>
		</fd:group>


Thanks again

Duncan

> Hi Duncan,
> you should put an fd:on-value-changed on the dropdown. From inside this
> listener, you can change the status of other widgets to DISABLED and
> have them appear disabled. It should work correctly also setting the
> state of a union.
>
> Simone
>
> Duncan McLean wrote:
>
>>Hi
>>
>>We have a situation where there is a dropdown list that contains one
>>of two options.
>>
>>On one option, we want a group of fields to display and the other set of
>>fields to display, but be in a disabled state.
>>The other option will still show the first set of fields, but the second
>>set of fields will now be enabled as well.
>>
>>Can anyone tell me whether it is possible to achieve this with a union -
>>as all the examples I have seen seem to conditionally show one set of
>>fields or another, not the scenario I have described.
>>
>>Thanks
>>
>>Duncan
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
> --
> Simone Gianni
>
> ---------------------------------------------------------------------
> 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


Re: Question about union

Posted by Simone Gianni <s....@thebug.it>.
Hi Duncan,
you should put an fd:on-value-changed on the dropdown. From inside this 
listener, you can change the status of other widgets to DISABLED and 
have them appear disabled. It should work correctly also setting the 
state of a union.

Simone

Duncan McLean wrote:

>Hi
>
>We have a situation where there is a dropdown list that contains one
>of two options.
>
>On one option, we want a group of fields to display and the other set of
>fields to display, but be in a disabled state.
>The other option will still show the first set of fields, but the second
>set of fields will now be enabled as well.
>
>Can anyone tell me whether it is possible to achieve this with a union -
>as all the examples I have seen seem to conditionally show one set of
>fields or another, not the scenario I have described.
>
>Thanks
>
>Duncan
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>
-- 
Simone Gianni

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