Class ExternalControllerFxWeaver
Reasons to extend FxWeaver class.
- When using abstract class annotated with
FxmlViewthe controller is not set. - When using root fxml inside the fxml the root controller is not loaded.
Overrides method FxWeaver.load(Class, String, ResourceBundle) adding to FxmlLoader
- builder factory
- set the controller
- set the root
Builder factory is used for loading controllers defined as inner elements in fxml. If the class is annotated with FxmlView,
it uses this loader to load the controller.
When an abstract class is annotated with FxmlView but the controller is subclass of it the FxmlController
annotation is used to instantiate the controller.
If the controller class (subclass of the abstract) is not annotated with FxmlController, the FXMLLoader use the abstract class as a controller.
When the fxml is defined as fx:root the controller class has to be annotated with FxmlRoot.
- Author:
- Daniel MaĊĦek
-
Constructor Summary
ConstructorsConstructorDescriptionExternalControllerFxWeaver(org.springframework.context.ConfigurableApplicationContext context) Create ExternalControllerFXWeaver instance -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildFxmlReference(Class<?> c) Build a FXML view location reference for controller classes, based onFxmlViewannotation or simple classname.protected <C,V extends javafx.scene.Node>
net.rgielen.fxweaver.core.FxControllerAndView<C,V> load(Class<C> controllerClass, String location, ResourceBundle resourceBundle) Load controller instance, potentially weaved with a FXML view declaring the given class as fx:controller.Methods inherited from class net.rgielen.fxweaver.core.FxWeaver
getBean, load, load, loadController, loadController, loadController, loadController, loadView, loadView, loadView, loadView, shutdown
-
Constructor Details
-
ExternalControllerFxWeaver
public ExternalControllerFxWeaver(org.springframework.context.ConfigurableApplicationContext context) Create ExternalControllerFXWeaver instance- Parameters:
context- Spring context
-
-
Method Details
-
load
protected <C,V extends javafx.scene.Node> net.rgielen.fxweaver.core.FxControllerAndView<C,V> load(Class<C> controllerClass, String location, ResourceBundle resourceBundle) Load controller instance, potentially weaved with a FXML view declaring the given class as fx:controller.The possible FXML resource is inferred from a
FxmlViewannotation at the controller class or the simple classname and package of said class if it was not annotated like this. If the FXML file is resolvable, the defined view within will be loaded byFXMLLoader. The controller will then be instantiated based on the fx:controller attribute, using the bean factory fromFxWeaver(Callback, Runnable). If the bean factory is based on a dependency management framework such as Spring, Guice or CDI, this means that the instance will be fully managed and injected as declared.If the controller class does not come with a resolvable FXML view resource, the controller will be instantiated by the given bean factory directly.
- Overrides:
loadin classnet.rgielen.fxweaver.core.FxWeaver- Type Parameters:
V- The view typeC- The controller type- Parameters:
controllerClass- The controller class of which a weaved instance should be providedlocation- The location of the FXML view to load as a classloader resource. May benullor not resolvable, in which case the controller will be directly instantiated by the given bean factory.resourceBundle- The optionalResourceBundleto use for view creation. May benull- Returns:
- A
SimpleFxControllerAndViewcontainer with the managed instance of the requested controller and the corresponding view, if applicable - See Also:
-
FxWeaverFXMLLoader
-
buildFxmlReference
Build a FXML view location reference for controller classes, based onFxmlViewannotation or simple classname.- Overrides:
buildFxmlReferencein classnet.rgielen.fxweaver.core.FxWeaver- Parameters:
c- The class to build a FXML location for. If it does not contain aFxmlViewannotation to specify resource to load, it is assumed that the view resides in the same package, named {c.getSimpleName()}.fxml- Returns:
- a resource location suitable for loading by
Class.getResource(String)
-