if you are doing validation you can use imarkupfilter to check the attrs.

-igor


On Fri, May 13, 2011 at 1:57 PM, Craig Pardey
<[email protected]> wrote:
> 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
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to