I want to ask you about model and ModelWrapper behavior. According to Wikipedia article about model component of MVVM:
Model refers either to a domain model, which represents real state content (an object-oriented approach), or to the data access layer, which represents content (a data-centric approach).
I was looking for ModelWrapper usage samples in mvvmFX documentation and examples, but I found only data access layer model sample. I need to use model classes with business logic. For example, changing class state in setter method (is the side effect usage a code smell here?):
public class ModelClass {
private int intField;
private String stringField;
public int getIntField() {
return intField;
}
public void setIntField(int intField) {
if (intField == 100) {
this.stringField = "";
}
this.intField = intField;
}
public String getStringField() {
return familyName;
}
public void setStringField(String stringField) {
this.stringField = stringField;
}
}
According to ModelWrapper documentation:
The user changes the values of the viewModel properties (via the UI). The state of the underlying model instance may not be changed at this point in time! When the user clicks an Apply button (and validation is successful) copy all values from the ViewModel fields into the model instance.
How to use such model classes, and not to implement the business logic twice (in the model class at the first time and in the ViewModel class at the second time)? Or maybe I have to move business-logic in other place?