I'd like to check that particular markup attributes have been set on a 
component.
My first instinct was to use component.getMarkupAttributes(), but the JavaDoc 
quite clearly suggests that it shouldn't be used.

For example, all TextFields should have a 'maxlength' defined:

public class MyTextField<T> extends TextField<T> {
      @Override
      public void onAfterRender(){
            super.onAfterRender();
            ValueMap attrs = getMarkupAttributes();
            if( !attrs.containsKey("maxlength")){
                  throw new IllegalStateException("No maxlength defined for " + 
getId());
            }
      }
}

Is there a better way to achieve this?
Ideally I'd like to do it in a unit test rather than at runtime.

Craig

Reply via email to