title: JavaFX 8: TableView Filtering & Row Removal
body: <p>Please pardon the chunk of codes below, i'm presenting them for clarity. Thanks!</p>
  
  <p>I have a table view control [suiteCasesSelected] of type [TestSuiteDetail] that has the following functions:<br></p>
  
  <p><li> filter function that I got from this tutorial: <a href="http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/" rel="nofollow noreferrer">JavaFX 8 TableView Sorting and Filtering</a><br></p>
  
  <pre><code>//Triggered every time I type something on the filter box
  private void filterTestSuiteSelectedList() {
      // Wrap the ObservableList in a FilteredList (display all data).
      FilteredList&lt;TestSuiteDetail&gt; filteredData = new FilteredList&lt;&gt;(mainApp.getTestSuiteSelectedData(), p -&gt; true);
  
      // Set the filter Predicate whenever the filter changes.
      suiteSelectedFilter.textProperty().addListener((observable, oldValue, newValue) -&gt; {
          filteredData.setPredicate(tc -&gt; {
              // Display all if filter is empty
              if (newValue == null || newValue.isEmpty()) {
                  return true;
              }
              // Compare test case name or module name
              String lowerCaseFilter = newValue.toLowerCase();
              if (tc.getTestCaseName().toLowerCase().contains(lowerCaseFilter)) {
                  return true;
              } else if (tc.getModuleName().toLowerCase().contains(lowerCaseFilter)) {
                  return true;
              }
              return false;
          });
      });
  
      // Wrap the FilteredList in a SortedList.
      SortedList&lt;TestSuiteDetail&gt; sortedData = new SortedList&lt;&gt;(filteredData);
  
      // Bind the SortedList comparator to the TableView comparator.
      sortedData.comparatorProperty().bind(suiteCasesSelected.comparatorProperty());
  
      // Add sorted and filtered data to the table.
      suiteCasesSelected.setItems(sortedData);
  }
  </code></pre>
  
  <p><li> remove items from the list via button press:</p>
  
  <pre><code>@FXML
  private void handleRemoveFromSelectedClicked() {
      ObservableList selectedItems = suiteCasesSelected.getSelectionModel().getSelectedItems();
      if (selectedItems != null) {
          suiteCasesSelected.getItems().removeAll(selectedItems);
          mainApp.saveSuiteDetailsSelectedXMLData(testSuite);
          TestNGXmlConverter.updateTestSuiteXMLFile(testSuite.getTestSuiteName());
      }
  }
  </code></pre>
  
  <p><b>My problem:</b><br>
  Every time I select items from the table and click the remove '&lt;&lt;' button, I get multiple exceptions starting from </p>
  
  <pre><code> Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  </code></pre>
  
  <p>and finally ending at </p>
  
  <pre><code> Caused by: java.lang.UnsupportedOperationException
  at java.util.AbstractList.remove(Unknown Source)
  at java.util.AbstractList$Itr.remove(Unknown Source)
  at java.util.AbstractCollection.removeAll(Unknown Source)
  at cl.oe.beatrix.view.ControllerWindowMain.handleRemoveFromSelectedClicked(ControllerWindowMain.java:2043)
  ... 70 more
  </code></pre>
  
  <p>Line 2043 points to <code>suiteCasesSelected.getItems().removeAll(selectedItems);</code> presented above.</p>
  
  <p><b>Additional Info:</b>
  <li> I'm calling the entire filter method <code>filterTestSuiteSelectedList()</code> on the <code>initialize()</code> method of the controller class.
  <li> The exception only happens if I put in the filter function in place. It works fine if I comment it out.</p>
  
  <p>Appreciate the help! Please do let me know if further information is needed!</p>
  
  <p><a href="https://i.stack.imgur.com/D5kOj.png" rel="nofollow noreferrer">Table snapshot</a></p>