dimanche 17 mars 2019

How to use ViewModel when Model has JavaFX properties?

Here it is said that we have 2 options to implement MVVM with JavaFX - it depends whether we want to use JavaFX-Properties in our model or not.

As I understand if my model doesn't have javafx properties then I add fx properties to ViewModel. However, I can't understand what I should do if my model has fx properties. What should I do this case? Something like this:

class ViewModel {
   private ObjectProperty<Person> personProperty = new SimpleObjectProperty<>();
   ...
   personProperty.set(person);
}

or I should duplicate all the properties of the Person in ViewModel and bind every ViewModel property to Person properties, to get View -><- ViewModel -><- Model? Could anyone explain what to do this case?

Aucun commentaire:

Enregistrer un commentaire