FXBean Adapter

FXBeanAdapter reflects changes of bean properties to the UI and vice versa.

It automatically creates bidirectional bindings to any bean.On bean update old bindings are cleared and new bindings for the new bean are created.

Example

Define Adapter

@FXML
var personBox: VBox = _

Add Bindings and Converter

override def didGainVisibilityFirstTime(): Unit = {
  super.didGainVisibilityFirstTime()

  val bindings = KeyBindings("id", "name", "age", "test")
  // Expression Binding Example
  bindings.add("person", "${sf:i18n('personText', _self.name(), _self.age())}")

  adapter.addBindings(bindings)

  adapter.addIntConverter("age")

  personBox.visibleProperty().bind(adapter.hasBeanProperty)
}

def items: ObservableList[FXBean[Person]] = PersonFactory.personList

Change Adapter items

def selectPerson(person: FXBean[Person]): Unit = {
  adapter.set(person)
}

def actionRevert(event: ActionEvent): Unit =
  adapter.revert()