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
Added utility class for loading fxml views #363
Conversation
Oh just forgot to tell you something, I posted a question on the google groups forums. I have a small problem concerning the process of updating a progress bar from other view models (and not only from the view/viewmodel that contains the progress bar). |
Hi, |
Just a small question: Is it possible to notify a view from a view model that is not bound to the view? For example, I want to notify the view from the add contact dialog by calling a method from the view model of the about dialog (some extreme example here). Or is this somehow against the design? |
|
||
public static <V extends FxmlView<VM>, VM extends ViewModel> void load(Class<V> viewClass, Class<VM> viewModelClass, | ||
Stage parentStage, String title, String... css) { | ||
load(viewClass, viewModelClass, parentStage, title, true, (String[]) null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bug in line 34. (String[])null
needs to be css
.
Hi, Getting a reference to the Stage of a view is a valid requirement.
In mvvmFX we typically have the approach to inject other things that are needed. For example in the View you can inject the ViewModel instance and the ResourceBundle with specific annotations. Additionally we should think about the actual use cases for this. The only real usage I can think of is showing dialogs. For this we already have issues: #171, #331. In this process we should could think about a good API for using dialogs with MVVM. Now to the second part your pull request, the The general idea is ok but instead of creating overloaded methods we should create a fluent API for this use case. |
I agree. Fluent api sounds great. The name was just a place holder for myself. The api that I created was a prototype. I wrote it in less than 5 minutes to make it work. It was more about the idea. There are probably two ways to implement this:
Would really like to hear back :) |
I totally agree with you that an API for dialogs needs a way of defining modal dialogs. For this we need the primary stage. The helper class in the example app doesn't provide such functionallity as it isn't a general API (yet). I really appreciate your feedback and help. But first we should discuss a suitable API in the #331 thread. Maybe we can use the existing dialog helper from the example and improve it somehow so that a primary stage can be used? |
Sure, I am fine with that. I will post new ideas on #331 later on today. Gonna take a look at the helper class. |
Some time ago I created a small utility class that was capable of loading and setting the stage up for a fxml view. It might help out other people so I created a pull request. The code is documented but not the methods itself.