Chain Validations

(only for Liferay 6.1.x)

              Chain validation here, are a way to populate a combo with values depending on another combo value selected. In a real world example, you would have a customer portlet with a combo to select the customer country and a combo to select its province.

                In this case, we all want to select only the provinces that are in the selected country. Well that is done using the new <depends> tag. Lets put all the parts of the ecuation on the table.

                First we have a country table, lets say it has countryId and countryName:

 

               Second we have a province table, it has provinceId, provinceName and provinceCountryId, so provinces can be filtered by its country. We could have made a master - detail, but we tought that this example would be more easy to understand.

 

 

                  And finally we have  a customers table, that has customerId, customerName, customerCountryId and customerProvinceId, we want province selection to depend on the country selected.

 

          All the magic is made at the customerProvinceId definition in the customers application. you can see the field definition:

<field>
<name>customerProvinceId</name>
    <title>Province</title>
    <type>
    <long>
        <length>5</length>
            <signed>false</signed>
            <nullable>false</nullable>
        </long>
    </type>
    <validation>
<className>Provinces</className>
<fieldName>provinceId</fieldName>
<orderByField>provinceName</orderByField>
<depends>
     <localFieldName>customerCountryId</localFieldName>
     <againstFieldName>provinceCountryId</againstFieldName>
</depends>
</validation>
<showFieldInView>true</showFieldInView>
<required>true</required>
</field>
 
                You have here the complete xml definition file for de Chain Validation Example.
                And here you have the portlet .war file generated from this definition for Liferay 6.1
 
     Saludos, Jack.