That example throws a bit too much all at once for an intro to the 'requiredif' rule. For making a simple validation such as
'inputVia' - a radio button set with values of 'FILE_SELECT' and 'MANUAL_INPUT'
'file' - a formFile for uploading a file,
'manualText' - a text area for inputting text
where you wanted the file to be required if the radio button was 'FILE_SELECT'
and you wanted the manualText to be required if the radio button was 'MANUAL_INPUT',
here's the validation.xml I ended up with. Its actually readable :)
-jeff
<field property="file.fileName" depends="requiredif"> <arg0 key="uploadForm.file.errorname"/> <var> <var-name>field[0]</var-name> <var-value>inputVia</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>FILE_SELECT</var-value> </var> </field> <field property="manualText" depends="requiredif"> <arg0 key="uploadForm.manualText.errorname"/> <var> <var-name>field[0]</var-name> <var-value>inputVia</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>MANUAL_INPUT</var-value> </var> </field>
On Thursday, March 20, 2003, at 10:06 AM, Steve wrote:
Has there been a time table set for 1.2? Any thoughts on alternative solutions? Banging my head on the keyboard doesn't seem to work.
-----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]