Hi, > Is there a way to perform 'requiredif' validation on nested objects ? > I would like to check for the value of an object only if the object > containing > it is not null. > > In the following example scenario: > > Class A{ > String x; > String y; > } > > Class Obj{ > A sub1; > String sub2; > } > > I need to validate an object of class Obj based on the rule that 'If sub1 is > not null > then sub1.x should be not null, and if sub1 is null, then do not check for > sub1.x' > The validator.xml is:
> <form .... > > ..... > <field property="sub1.x" depends="requiredif"> > <var> > <var-name>field[0]</var-name> > <var-value>sub1</var-value> > </var> > <var> > <var-name>fieldTest[0]</var-name> > <var-value>NOTNULL</var-value> > </var> > > </field> > ... > </form> > > However, this does not seem to work, and fails when sub1 is null. It throws > an > exception when trying to retrieve sub1.x value. > > Is there any way to perform such a validation ? > > > > Thanks and Regards, Ashutosh