title: Editing a Number cell in a TableView
body: <p>I have a <code>TableView</code> control which consists of several columns containg different types including <code>String</code>s and <code>Number</code>s. I have been trying to write a suitable callback function for an editable Number cell, but I can't get anywhere with it as I get a variety of issues ranging from empty cells to exceptions.</p>
  
  <p>I have read through <a href="http://docs.oracle.com/javafx/2/ui_controls/table-view.htm" rel="noreferrer">http://docs.oracle.com/javafx/2/ui_controls/table-view.htm</a> but this only covers String values in cells. The sticking point seems to be <code>lastNameCol.setCellFactory(TextFieldTableCell.forTableColumn());</code>. This line seems to be tailored for Text fields and not for Number fields.</p>
  
  <p>Also, I wish to perform validation on the numbers entered. Does this require a custom callback for the <code>CellFactory</code> in order to do this? If so, how can I develop a callback that accepts Number types and validates them?</p>
  
  <p>Here's a code snippet of what I currently have in my project:</p>
  
  <pre><code>@FXML private TableView&lt;BMIRecord&gt; fxBMITable;
  @FXML private TableColumn&lt;BMIRecord, String&gt; fxBMITableDate;
  @FXML private TableColumn&lt;BMIRecord, String&gt; fxBMITableTime;
  @FXML private TableColumn&lt;BMIRecord, Number&gt; fxBMITableHeight;
  @FXML private TableColumn&lt;BMIRecord, Number&gt; fxBMITableWeight;
  @FXML private TableColumn&lt;BMIRecord, Number&gt; fxBMITableBMI;
  
  // ...
  
  private void someFunc() {
      fxBMITable.setEditable(true);
  
      /* BMI table callback configuration */
      fxBMITableHeight.setCellValueFactory(new Callback&lt;CellDataFeatures&lt;BMIRecord, String&gt;, ObservableValue&lt;String&gt;&gt;() {
          public ObservableValue&lt;String&gt; call(CellDataFeatures&lt;BMIRecord, String&gt; p) {
              return new SimpleStringProperty(p.getValue().getDateString());
          }
      });
  
      /*
       * ERROR:
       * The method setCellFactory(Callback&lt;TableColumn&lt;BMIRecord,Number&gt;,TableCell&lt;BMIRecord,Number&gt;&gt;)
       * in the type TableColumn&lt;BMIRecord,Number&gt; is not applicable for the arguments
       * (Callback&lt;TableColumn&lt;Object,String&gt;,TableCell&lt;Object,String&gt;&gt;)
       */
      fxBMITableHeight.setCellFactory(TextFieldTableCell.forTableColumn());
      fxBMITableHeight.setOnEditCommit(new EventHandler&lt;CellEditEvent&lt;BMIRecord, Number&gt;&gt;() {
          @Override
          public void handle(CellEditEvent&lt;BMIRecord, Number&gt; t) {
              ((BMIRecord)t.getTableView().getItems().get(t.getTablePosition().getRow())).setHeight(t.getNewValue().doubleValue());
          }
      });
  }
  </code></pre>
  
  <p>Thanks for any help in advance.</p>