Sorry I am not following you. I am trying to to use the 'requiredif'
validation not 'required' validation.  I dont have xml defining the field.
Just what I had posted in the previous message to illustrate my problem.  I
am currently looking at the code of requiredif to see if its functioning
properly.

You say to use required, mycheck.  But I cant require the field.  I need to
require it conditionally based on another field in the form.  That is why I
want to use requiredif.  Based on whether a field is true or false, validate
some other fields, kind of thing...

As for as the code for RequiredIf, it doesnt seem to me to handle EQUALS
well.  

boolean required = false;

...
...
...
            if (dependTest.equals(FIELD_TEST_EQUAL)) {
                        this_required =
dependTestValue.equalsIgnoreCase(dependVal);
            }
...
...

        if (required) {
            if ((value != null) && (value.length() > 0)) {
                return true;
            } else {
                errors.add(field.getKey(), Resources.getActionError(request,
va, field));
                return false;
            }
        }
}
No where does it seem to compare the xml value and the value on the actual
form.




If you have any other suggestions or can clarify, please do...  


Jeremy Weber                    
[EMAIL PROTECTED]


-----Original Message-----
From: Dennis Muhlestein [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 24, 2003 3:39 PM
To: Struts Users Mailing List
Subject: RE: RequiredIf Example Request


I just barely ran into this problem.  Seems that all the field checks
are run.  Checking the Validator example (TowFieldCheck) in the struts
docs (1.1b3), It seems that if the value is null, you should let it pass
as accepted.

The xml defining the field is the one that should specify that the field
is required.  id: required,mycheck

Then it becomes possible to have an optional field.

-Dennis

On Thu, 2003-01-23 at 14:33, Weber, Jeremy wrote:
> Yes, but I would think that it would only be run after the first
validation
> (the requiredif) runs.  Is that not a correct assumption?  Do I need to
add
> anything to the exists validation to make it so?  In your example if the
> requiredif fails, does it still try to run the next validations....?
> 
> 
> 
> Jeremy Weber                    
> [EMAIL PROTECTED]
> 
> 
> -----Original Message-----
> From: Greg Murray [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 4:20 PM
> To: Struts Users Mailing List
> Subject: RE: RequiredIf Example Request
> 
> 
> I'm not sure "exists" is a standard validation rule.  Did you define it
> yourself?
> 
> -----Original Message-----
> From: Weber, Jeremy [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 2:00 PM
> To: 'Struts Users Mailing List'
> Subject: RE: RequiredIf Example Request
> 
> 
> Thank you , thank you, thank you!
> 
> I misspoke when I said checkboxs, its a radio button, like this...
> 
>       
> <tr>
>       <td class="mandatory"><bean:message
> key="appserver.usesecure.displayname"/></td>
>       <td><html:radio property="useSecure" value="true"
> onclick="showSecureOptions('true');"/> Yes<br>
>       <html:radio property="useSecure" value="false"
> onclick="showSecureOptions('false');"/> No</td>
> 
> </tr>
> 
>                        <field property="sslKeyStore"
> depends="requiredif,exists">
>                              <arg0
> key="appserver.sslkeystore.displayname"/>
>                              <var>
>                                       <var-name>field[0]</var-name>
>                                       <var-value>useSecure</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>true</var-value>
>                               </var>
>                       </field>
> 
> 
> >From what I can tell, this looks like it will work... But it doesnt.
> However, this is the kicker... If I remove exists from depends, it acts as
> it should.  Now I figured that exists would only be called if requiredif
> passed.  Any thoughts?
> 
> 
> 
> 
> 
> 
> Jeremy Weber                    
> [EMAIL PROTECTED]
> 
> 
> -----Original Message-----
> From: Greg Murray [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 3:26 PM
> To: Struts Users Mailing List
> Subject: RE: RequiredIf Example Request
> 
> 
> If you're just requesting an example of something, here's what I'm
currently
> using:
> 
>       <field property="studentId"
> depends="requiredif,integer,minlength,maxlength">
>         <msg name="requiredif" key="errors.msg.studentIDorNameRequired"/>
>         <msg name="integer" key="errors.msg.invalidStudentID"/>
>         <msg name="minlength" key="errors.msg.invalidStudentID"/>
>         <msg name="maxlength" key="errors.msg.invalidStudentID"/>
>         <var>
>           <var-name>minlength</var-name>
>           <var-value>9</var-value>
>         </var> 
>         <var>
>           <var-name>maxlength</var-name>
>           <var-value>9</var-value>
>         </var>
>         <var>
>           <var-name>field[0]</var-name>
>           <var-value>lastName</var-value>
>         </var>
>         <var>
>           <var-name>field-test[0]</var-name>
>           <var-value>NULL</var-value>
>         </var>
>       </field>
> 
> This makes studentId required if lastName is NULL.  If I also wanted to
add
> a requirement to make studentId required if firstName was null, I'd add
the
> following to the above:
> 
>         <var>
>           <var-name>field[1]</var-name>
>           <var-value>lastName</var-value>
>         </var>
>         <var>
>           <var-name>field-test[1]</var-name>
>           <var-value>NULL</var-value>
>         </var>
> 
> The conditions you can have are NULL, NOTNULL, and EQUAL.
> 
> I haven't used this with checkboxes yet, but I think you'd probably have
> each of your three fields use requiredif, and use something like the
> following to make it depend on the checkbox:
> 
>         <var>
>           <var-name>field[0]</var-name>
>           <var-value>checkboxFieldName</var-value>
>         </var>
>         <var>
>           <var-name>field-test[0]</var-name>
>           <var-value>NOTNULL</var-value>
>         </var>
> 
> The fact that the example was using indicies screwed me up for a while too
> until I took a look at the source code for FieldChecks.
> 
> GM
> 
> -----Original Message-----
> From: Weber, Jeremy [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 12:57 PM
> To: 'Struts Users Mailing List' (E-mail)
> Subject: RequiredIf Example Request
> 
> 
> I requested this before and have not recieved a response...:(  Any takers
> out there?  Currently I am having a heck of time figuring out how to make
> this work...  
> 
> I have checked out all the online examples, but I am unclear as to what
this
> stuff means...
> 
> If you have this in your struts-config.xml...
> 
> <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>
> 
> My form properties look like...
> 
> <form-bean name="InstallConfigurationFormBean"
>       type="com.vendorsite.install.beans.InstallConfigurationFormBean"/>
> 
> 
> So I am missing the type and initial fields.  Can anybody help me see the
> light?  I need a checkbox to control whether or not 3 addiotional text
> fields are required.
> 
> Thanks,
> 
> Jeremy Weber                    
> [EMAIL PROTECTED]
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
-- 
Dennis Muhlestein <[EMAIL PROTECTED]>
ZServe Corporation


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

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

Reply via email to