-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, one can use @FxView on a controller to link resources (fxml, css, bundles) to it which will be constructed on startup. Then inject FxViewRepository to access it, something like:
@FxView("login")
@Singleton
public class LoginController {
public void prepareLogin(){...}
}
@FxView("core")
@Singleton
public class CoreController {
@Inject FxViewRepository fxViewRepository;
@FXML BorderPane root;
@FXML
void initialize() {
if (!isLoggedIn()) {
var loginViewData = fxViewRepository.getViewData("login");
root.setCenter(loginViewData.getRootNode());
loginViewData.<LoginController>getController().prepareLogin();
}
}
}
or inject FXMLLoader to load the view on demand:
@FxView("core")
@Singleton
public class CoreController {
@Inject FXMLLoader fxmlLoader;
@FXML BorderPane root;
@FXML
void initialize() {
Parent loginRoot = fxmlLoader.load(getClass().getResourceAsStream("/login.fxml"));
root.setCenter(loginRoot);
fxmlLoader.<LoginController>getController().prepareLogin();
}
}
It would be nice to be able to inject FXMLLoader and bind it to a view using a qualifier (making @FxView a qualifier?), something like:
@FxView("core")
@Singleton
public class CoreController {
@Inject @FxView("login") FXMLLoader fxmlLoader;
@FXML BorderPane root;
@FXML
void initialize() {
Parent loginRoot = fxmlLoader.load();
root.setCenter(loginRoot);
fxmlLoader.<LoginController>getController().prepareLogin();
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request