Released mvvmFX 1.1.0

mvvmfxjavajavafx

Yesterday we released the new version 1.1.0 of mvvmFX. This time we have lots of new features that can make the development of JavaFX applications easier.

Some of the new features:

Commands

The most interesting new feature are the Commands. With them you can now encapsulate actions in the ViewModel and provide them to the View. Each Command has boolean properties showing if it is running at the moment and if it isExecutable. The latter can for example be used in the View to bind the visibility of a button. With CompositeCommands you can compose many commands so that all sub-commands are executed when the composite command is triggered. See the wiki page for a detailed explanation.

ModelWrapper

The second big feature is the ModelWrapper. This class can simplify the mapping between the Model and the ViewModel for CRUD like applications. Instead of duplicating the fields of a model class in the ViewModel you can now use the ModelWrapper that support reloading (copy values from Model to ViewModel), resetting (set ViewModel to default values) and committing (copy values from ViewModel to Model). In the wiki you can see a detailed example.

Using mvvmFX views as items of ListView

You can now use the CachedViewModelCellFactory as CellFactory for the javaFX ListView component. This way you can use mvvmFX Views as items of the ListView. See a more detailed description in the wiki: https://github.com/sialcasa/mvvmFX/wiki/ListView-containing-mvvmFX-views.

Inject ResourceBundle in the ViewModel

Until now it was only possible to inject the ResourceBundle in the View. But for some use cases it would be useful to have the ResourceBundle available in the ViewModel too. With the new version this is possible via the annotation @InjectResourceBundle. In addition we have added a live cycle method for the ViewModel like it was possible in the View before. We use the same naming conventions for this: If the ViewModel has a method with the signature public void initialize() it will be called by the framework after the injection of the ResourceBundle is done.

public void MyViewModel implements ViewModel {
    @InjectResourceBundle
    ResourceBundle resourceBundle;

    private StringProperty title = new SimpleStringProperty();

    public void initialize() {
        title.setValue(resourceBundle.getString("app.title"));
    }
    ...
}

Utility modules

Additionally we have introduced two more Maven modules:

mvvmfx-utils contains utilities that are not directly related to MVVM but that are more generally useful for JavaFX development. We moved the SizeBindingsBuilder and the ListenerManager from the core module to this new module to improve the cohesion of the core module.

mvvmfx-testing-utils contains utils that we used for testing purposes internally for some time. Now these utils are available for the public. The most interesting is the GCVerifier that we are using for testing situations where Garbage Collection is important.

See the whole list of changes at github: https://github.com/sialcasa/mvvmFX/releases/tag/mvvmfx-1.1.0