title: How to validate number format TextField in wicket?
body: <p>In my maven-wicket (6.10) application I have a TextField, which has an Integer type property model. I want to set a maximum length for numberts to type into this TextField. (for example the user should write maximum 2 characters to the "age" text field)</p>
  
  <p>I have tried this code:</p>
  
  <pre><code>add(new TextField&lt;&gt;("age",new PropertyModel&lt;(personModel,"age"))
      .add(StringValidator.maximumLength(2)));
  //age is an Integer value from a Person class, personModel is "IModel&lt;Person&gt;" type
  </code></pre>
  
  <p>but I got this exception:</p>
  
  <pre><code>java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
      at org.apache.wicket.validation.validator.StringValidator.getValue(StringValidator.java:87)
      at org.apache.wicket.validation.validator.StringValidator.getValue(StringValidator.java:59)
      at org.apache.wicket.validation.validator.AbstractRangeValidator.validate(AbstractRangeValidator.java:107)
      at org.apache.wicket.markup.html.form.FormComponent.validateValidators(FormComponent.java:1523)
  </code></pre>
  
  <p>So if the property model is not string type, I cannot use StringValidator. I have found examples, which use NumberValidator (<a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/validation/validator/package-summary.html" rel="nofollow noreferrer">validators</a>), but I cannot resolve NumberValidator. I have only these validators in the source:
  <img src="https://i.stack.imgur.com/DUpus.png" alt="validation source">
  How could I use number validator? Or am I missing something, maybe form the pom.xml's dependencies for wicket?</p>