# ClassCastException when using NumberTextField

**URL:** <https://forum.inductiveautomation.com/t/classcastexception-when-using-numbertextfield/12648>\
**Category:** Module Development\
**Created:** [February 6, 2017, 7:54pm UTC](https://forum.inductiveautomation.com/t/classcastexception-when-using-numbertextfield/12648 "2017-02-06T19:54:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![caitlinf](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@caitlinf](https://forum.inductiveautomation.com/u/caitlinf)\
**Post date:** [February 6, 2017, 7:54pm UTC](https://forum.inductiveautomation.com/t/classcastexception-when-using-numbertextfield/12648/1 "2017-02-06T19:54:51Z")

</div>

Hello again,

I am having an issue when trying to use a NumberTextField in my module’s web page.

I get the following error:

[code]Last cause: java.lang.Double cannot be cast to java.lang.String  
WicketMessage: Exception ‘java.lang.Double cannot be cast to java.lang.String’ occurred during validation org.apache.wicket.validation.validator.RangeValidator on component 20:config-contents:antenna-connect-form:antenna-name

[/code]

which occurs on my NumberTextField component.

My html and java files are as follows:

[code]\<?xml version="1.0" encoding="ISO-8859-1" ?\>

# Add New Connection

Antenna ID:

```
     <h1>Remove Connection</h1>
     <form wicket:id="antenna-remove-form">
     <p>Antenna ID:</p>
    	  <input wicket:id="remove-antenna-name" type="number" />
      	 <input wicket:id="remove-button" class="savebtn" type="submit"
           value="Remove Antenna" />
     </form>
     
  </wicket:extend>

```

 [/code]

[code]   
…  
//components for adding new antenna connection form  
Form addform = new Form(“antenna-connect-form”);  
TextField IP\_ADDRESS = new TextField(“ip-address”, new Model(“ip address”));  
TextField PORT = new TextField(“port”, new Model(“port”));  
NumberTextField ANTENNA\_ID = new NumberTextField(“antenna-name”, new Model());  
Button addButton = new Button(“submit-button”){  
public void onSubmit(){  
try {  
LRSManager.addNewAntenna(IP\_ADDRESS.getValue(), Integer.parseInt(PORT.getValue()), Integer.parseInt(ANTENNA\_ID.getValue()));  
LRSManager.DBConnectAdd(LRSManager.getByID(Integer.parseInt(ANTENNA\_ID.getValue())));  
} catch (Exception e) {  
logger.error("error: " + e.toString());  
}  
}  
};

…[/code]

I am not sure why this is happening and I can’t seem to find the same error online. Could I be using the NumberTextField incorrectly? If so, how can I make the field so that the only valid input is integers?

---

<div class="post-metadata">

**Author:** ![caitlinf](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@caitlinf](https://forum.inductiveautomation.com/u/caitlinf)\
**Post date:** [February 6, 2017, 9:01pm UTC](https://forum.inductiveautomation.com/t/classcastexception-when-using-numbertextfield/12648/2 "2017-02-06T21:01:08Z")

</div>

Somehow fixed it by changing the code to:

```auto
NumberTextField<Integer> ANTENNA_ID = new NumberTextField<Integer>("antenna-name", new Model<Integer>(), Integer.class);
```
