You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Markus Heussen <he...@asspaxx.de> on 2004/11/24 00:14:14 UTC

[CForms] booleanfield, on-value-change => display form fields

I know how to display form fields depending on an option selected in a 
dropdown list. But if I try to do the same using a booleanfield I get a 
ClassCastException.

Anyone there who can explain me or give some code examples about 
displaying form fields after checking a checkbox?

Many thanks!

Markus


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


Re: [CForms] booleanfield, on-value-change => display form fields

Posted by Joerg Heinicke <jo...@gmx.de>.
On 25.11.2004 22:54, Markus Heussen wrote:

>> Don't know about this sample, but it should be similar. Referencing 
>> the boolean field as case widget should work IIRC. I have done it 
>> myself, I could have a look at latest at monday. The rest should be 
>> the same like the selection list sample.
> 
> Trying it in different ways I get ClassCastExceptions all the time. I'm 
> looking forward for a running code snipped.

This was why I asked for the stacktrace. Maybe it is not even related to 
CForms. I will show a sample tomorrow though.

Joerg

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


Re: [CForms] booleanfield, on-value-change => display form fields

Posted by Joerg Heinicke <jo...@gmx.de>.
>> Don't know about this sample, but it should be similar. Referencing 
>> the boolean field as case widget should work IIRC. I have done it 
>> myself, I could have a look at latest at monday. The rest should be 
>> the same like the selection list sample.

I promised something, but did not make it to send it here. So somewhat 
late here is my example:

in form definition:

<fd:booleanfield id="newAddressKnown">
   <fd:label><i18n:text key="newAddressKnown"/></fd:label>
   <fd:on-value-changed>
     <javascript>
       var widget = event.source;
       var stringWidget = 
event.source.parent.getChild("newAddressKnownString");
       stringWidget.value = new java.lang.String(widget.value);
     </javascript>
   </fd:on-value-changed>
</fd:booleanfield>
<fd:output id="newAddressKnownString">
   <fd:datatype base="string"/>
</fd:output>
<fd:union id="newAddress" case="newAddressKnownString">
   <fd:widgets>
     <fd:struct id="true">
       <fd:widgets>
         ... the optional widgets ...
       </fd:widgets>
     </fd:struct>
   </fd:widgets>
</fd:union>

in form template:

<ft:widget id="newAddressKnown">
   <fi:styling submit-on-change="true"/>
</ft:widget>
<ft:union id="newAddress">
   <ft:case id="true">
     <ft:struct id="true">
       ... the optional widgets ...
     </ft:struct>
   </ft:case>
</ft:union>

Hope it helps. If someone can integrate it into the Cocoon samples, I 
would be happy to commit it.

Joerg

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


Re: [CForms] booleanfield, on-value-change => display form fields

Posted by Markus Heussen <he...@asspaxx.de>.
Joerg Heinicke schrieb:

Thanks for your answer!

> On 24.11.2004 09:55, Markus Heussen wrote:
> 
>> I'm convinced I did it in a wrong way. But I'm still trying to solve 
>> my problem by trial and error principle. Could you help me, please?
>>
>> I need a form that displays a couple of form fields. One field is a 
>> check box (booleanfield). If that box is checked I have to display 
>> some additional form fields beneath that check box.
> 
> 
> A boolean field should also be submit-on-change-able. This means adding 
> the following code snippet to your template should be part I:
> 
> <ft:widget id="aBooleanField">
>   <fi:styling submit-on-change="true"/>
> </ft:widget>

I've done it like this.

> 
>> How can I solve it using unions, structs and classes? I'm using the 
>> jx-macro sample style for my forms of Cocoon 2.1.6. This example shows 
>> what I want to do. But a selections-list is used instead of a 
>> booleanfield.
> 
> 
> Don't know about this sample, but it should be similar. Referencing the 
> boolean field as case widget should work IIRC. I have done it myself, I 
> could have a look at latest at monday. The rest should be the same like 
> the selection list sample.
> 

Trying it in different ways I get ClassCastExceptions all the time. I'm 
looking forward for a running code snipped.

Thanks for your help, Joerg!

> Joerg
> 
> ---------------------------------------------------------------------
> 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: [CForms] booleanfield, on-value-change => display form fields

Posted by Joerg Heinicke <jo...@gmx.de>.
On 24.11.2004 09:55, Markus Heussen wrote:

> I'm convinced I did it in a wrong way. But I'm still trying to solve my 
> problem by trial and error principle. Could you help me, please?
> 
> I need a form that displays a couple of form fields. One field is a 
> check box (booleanfield). If that box is checked I have to display some 
> additional form fields beneath that check box.

A boolean field should also be submit-on-change-able. This means adding 
the following code snippet to your template should be part I:

<ft:widget id="aBooleanField">
   <fi:styling submit-on-change="true"/>
</ft:widget>

> How can I solve it using unions, structs and classes? I'm using the 
> jx-macro sample style for my forms of Cocoon 2.1.6. This example shows 
> what I want to do. But a selections-list is used instead of a booleanfield.

Don't know about this sample, but it should be similar. Referencing the 
boolean field as case widget should work IIRC. I have done it myself, I 
could have a look at latest at monday. The rest should be the same like 
the selection list sample.

Joerg

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


Re: [CForms] booleanfield, on-value-change => display form fields

Posted by Markus Heussen <he...@asspaxx.de>.
Hi Joerg,

I'm convinced I did it in a wrong way. But I'm still trying to solve my 
problem by trial and error principle. Could you help me, please?

I need a form that displays a couple of form fields. One field is a 
check box (booleanfield). If that box is checked I have to display some 
additional form fields beneath that check box.

How can I solve it using unions, structs and classes? I'm using the 
jx-macro sample style for my forms of Cocoon 2.1.6. This example shows 
what I want to do. But a selections-list is used instead of a booleanfield.

Thanks for any help.

Markus


Joerg Heinicke schrieb:
> On 24.11.2004 00:14, Markus Heussen wrote:
> 
>> I know how to display form fields depending on an option selected in a 
>> dropdown list. But if I try to do the same using a booleanfield I get 
>> a ClassCastException.
> 
> 
> Can you send the beginning of the stack trace?
> 
> Joerg
> 
> ---------------------------------------------------------------------
> 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: [CForms] booleanfield, on-value-change => display form fields

Posted by Joerg Heinicke <jo...@gmx.de>.
On 24.11.2004 00:14, Markus Heussen wrote:

> I know how to display form fields depending on an option selected in a 
> dropdown list. But if I try to do the same using a booleanfield I get a 
> ClassCastException.

Can you send the beginning of the stack trace?

Joerg

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