Thanks Jeff. My field-join condition should be AND instead of OR. That's
a big DUH on my part. Less coffee more sleep I guess. 

-----Original Message-----
From: Steve [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 20, 2003 3:04 PM
To: 'Struts Users Mailing List'
Subject: RE: 1.1 rc1 -Validator: Conditionally required fields.


The status would have a value of Active Inactive or All.
shortDiagnosisDescription and or diagnosisDescription are not required
as long as the 'status' has been selected. So you can basically search
on lets say all Active records without specifying a
shortDiagnosisDescription or diagnosisDescription. Not sure about radio
buttons having values of 'Off' though.


-----Original Message-----
From: Jeff Kyser [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 20, 2003 2:52 PM
To: Struts Users Mailing List
Subject: Re: 1.1 rc1 -Validator: Conditionally required fields.


An unselected radio button has a value of 'Off' rather than NULL, 
doesn't it?

Are you're trying to say?
     shortDiagnosisDescription is required if diagnosisDescription is 
NULL OR status is Off
     diagnosisDescription is required if shortDiagnosisDescription is 
NULL OR status is Off


-jeff

On Thursday, March 20, 2003, at 01:32  PM, Steve wrote:

> That makes sense. So if I had two input fields and a radio button
> (status-that is defaulted to a checked value from my ValidatorForm) I 
> would think the following would work:
>
> <field property="shortDiagnosisDescription" depends="requiredif">
>    <arg0 key="searchForm.shortDiagnosisDescription"/>
>    <var>
>       <var-name>field[0]</var-name>
>       <var-value>diagnosisDescription</var-value>
>    </var>
>    <var>
>       <var-name>field-test[0]</var-name>
>       <var-value>NULL</var-value>
>    </var>
>    <var>
>       <var-name>field[1]</var-name>
>       <var-value>status</var-value>
>    </var>
>    <var>
>       <var-name>field-test[1]</var-name>
>       <var-value>NULL</var-value>
>    </var>
>    <var>
>       <var-name>field-join</var-name>
>       <var-value>OR</var-value>
>    </var>
> </field>
>
> <field property="diagnosisDescription" depends="requiredif">
>    <arg0 key="searchForm.diagnosisDescription"/>
>    <var>
>       <var-name>field[0]</var-name>
>       <var-value>shortDiagnosisDescription</var-value>
>    </var>
>    <var>
>       <var-name>field-test[0]</var-name>
>       <var-value>NULL</var-value>
>    </var>
>    <var>
>       <var-name>field[1]</var-name>
>       <var-value>status</var-value>
>    </var>
>    <var>
>       <var-name>field-test[1]</var-name>
>       <var-value>NULL</var-value>
>    </var>
>    <var>
>       <var-name>field-join</var-name>
>       <var-value>OR</var-value>
>    </var>
> </field>
>
> That basically says if nothing is entered in either input field just 
> use the the value given for the status radio button. Using the above
> listing
> however doesn't behave as I expect. Are radio buttons evaluated
> differently? Looking at the validateRequiredIf method doesn't seem to
> indicate that. Thanks to all the help thus far.
>
>
>
> -----Original Message-----
> From: James Turner [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 20, 2003 11:17 AM
> To: 'Struts Users Mailing List'
> Subject: RE: 1.1 rc1 -Validator: Conditionally required fields.
>
>
> That would be me.  For the moment, here's a simple example of a
> requiredif:
>
> Let's say you have three fields in your form, Sex, dateOfLastMamogram,

> and testResult.  If sex is 'F' or 'f', dateOfLastMamogram should be 
> required. If dateOfLastMamogram is not empty, testResult is required. 
> Here the validator XML for it:
>
> <form name="medicalStatusForm">
>
> <field
>     property="dateOfLastMamogram" depends="requiredif">
>   <arg0 key="medicalStatusForm.dateOfLastMamogram.label"/>
>   <var>
>     <var-name>field[0]</var-name>
>     <var-value>sex</var-value>
>   </var>
>   <var>
>     <var-name>field-test[0]</var-name>
>     <var-value>EQUAL</var-value>
>   </var>
>   <var>
>     <var-name>field-value[0]</var-name>
>     <var-value>F</var-value>
>   </var>
>   <var>
>     <var-name>field[1]</var-name>
>     <var-value>sex</var-value>
>   </var>
>   <var>
>     <var-name>field-test[1]</var-name>
>     <var-value>EQUAL</var-value>
>   </var>
>   <var>
>     <var-name>field-value[1]</var-name>
>     <var-value>f</var-value>
>   </var>
>   <var>
>     <var-name>field-join</var-name>
>     <var-value>OR</var-value>
>   </var>
> </field>
>
> <field
>     property="testResult" depends="requiredif">
>   <arg0 key="medicalStatusForm.testResult.label"/>
>   <var>
>     <var-name>field[0]</var-name>
>     <var-value>dateOfLastMamogram</var-value>
>   </var>
>   <var>
>     <var-name>field-test[0]</var-name>
>     <var-value>NOTNULL</var-value>
>   </var>
> </field>
> </form>
>
> I've added this example to the Validator dev guide and the Struts FAQ
> to
> hopefully reduce the number of these queries.
>
>> -----Original Message-----
>> From: David Graham [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, March 20, 2003 10:58 AM
>> To: [EMAIL PROTECTED]
>> Subject: Re: 1.1 rc1 -Validator: Conditionally required fields.
>>
>>
>>> Are there any other examples of using conditionally required
>> fields for
>>> the validator? I find the example here a bit confusing.
>>
>> You're not the only one.  I still haven't figured it out although I 
>> haven't spent much time with it.  A committer (can't remember which 
>> one) has developed an easier validation method for this kind of 
>> thing.  We should be
>> adding it for 1.2.
>>
>>>
>>> http://jakarta.apache.org/struts/userGuide/dev_validator.html
>>>
>>> Specifically the part:
>>> <form-bean
>>>     name="dependentlistForm"
>>>     type="org.apache.struts.webapp.validator.forms.ValidatorForm">
>>>
>>>     <form-property
>>>         name="dependents"
>>>         type="org.apache.struts.webapp.validator.Dependent[]"
>>>         initial="{'','','','','','','','','','',''}"/>
>>>     <form-property
>>>         name="insureDependents"
>>>         type="java.lang.Boolean"
>>>         initial="false"/>
>>>
>>> </form-bean>
>>>
>>> 'Where dependent is a bean that has properties lastName, firstName, 
>>> dob, coverageType'
>>>
>>> Is 'dependent' referring to Dependent[] or dependentlistForm? If 
>>> Dependent[], I don't see this in the src. Or this something
>> I need to
>>> code? Thanks for any clarity you can offer.
>>>
>>> steve
>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> _________________________________________________________________
>> Help STOP SPAM with the new MSN 8 and get 2 months FREE* 
>> http://join.msn.com/?page=features/junkmail
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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



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



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

Reply via email to