title: JavaFX 8 - How to declare a TableView row factory in FXML
body: <p>I have a fully functional row factory, done in java but I would like to (if possible) migrate it to my .fxml file associated with the controller. This is the working code that I currently have:</p>
  
  <pre><code>tableView.setRowFactory( tv -&gt; {
              TableRow&lt;Loan&gt; row = new TableRow&lt;&gt;();
              row.setOnMouseClicked( clickEvent -&gt; {  // If an item is clicked.
                  if ((clickEvent.getClickCount() == 1) &amp;&amp; (!row.isEmpty())) {    // Item was clicked once and the row is
                      // not empty
              });
              return row;
          });
  </code></pre>
  
  <p>Again, this works for my purposes (note that I removed what the factory does for ease of readability) but I feel like I'm not being consistent in my project by having <em>some</em> functions in the controller and some in the .fxml, it just feels wrong. I could not find anything regarding the declaration of a row factory and I hope someone out there has done it before. So far I have only done:</p>
  
  <pre><code>&lt;rowFactory&gt;
  
  &lt;/rowFactory&gt;
  </code></pre>
  
  <p>so I do know that there is something here to work with. But there does not seem to be any obvious choice for me to proceed such as "onMouseClicked" and so on.</p>
  
  <p>Please advise!</p>