/***
 * Excerpted from "Domain-Driven Design Using Naked Objects",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/dhnako for more book information.
***/
@Override
protected void configureNotesFieldRules(
        final LabelAndFormComponent lafc) {
    super.configureNotesFieldRules(lafc);
    installMaxLengthValidator(
            Customer.class, lafc.getFormComponent());
}
private void installMaxLengthValidator(
        final Class<?> domainClass, final FormComponent field) {
    NakedObjectAssociation association = 
        getAssociation(domainClass, field);
    MaxLengthFacet maxLengthFacet = 
        association.getFacet(MaxLengthFacet.class);
    if (maxLengthFacet != null) {
        field.add(StringValidator.maximumLength(
                    maxLengthFacet.value()));
    }
}
