Closed svedie closed 4 years ago
Sorry for the late reply. Reusing code with inheritance is not a good idea and mvvmFX is not intended to be used with inheritance. Instead you should use composition. If you have a reusable View/ViewModel you can use an instance of this View/ViewModel in your other Views/ViewModels. This way you can reuse several things in a single View/ViewModel which wouldn't be possible with inheritance (as Java doesn't support multi-inheritance).
Hi lestard,
after some implementation tests I have discarded this idea and did a redesign of the toolbars.
Thank you for your answer.
Hello lestard,
I have implemented a toolbar with default buttons for a dataset view. But some views have additional buttons. Here I extend the
View
andViewModel
from the default toolbar, add the specific implementation, but I get this error:Caused by: java.lang.RuntimeException: The View <class ToolbarKontoView> may only define one viewModel but there were <2> viewModel fields with the @InjectViewModel annotation!
Is there an way to inject the extended
ViewModel
instead the one from default toolbar? Or do I need to "duplicate" the code for the extended toolbar?Greetings