I just made a simple test and it worked for me.
1. I downloaded the most recent build.
2. Updated my validator-rules.xml to the new version.
3. Updated my app-validation.xml to use camel case variables like fieldTest instead of field-test.
4. Regenerated the static javascript and placed it in the file I use for caching (instead of generating it on each page).


My test form had 3 text boxes on it. Box 1 depends on required and email. Box 3 is required if Box 2 EQUALS "blah".

David




From: Bruce Geerdes <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Subject: Re: 1.1 rc1 -Validator: Conditionally required fields.
Date: Tue, 25 Mar 2003 15:09:42 -0700

Sorry, when I say the javascript validation is "broken" I mean the validation falls through to the server. Instead of getting a javascript dialog noting that such-and-such field is required, I get a server-side message.

Bruce


David Graham wrote:


What do you mean by "broke all the javascript validation on that page"? That's quite vague. The - is not a valid js variable name so switching to camel case must have fixed part of the problem but perhaps caused another.

David



From: Bruce Geerdes <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Subject: Re: 1.1 rc1 -Validator: Conditionally required fields.
Date: Mon, 24 Mar 2003 16:16:02 -0700

In our last episode, I downloaded the 3/20 nightly build and discovered that adding a requiredif depends broke all the javascript validation on that page. I have since reverted back to 1.1b3 and, lo and behold, javascript is no longer broken (on Netscape 7, anyway). Even though the requiredif code I'm using has the "field-*" names.

Anyway, I thought I'd add this to the muddle. If requiredif is broken in 1.1rc1, it does not appear (to me anyway) that changing variables from "field-*" to camel case has fixed it.

Bruce


David Graham wrote:


You can't use field-* anymore. It generates invalid javascript variables so I changed all of those variables to camel case and removed the "-". Also, can you choose a different topic for the example? This one is kind of distracting :-).

David



From: "James Turner" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Subject: RE: 1.1 rc1 -Validator: Conditionally required fields.
Date: Thu, 20 Mar 2003 11:16:40 -0500

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]




_________________________________________________________________
The new MSN 8: advanced junk mail protection and 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]



_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail



--------------------------------------------------------------------- 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]



_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail



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



Reply via email to