cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <>
Subject Re: CForms (Cocoon Forms) validation & SelectionList fields
Date Fri, 26 Mar 2004 19:11:36 GMT
On 26.03.2004 20:01, Mark Lundquist wrote:

>> I have two selection lists on a page. The problem is this: the second 
>> one is a required field, only if the value of the first one is among a 
>> few values.
>> I've seen the car example (localhost:8888/samples/forms/carselector), 
>> which has served as a useful starting point, as I can populate the 
>> second list given a value in the first. However, I still can't find 
>> out how to make the second selection list a required field if the 
>> first one has a certain value.
> Something tells me there might be a way to use a union widget to achieve 
> this.  But I couldn't give you any details, I'm kinda behind the curve 
> on those bits...  Tim, are you out there? :-)
>> I thought of hiding the second list field if it's not required, but I 
>> don't know how to do that either.
> Try this...
> 1)
>     <wt:widget id="listA">
>         <wi:styling submit-on-change="true" />
>     </wt:widget>
> This will cause the form to redisplay when the selection is changed, but 
> with any other form control values the user has entered/changed being 
> redisplayed as well (unlike a client-side reload), however neither 
> validation nor form finalization are triggered (think of it as a 
> "smart"/sticky refresh!)
> 2) To conditionalize the display of the second selection list, use 
> JXTemplateGenerator to generate your Woody template, and write something 
> like this:
>     <jx:if test="${listA.value == 'whatever'}">
>         <wt:widget id="listB"/>
>     </jx:if>

Hmm, if I read the above I think he only wants to conditionalize the 
requiredness of selectionlist 2 in dependency on selectionlist 1, not 
the displaying. This is what was called "optionally required" in 

Vadim has provided a solution:

I have not used the XReporter expressions, but javascript using
     if (widget1 != null && widget2 == null) {
       widget2.setValidationError =
                              new ValidationError(general.required);
     } else {
       widget2.setValidationError = null;

For details have a look on the sample at


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message