views:

1037

answers:

6

hi,

I want my validation.xml to only check for a null if certain options are selected from a dropdown. So far I have

<field property="empFDServiceStartDate" depends="requiredif, date">
        <arg0 key="Service Start date" resource="false"/>
        <var>
                <var-name>field[0]</var-name>
                <var-value>moverChangeType</var-value>
        </var>
        <var>
                <var-name>fieldTest[0]</var-name>
                <var-value>EQUALS</var-value>
        </var>
        <var>
                <var-name>fieldValue[0]</var-name>
                <var-value>Conversion</var-value>
        </var>
</field>

When the value "Conversion" is selected from the moverChangeType dropdown, I was hoping that the empFDServiceStartDate field would be checked for nulls before being saved. At the moment this doesn't work and it allows me to save nulls.

Any idea?

I am tied to struts 1.1 and therefore can't use newer commands.

M

A: 

If you want to check the field if moverChangeType equals "Conversion" try this...

<field property="empFDServiceStartDate" depends="requiredif, date">
    <arg0 key="Service Start date" resource="false"/>
    <var>
        <var-name>test</var-name>
        <var-value>(moverChangeType == "Conversion")</var-value>
    </var>
</field>
Fred
A: 

Thats brilliant thank you!!

can i make it test multiple entries?

<field property="empFDServiceStartDate" depends="requiredif, date">
    <arg0 key="Service Start date" resource="false"/>
    <var>
      <var-name>test</var-name>
      <var-value>(moverChangeType == "Conversion")</var-value>
    </var>
   <var>
    <var-name>test</var-name>
    <var-value>(moverChangeType == "SomethingElse")</var-value>
</var>   
</field>

?

A: 

You can do this multiple test in the same test, like this:

<field property="empFDServiceStartDate" depends="requiredif, date">
    <arg0 key="Service Start date" resource="false"/>
    <var>
      <var-name>test</var-name>
      <var-value>((moverChangeType == "Conversion") or (moverChangeType == "SomethingElse"))</var-value>
    </var>  
</field>
Fred
A: 

i cant get this to work its not actually evaluating it? any ideas?

A: 

i've tried this instead but it's still not working!

        <field property="empFDServiceStartDate" depends="requiredif, date">
      <arg0 key="Service Start date" resource="false"/>
        <var-name>field[0]</var-name>
       <var-value>moverChangeType</var-value>
     </var>
     <var>
       <var-name>fieldTest[0]</var-name>
       <var-value>EQUAL</var-value>
     </var>
     <var>
       <var-name>fieldValue[0]</var-name>
       <var-value>Conversion to AZ FTC</var-value>
     </var>
              <var-name>field[1]</var-name>
       <var-value>moverChangeType</var-value>
     </var>
     <var>
       <var-name>fieldTest[1]</var-name>
       <var-value>EQUAL</var-value>
     </var>
     <var>
       <var-name>fieldValue[1]</var-name>
       <var-value>Conversion to AZ Permanent</var-value>
     </var>
     <var>
       <var-name>fieldJoin</var-name>
       <var-value>OR</var-value>
     </var>

  </field>
A: 

hhhhhhhhhhhgfsfghfgh015654`