Private Mixin Interfaces

One additional feature of my binding library is that a Mixin can register any number of interfaces to a presentation model. This allows the Mixin to define implementation properties that aren’t visible to the user. Thus code completion on the ValueModels returned from the PresentationModel won’t show the private properties.

I use this feature in the ValidationMixin. The mixin registers its own interfaces with the PresentationModel being validated. This means you don’t even need to define that your PresentationModel vends ValidatableValueModels. The following is an example.

// Create a model that vends ComponentValueModels defined by
// the ComponentMixin.
public class PersonPM
extends BeanPresentationModel
{
   public PersonPM()
   {
      // we have to pass the classes in because of erasure..
      super(Person.class, ComponentValueModel.class);   

     // create a validation engine, this will install the required
     // mixin interfaces to the presentation model.
     engine = new ValidationEngine(this);  

     // now we can add some values..
     installValueModel("firstName");

     // now configure the validators, these will use the private
     // interfaces defined by the validation mixin.
     engine.getValidationManager("firstName")
           .setMandatory("Please enter your first name")
           .addValidator(new NameValidator());
  }
}
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *