Question

I am used WebWork and I am not able to validate my data properly.

The main two things I don't know how to do are:

-Validate a field with the validator of its super class.

Example: Say we have class Person and Class Employee. I want to validate an attribute of class Employee with my Person-validation.xml. Is it possible?

-Validate the length of a list:

I have an attribute that is a list, how could I check the length of the list and afterwards check every item within the list with its appropriate validator?

I tried:

<field name="list">
    <field-validator type="visitor">
        <message />
    </field-validator>
<field-validator type="fieldexpression">
    <param name="expression">
            list.size() < 2
        </param>
        <message key="too much items"/>
    </field-validator>
</field>

but it is now working.

Thanks

Was it helpful?

Solution

For you "-Validate the length of a list" problem:

<field-validator type="fieldexpression">
   <param name="expression"><![CDATA[2 > list.size]]></param>
   <message key="too much items"/>
</field-validator>

OTHER TIPS

If someone has the same problem: At the end it is done automatically!!! The validator of the super class is called by default :) and use

 <field-validator type="fieldexpression">
   <param name="expression"><![CDATA[2 > list.size]]></param>
   <message key="too much items"/>
</field-validator>

for the list

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top