Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8117600

Default List properties behave differently than standard properties

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • None

      The difference is in List properties that also have a setter. Take example from RT-17714.

      The following FXML will call the handle method, as the items property in ListView contains the list constructed in the FXML:
      <?import java.lang.*?>
      <?import java.util.*?>
      <?import javafx.collections.FXCollections?>
      <?import javafx.scene.control.ListView?>

      <ListView fx:controller="collectioneventshandler.SampleController"
                         xmlns:fx="http://javafx.com/fxml">
          <items>
          <FXCollections fx:factory="observableArrayList"
                         onChange="#handleListChangeEvent">
              <String fx:value="ABC"/>
          </FXCollections>
          </items>
      </ListView>

      However, using the default property will just add the list content to the items property:
      <?import java.lang.*?>
      <?import java.util.*?>
      <?import javafx.collections.FXCollections?>
      <?import javafx.scene.control.ListView?>

      <ListView fx:controller="collectioneventshandler.SampleController"
                         xmlns:fx="http://javafx.com/fxml">
          <FXCollections fx:factory="observableArrayList"
                         onChange="#handleListChangeEvent">
              <String fx:value="ABC"/>
          </FXCollections>
      </ListView>

            msladecek Martin Sládeček
            msladecek Martin Sládeček
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: