-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't access Viewmodel after Include. #190
Comments
Michael reported, that our ViewLoader does not construct the ViewModels of fx:include views. This is a serious bug. |
This sounds like a misconfiguration or some other special case because actually the usage of fx:include does work without problems. We have plenty examples that demonstrate this. For example the contacts-example consists of many sub views that are orchestrated via fx:include. There is also a test case that verifies exactly this use case with fx:include here. Anyway, I think the bug report is not directly related to this feature request. |
This has been a misunderstanding. I reported that I wanted exactly the behaviour as described in the original comment (i.e., get a viewmodel of a nested view injected into the parent view). |
The injection of the subview via the "controller" naming convention is done by JavaFX internals and not by mvvmFX. |
@lestard Sounds tuff, other ideas? |
The idea to enhance the ControllerFactory won't work because we don't know the fx:id in the controller factory method. Therefore we can't distinguish between viewmodels of the same type. |
To implement this feature we would need to patch the FXMLLoader. The FXMLLoader has inner classes for all types of elements that can occure in a fxml file. We would need to patch the "IncludeElement" class that can be found here. On line 1015 begins the code block that is responsible for the injection of the Controller class via the *Controller naming convention. Similar to this we would need to add our own naming convention for the viewModels. The FXMLLoader isn't marked as |
This issue has a similar idea to #215 |
Can't access Viewmodel after Include.
@FXML
private Node import_createPerson;
@FXML
private CreatePersonView import_createPersonController;
//SHOULD WORK --> Or other solution
@FXML
private CreatePersonViewModel import_createPersonViewModel;
The text was updated successfully, but these errors were encountered: