You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a view that gets loaded via the FluentViewLoader and contains a @InjectContext annotation because this view has to load another view. When loading the view i pass an existing view model instance to the FluentViewLoader which inhibits the injection of the context into the view. As a result the context field is null when loading the sub view.
I debugged through the code and identified ControllerFactoryForCustomViewModel as the most likely cause. This Factory injects the context when the custzom view model hasn't been injected in a prior call. So in the first call the context doen't get injected into the view.
private static class ControllerFactoryForCustomViewModel implements Callback<Class<?>, Object> {
...
@Override
public Object call(Class<?> type) {
Object controller = DependencyInjector.getInstance().getInstanceOf(type);
if (controller instanceof View) {
View codeBehind = (View) controller;
if (!customViewModelInjected) {
ResourceBundleInjector.injectResourceBundle(customViewModel, resourceBundle);
ResourceBundleInjector.injectResourceBundle(codeBehind, resourceBundle);
ViewLoaderReflectionUtils.injectViewModel(codeBehind, customViewModel);
customViewModelInjected = true;
return codeBehind; // returns the code behind without context injected
}
handleInjection(codeBehind, resourceBundle, context); //happens only in subsequent calls
}
return controller;
}
}
The text was updated successfully, but these errors were encountered:
I have a view that gets loaded via the
FluentViewLoader
and contains a@InjectContext
annotation because this view has to load another view. When loading the view i pass an existing view model instance to the FluentViewLoader which inhibits the injection of the context into the view. As a result the context field is null when loading the sub view.FluentViewLoader.fxmlView(viewType).context(context).viewModel(vm).load()
I debugged through the code and identified
ControllerFactoryForCustomViewModel
as the most likely cause. This Factory injects the context when the custzom view model hasn't been injected in a prior call. So in the first call the context doen't get injected into the view.The text was updated successfully, but these errors were encountered: