title: Generic Javafx table view
body: <p>I am trying to create a method in my JAVAFX controller which will show the preview of the data in table view. That table view has to be generic enough so that it can just take a list of objects and display it into the table. Here is my code.</p>
  
  <p>In my controller i have TableView like this</p>
  
  <pre><code>@FXML
  private TableView dataPreviewTableView; 
  </code></pre>
  
  <p>Down below in the same controller i have a method like this</p>
  
  <pre><code>public void loadScreen(Class&lt;?&gt; T){
  
  TableColumn col;
  TableViewHeader headerInfo =getHeaderInfoFromTemplate(fileTemplate);
  List&lt;String&gt; headerNames = headerInfo.getHeaderNames();
  dataPreviewTableView.getItems().clear();
  
   for(String headerName : headerNames){
          col = new TableColumn (headerName.toUpperCase());
          col.prefWidthProperty().bind(dataPreviewTableView.widthProperty().divide(headerNames.size()));
          col.setCellValueFactory(new PropertyValueFactory&lt;**T,Integer**&gt;(headerName));
          dataPreviewTableView.getColumns().add(col);
      }   
   this.lblFileName.setText(fileToImport.getPath()); 
   dataPreviewTableView.setItems(data);
  
  }
  </code></pre>
  
  <p>The  following line gives an error <strong>T cannot be resolved to a type</strong></p>
  
  <pre><code>col.setCellValueFactory(new PropertyValueFactory&lt;T,Integer&gt;(headerName));
  </code></pre>