title: JavaFX ListProperty filter for combobox
body: <p>I have a ListProperty in which I load the application operator list from the database. I would like to display only the operators that have an active status in a ComboBox.</p>
  
  <p>I have tried to filter it when the ListProperty is modified, but when I only update the operator status it doesn't work. I have also tried to find a way to bind the operators list to a filteredList.</p>
  
  <p>There's my 2 models :</p>
  
  <blockquote>
    <p><em>Operator.java</em></p>
  </blockquote>
  
  <pre><code>/**
   * Model representing an operator in the application.
   *
   * @author Mathieu DARÉ
   */
  
  package com.dare.tkpf.esatraceability.model;
  
  
  import java.time.LocalDateTime;
  import java.time.format.DateTimeFormatter;
  
  import javafx.beans.property.IntegerProperty;
  import javafx.beans.property.ObjectProperty;
  import javafx.beans.property.SimpleIntegerProperty;
  import javafx.beans.property.SimpleObjectProperty;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.property.StringProperty;
  
  
  
  
  
  public class Operator {
  
  //
  // Attributes of the operator...
  //
      private IntegerProperty                IDProperty;
      private StringProperty                 firstNameProperty;
      private StringProperty                 lastNameProperty;
      private ObjectProperty&lt;OperatorStatus&gt; statusProperty;
      private ObjectProperty&lt;LocalDateTime&gt;  dateTimeAddedProperty;
      private StringProperty                 dateTimeAddedStringProperty;
  
  
  
  
  
      /**
       * Constructor of the Operator.
       *
       * @param ID            The operator's ID.
       * @param firstName     The operator's first name.
       * @param lastName      The operator's last name.
       * @param status        The operator's status.
       * @param datetimeAdded The date/time of when the operator has been added.
       */
      public Operator(int ID, String firstName, String lastName, OperatorStatus status, LocalDateTime dateTimeAdded) {
  
          this.IDProperty                  = new SimpleIntegerProperty(ID);
          this.firstNameProperty           = new SimpleStringProperty(firstName);
          this.lastNameProperty            = new SimpleStringProperty(lastName);
          this.statusProperty              = new SimpleObjectProperty&lt;OperatorStatus&gt;(status);
          this.dateTimeAddedProperty       = new SimpleObjectProperty&lt;LocalDateTime&gt;(dateTimeAdded);
          this.dateTimeAddedStringProperty = new SimpleStringProperty( dateTimeAddedProperty.get().format( DateTimeFormatter.ofPattern("'le' dd/MM/yyyy 'à' HH:mm:ss") ) );
  
      }
  
  
  
  //
  // Setter, getters for the operator's ID...
  //
  
      /**
       * Setter for the operator's ID.
       *
       * @param ID The ID of the operator.
       */
      public void setID(int ID) {
  
          this.IDProperty.set(ID);
  
      }
  
  
  
      /**
       * Getter for the operator's ID.
       *
       * @return The ID of the operator.
       */
      public int getID() {
  
          return this.IDProperty.get();
  
      }
  
  
  
      /**
       * Getter for the operator's ID property.
       *
       * @return The ID property of the operator.
       */
      public IntegerProperty IDProperty() {
  
          return this.IDProperty;
  
      }
  
  
  
  //
  // Setter, getters for the operator's first name...
  //
  
      /**
       * Setter for the operator's first name.
       *
       * @param firstName The first name of the operator.
       */
      public void setFirstName(String firstName) {
  
          this.firstNameProperty.set(firstName);
  
      }
  
  
  
      /**
       * Getter for the operator's first name.
       *
       * @return The first name of the operator.
       */
      public String getFirstName() {
  
          return this.firstNameProperty.get();
  
      }
  
  
  
      /**
       * Getter for the operator's first name property.
       *
       * @return The first name property of the operator.
       */
      public StringProperty firstNameProperty() {
  
          return this.firstNameProperty;
  
      }
  
  
  
  //
  // Setter, getters for the operator's last name...
  //
  
      /**
       * Setter for the operator's last name.
       *
       * @param lastName The last name of the operator.
       */
      public void setLastName(String lastName) {
  
          this.lastNameProperty.set(lastName);
  
      }
  
  
  
      /**
       * Getter for the operator's last name.
       *
       * @return The last name of the operator.
       */
      public String getLastName() {
  
          return this.lastNameProperty.get();
  
      }
  
  
  
      /**
       * Getter for the operator's last name property.
       *
       * @return The last name property of the operator.
       */
      public StringProperty lastNameProperty() {
  
          return this.lastNameProperty;
  
      }
  
  
  
  //
  // Setter, getters for the operator's status...
  //
  
      /**
       * Setter for the operator's status.
       *
       * @param status The status of the operator.
       */
      public void setStatus(OperatorStatus status) {
  
          this.statusProperty.get().setID( status.getID() );
          this.statusProperty.get().setDescription( status.getDescription() );
  
      }
  
  
  
      /**
       * Getter for the operator's status.
       *
       * @return The status of the operator.
       */
      public OperatorStatus getStatus() {
  
          return this.statusProperty.get();
  
      }
  
  
  
      /**
       * Getter for the operator's status property.
       *
       * @return The status property of the part.
       */
      public ObjectProperty&lt;OperatorStatus&gt; statusProperty() {
  
          return this.statusProperty;
  
      }
  
  
  
      /**
       * Getter for the operator's status description.
       *
       * @return The status description of the operator.
       */
      public String getStatusDescription() {
  
          return this.statusProperty.get().descriptionProperty().get();
  
      }
  
  
  
      /**
       * Getter for the operator's status description property.
       *
       * @return The status description property of the part.
       */
      public StringProperty statusDescriptionProperty() {
  
          return this.statusProperty.get().descriptionProperty();
  
      }
  
  
  
  //
  // Setter, getters for the date/time the operator has been added...
  //
  
      /**
       * Setter for the date/time the operator has been added.
       *
       * @param datetimeAdded The date/time the operator has been added.
       */
      public void setDateTimeAdded(LocalDateTime datetimeAdded) {
  
          this.dateTimeAddedProperty.set(datetimeAdded);
  
          this.dateTimeAddedStringProperty = new SimpleStringProperty( dateTimeAddedProperty.get().format( DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss") ) );
  
      }
  
  
  
      /**
       * Getter for the date/time the operator has been added.
       *
       * @return The date/time the operator has been added.
       */
      public LocalDateTime getDateTimeAdded() {
  
          return this.dateTimeAddedProperty.get();
  
      }
  
  
  
      /**
       * Getter for the date/time property of when the operator has been added.
       *
       * @return The date/time property of when the operator has been added.
       */
      public ObjectProperty&lt;LocalDateTime&gt; dateTimeAddedProperty() {
  
          return this.dateTimeAddedProperty;
  
      }
  
  
  
      /**
       * Getter for the date/time string property of when the operator has been added.
       *
       * @return The date/time string property of when the operator has been added.
       */
      public StringProperty dateTimeAddedStringProperty() {
  
          return this.dateTimeAddedStringProperty;
  
      }
  
  
  
  //
  // Utility methods...
  //
  
      /**
       * Method converting the model into a string describing the operator (For direct use in the UI).
       *
       * @return The string describing the operator.
       */
      @Override
      public String toString() {
  
          return getFirstName() + " " + getLastName();
  
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p><em>OperatorStatus.java</em></p>
  </blockquote>
  
  <pre><code>/**
   * Model representing an operator status in the application.
   *
   * @author Mathieu DARÉ
   */
  
  package com.dare.tkpf.esatraceability.model;
  
  
  import javafx.beans.property.IntegerProperty;
  import javafx.beans.property.SimpleIntegerProperty;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.property.StringProperty;
  
  
  
  
  
  public class OperatorStatus {
  
  //
  // Attributes of the operator status...
  //
      private IntegerProperty IDProperty;
      private StringProperty  descriptionProperty;
  
  
  
  
  
      /**
       * Constructor of the operator status.
       *
       * @param ID          The operator status' ID.
       * @param description The operator status' description.
       */
      public OperatorStatus(int ID, String description) {
  
          this.IDProperty          = new SimpleIntegerProperty(ID);
          this.descriptionProperty = new SimpleStringProperty(description);
  
      }
  
  
  
  //
  // Setter, getters for the operator status' ID...
  //
  
      /**
       * Setter for the operator status' ID.
       *
       * @param ID The ID of the operator status.
       */
      public void setID(int ID) {
  
          this.IDProperty.set(ID);
  
      }
  
  
  
      /**
       * Getter for the operator status' ID.
       *
       * @return The ID of the operator status.
       */
      public int getID() {
  
          return this.IDProperty.get();
  
      }
  
  
  
      /**
       * Getter for the operator status' ID property.
       *
       * @return The ID property of the operator status.
       */
      public IntegerProperty IDProperty() {
  
          return this.IDProperty;
  
      }
  
  
  
  //
  // Setter, getters for the operator status' description...
  //
  
      /**
       * Setter for the operator status' description.
       *
       * @param description The description of the operator status.
       */
      public void setDescription(String description) {
  
          this.descriptionProperty.set(description);
  
      }
  
  
  
      /**
       * Getter for the operator status' description.
       *
       * @return The description of the operator status.
       */
      public String getDescription() {
  
          return this.descriptionProperty.get();
  
      }
  
  
  
      /**
       * Getter for the operator status' description property.
       *
       * @return The description property of the operator status.
       */
      public StringProperty descriptionProperty() {
  
          return this.descriptionProperty;
  
      }
  
  
  
  //
  // Utility methods...
  //
  
      /**
       * Method converting the operator status to string.
       *
       * @return The description of the status.
       */
      @Override
      public String toString() {
  
          return getDescription();
  
      }
  
  }
  </code></pre>
  
  <p>And my data holder for the application in which I want to creat a filtered version of the operators list for use in a combobox :</p>
  
  <blockquote>
    <p><em>ESATraceabilityDataHolder.java</em></p>
  </blockquote>
  
  <pre><code>/**
   * Data holder of the application. Contains all the properties and observable data shared through the entire application.
   *
   * @author Mathieu DARÉ
   */
  
  package com.dare.tkpf.esatraceability;
  
  
  import javafx.beans.property.ListProperty;
  import javafx.beans.property.SimpleListProperty;
  
  import com.dare.tkpf.esatraceability.model.NomenclatureStatus;
  import com.dare.tkpf.esatraceability.model.Operator;
  import com.dare.tkpf.esatraceability.model.OperatorStatus;
  import com.dare.tkpf.esatraceability.model.Part;
  
  
  
  
  
  public class ESATraceabilityDataHolder {
  
  //
  // Instance of the data holder...
  //
      private static ESATraceabilityDataHolder instance = null;
  
  
  //
  // Reference toward the app DBMS...
  //
      private static ESATraceabilityDBMS dbms = ESATraceabilityDBMS.getInstance();
  
  
  //
  // Properties and observable values of the application...
  //
      private static ListProperty&lt;OperatorStatus&gt;     operatorStatuses     = null;
      private static ListProperty&lt;Operator&gt;           operators            = null;
      private static ListProperty&lt;Part&gt;               halfFinished         = null;
      private static ListProperty&lt;NomenclatureStatus&gt; nomenclatureStatuses = null;
  
  
  
  
  
  //
  // Constructor and base methods of the data holder...
  //
  
      /**
       * Constructor of the data holder.
       */
      private ESATraceabilityDataHolder() {
  
          // Retrieval of the base data from the database at launch...
          operatorStatuses     = new SimpleListProperty&lt;&gt;( dbms.getOperatorsStatuses() );
          operators            = new SimpleListProperty&lt;&gt;( dbms.getOperators() );
          halfFinished         = new SimpleListProperty&lt;&gt;( dbms.getHalfFinished() );
          nomenclatureStatuses = new SimpleListProperty&lt;&gt;( dbms.getNomenclatureStatuses() );
  
      }
  
  
  
      /**
       * Getter of the data holder instance.
       *
       * @return Instance of the data holder.
       */
      public static ESATraceabilityDataHolder getInstance() {
  
          // If the data holder doesn't exist yet, we instantiate it...
          if( instance == null ) { instance = new ESATraceabilityDataHolder(); }
  
          return instance;
  
      }
  
  
  
  //
  // Getters for the shared data of the application...
  //
  
      /**
       * Getter for the operator statuses list.
       *
       * @return The list of the operator statuses.
       */
      public ListProperty&lt;OperatorStatus&gt; getOperatorStatuses() {
  
          return operatorStatuses;
  
      }
  
  
  
      /**
       * Getter for the operators list.
       *
       * @return The list of all the operators.
       */
      public ListProperty&lt;Operator&gt; getOperators() {
  
          return operators;
  
      }
  
  
  
      /**
       * Getter for the half-finished list.
       *
       * @return The list of all the half-finished.
       */
      public ListProperty&lt;Part&gt; getHalfFinished() {
  
          return halfFinished;
  
      }
  
  
  
      /**
       * Getter for the nomenclature statuses' list.
       *
       * @return The list of the operator statuses.
       */
      public ListProperty&lt;NomenclatureStatus&gt; getNomenclatureStatuses() {
  
          return nomenclatureStatuses;
  
      }
  
  }
  </code></pre>
  
  <p>Thanks in advance.</p>