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 discussions:
http://marc.theaimsgroup.com/?t=107349479500003&r=1&w=4


Vadim has provided a solution:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=107352171910636&w=4

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

For details have a look on the sample at
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/woody/samples/forms/form1.xml?annotate=1.24#240

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to