The problem, sir, lies not in your requiredif, but in your mask.

When you say:

<var-value>^[A-Za-z -']+$</var-value>

What you're literally saying is "A to Z, a to z, and space to '".  What
you want to say is:

<var-value>^[A-Za-z\ \-\']+$</var-value>

When I used the correct mask, everything worked correctly. (i.e., if
patientId was blank, the other three fields were required and had to
obey the mask.  If patientId was not black, the other three could be.)

James

> -----Original Message-----
> From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, February 14, 2003 10:02 AM
> To: 'Struts Users Mailing List'
> Subject: RE: [REPOST] [Validator] REQUIREDIF Question
> 
> 
> Sri - thanks for the reply.  We have several other 
> validations going on with this form-bean, so I'm confident 
> that your first two items are OK.  I've also pulled the 
> 'REQUIREDIF' check out of the validation in question (leaving 
> just the MASK) and everything behaves correctly.  I've also 
> been over the validator docs countless times, and have 
> verified that the general approach matches what is in the 
> doc.  The only thing I can come up with is that the MASK 
> processing is screwing things up some way....
> 
> I'm about to a point of writing a custom validation routine 
> just to get by this, but would sure like to use the REQUIREDIF....
> 
> Jerry
> 
> > -----Original Message-----
> > From: Sri Sankaran [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 14, 2003 8:35 AM
> > To: Struts Users Mailing List
> > Subject: RE: [REPOST] [Validator] REQUIREDIF Question
> > 
> > 
> > Nothing out of the ordinary jumps out from what you have
> > sent.  That being said, following are a few points; a list 
> > which you have probably already checked and double-checked:
> > 
> > * Have you set the validator plug-in element in the 
> >   struts-config?
> > * Is the name of the form-bean in the action mapping also
> >   "UserInfo"?
> > * Have you ensured that the requiredIf logic is being invoked
> >   at all?  You could test this by say, changing the logic 
> >   (just for test purposes).  For example, change the NULL 
> >   criterion to some dummy string literal.  Then actually enter 
> >   that literal on the JSP and see if the requiredif logic 
> >   is triggered
> > 
> > Sri
> > 
> > -----Original Message-----
> > From: Jerry Jalenak [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 14, 2003 8:38 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: [REPOST] [Validator] REQUIREDIF Question
> > 
> > 
> > I'm reposting this in the hope that someone can tell what I'm
> > doing wrong. I can't seem to figure out why this doesn't 
> > work.....  Any (and all) help is greatly appreciated....
> > 
> > I have a rather simple form with 4 fields on it.  If the first field
> > (patientId) is left blank, then the other three fields
> > (lastName, firstName,
> > dob) are required.  So, in struts-config I have
> > 
> > <snip>
> >     <form-bean name="UserInfo"
> > type="org.apache.struts.validator.DynaValidatorForm">
> >             <form-property name="lastName"
> > type="java.lang.String"/>
> >             <form-property name="firstName"
> > type="java.lang.String"/>
> >             <form-property name="dob"
> > type="java.lang.String"/>
> >             <form-property name="patientId"
> > type="java.lang.String"/>
> >     </form-bean>
> > </snip>
> > 
> > and in my validator-rules I am using
> > 
> > <snip>
> >     <formset>
> >             <form name="UserInfo">
> >                     <field property="patientId" depends="mask">
> >                             <msg name="mask"
> > key="errors.field.invalid"
> > />
> >                             <arg0 
> > key="UserInfo.patientId.displayname"
> > />
> >                             <var>
> >                                     <var-name>mask</var-name>
> >                                     <var-value>^[0-9]+$</var-value>
> >                             </var>
> >                     </field>
> >                     <field property="lastName" depends="requiredif,
> > mask">
> >                             <msg name="requiredif"
> > key="errors.field.required" />
> >                             <msg name="mask" 
> > key="errors.field.invalid"
> > />
> >                             <arg0 
> > key="UserInfo.lastName.displayname" />
> >                             <var>
> >                                     <var-name>mask</var-name>
> >                                     <var-value>^[A-Za-z
> > -']+$</var-value>
> >                             </var>
> >                             <var>
> >                                     <var-name>field[0]</var-name>
> >                                     <var-value>patientId</var-value>
> >                             </var>
> >                             <var>
> >                                     
> > <var-name>field-test[0]</var-name>
> >                                     <var-value>NULL</var-value>
> >                             </var>
> >                     </field>
> >                     <field property="firstName" depends="requiredif,
> > mask">
> >                             <msg name="requiredif"
> > key="errors.field.required" />
> >                             <msg name="mask"
> > key="errors.field.invalid"
> > />
> >                             <arg0 
> > key="UserInfo.firstName.displayname"
> > />
> >                             <var>
> >                                     <var-name>mask</var-name>
> >                                     <var-value>^[A-Za-z
> > -']+$</var-value>
> >                             </var>
> >                             <var>
> >                                     <var-name>field[0]</var-name>
> >                                     <var-value>patientId</var-value>
> >                             </var>
> >                             <var>
> >                                     
> > <var-name>field-test[0]</var-name>
> >                                     <var-value>NULL</var-value>
> >                             </var>
> >                     </field>
> >                     <field property="dob"
> > depends="requiredif, mask">
> >                             <msg name="requiredif"
> > key="errors.field.required" />
> >                             <msg name="mask" 
> > key="errors.field.invalid"
> > />
> >                             <arg0 key="UserInfo.dob.displayname" />
> >                             <var>
> >                                     <var-name>mask</var-name>
> >                                     <var-value>^[0-9]+$</var-value>
> >                             </var>
> >                             <var>
> >                                     <var-name>field[0]</var-name>
> >                                     <var-value>patientId</var-value>
> >                             </var>
> >                             <var>
> >                                     
> > <var-name>field-test[0]</var-name>
> >                                     <var-value>NULL</var-value>
> >                             </var>
> >                     </field>
> >             </form>
> >     </formset>
> > </snip>
> > 
> > The REQUIREDIF check does not seem to be working as the
> > validation is passed successfully.  I suspect it has 
> > something to do with the form property being a String, but 
> > being checked against a NULL in validator.  I checked the 
> > validator docs and this appears to be the correct way of 
> > doing this.  Am I just missing something obvious?
> > 
> > TIA!
> > 
> > Jerry Jalenak
> > Web Publishing
> > LabOne, Inc.
> > 10101 Renner Blvd.
> > Lenexa, KS  66219
> > (913) 577-1496
> > [EMAIL PROTECTED]
> > 
> > 
> > 
> > This transmission (and any information attached to it) may be
> > confidential and is intended solely for the use of the 
> > individual or entity to which it is addressed. If you are not 
> > the intended recipient or the person responsible for 
> > delivering the transmission to the intended recipient, be 
> > advised that you have received this transmission in error and 
> > that any use, dissemination, forwarding, printing, or copying 
> > of this information is strictly prohibited. If you have 
> > received this transmission in error, please immediately 
> > notify LabOne at the following email address: 
> > [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]
> > 
> > 
> 
> This transmission (and any information attached to it) may be 
> confidential and is intended solely for the use of the 
> individual or entity to which it is addressed. If you are not 
> the intended recipient or the person responsible for 
> delivering the transmission to the intended recipient, be 
> advised that you have received this transmission in error and 
> that any use, dissemination, forwarding, printing, or copying 
> of this information is strictly prohibited. If you have 
> received this transmission in error, please immediately 
> notify LabOne at the following email address: 
> [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