Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

An attribute validation is a validation specific for one attribute, if you want to have validation over multiple attributes or an element, you need to use the ElementValidation customization.
You will not see this attribute validation in the DataControl, but once the attribute on the page is submitted, the validation will fire.
If the validation fails, it is up to you as programmer to throw the correct error message as an AttrValException. 

Just as any other data control customization this requires an annotated method in a Customization Java Class

Code Block
languagejava
     @AttrValidation
    public void validateSalary(AttrChangeEvent event) throws AttrValException {
        BigDecimal oldVal = (BigDecimal) event.getOldValue();
        BigDecimal newVal = (BigDecimal) event.getNewValue();
        if (newVal != null && oldVal != null && newVal.compareTo(oldVal) < 0) {
            throw new AttrValException(AttrValException.TYP_ATTRIBUTE, "Salary can not be lowered", "SAL-0001",
                                       event.getElement().getDefinition().getFullName(), event.getAttribute());
        }
    }

...