Hi
I really wishes there was a clear instruction/manual for Constraint as, yet again, my poor brain fried up...
I want to be able to specify these 2 types of constraints, which seem easy enough:
propertyA is required if propertyB=x AND propertyC=y
also
propertyA is required if propertyB=x OR propertyC=y
I have tried the following without success:
ditto for the OR, it is always false.Code:new RequiredIfTrue("propertyB", and(eq("propertyB", y), eq("propertyC", y))
I have also tried this for the 'and'Code:new RequiredIfTrue("propertyB", or(eq("propertyB", y), eq("propertyC", y))
Can anyone help? why does and(eq("propertyB", y), eq("propertyC", y) always seems to return false???Code:new RequiredIfTrue("propertyA", new ConditionalPropertyConstraint(eq("propertyB", x), eq("propertyC", y)))
I then seem to have found a solution, which seems way over-complicated:
What is the difference between a "new And(...." and "and(..." ? Why does not an 'and' seem to use CompoundPropertyConstraint?Code:new RequiredIfTrue("propertA", new CompoundPropertyConstraint(new And(new PropertyConstraint[] { eq("propertyB", x, eq("propertyC", y) }))));
Whoever knows all this... please write a blog... :-) Thanks!
Many thanks in advance.
Benoit


Reply With Quote
