Skip to content
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

Load view via FXML Path #262

Open
sideisra opened this issue Jun 11, 2015 · 1 comment
Open

Load view via FXML Path #262

sideisra opened this issue Jun 11, 2015 · 1 comment

Comments

@sideisra
Copy link
Contributor

In some cases I need to load a view based on the FXML path because the FXML name and the view classes name are not identical.

At the moment I can load view tuples via FluentViewLoader#fxmlView or FluentViewLoader#javaView and I have to provide a class.

In my scenario I have a FXML file (some.fxml) and I have a view class with another name (MyView.java) so the name matching of FluentViewLoader will not work.

Possible solution:

  • provide a method in FluentViewLoader named fromFxml(String fxmlResourcePath) which can load the specified fxml and instantiate the view class which is specified by fx:controller.

My workaround at the moment:

FXMLLoader fxmlLoader = new FXMLLoader(fxmlPath);
fxmlLoader.setControllerFactory(controllerClass -> {
  final MyView view = new MyView();
  ViewLoaderReflectionUtils.createAndInjectViewModel(view);
  return view;
});
fxmlLoader.load();
@manuel-mauky manuel-mauky modified the milestones: 1.5.0, 1.4.0 Jun 17, 2015
@manuel-mauky manuel-mauky modified the milestones: 1.5.0, 1.4.0 Sep 8, 2015
@manuel-mauky manuel-mauky modified the milestones: 1.6.0, 1.5.0 Jun 1, 2016
@manuel-mauky manuel-mauky modified the milestones: 1.7.0, 1.6.0 Jan 23, 2017
@manuel-mauky
Copy link
Collaborator

This should be easy to add because internally we are already parsing the class-argument to a string path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants