hi
for my application i am loading ui from fxml. i have multiple part application. and each part is as below
Part1 | Part2
personabstractpart.java (part) | PersonDetailedInfoPart.java (part)
personabstractpart.fxml (ui-> built using javafx 8) | PersonDetailedInfoPart.fxml (ui-> built using javafx 8)
personabstractpartcontroller.java (controller for fxml) | PersonDetailedInfoPartcontroller.java (controller for fxml)
now i want to use ESelectionService in my controller class. as below
@FXML
private TableView<Person> personTable;
@Inject
private ESelectionService selectionService;
...
@FXML
private void initialize() {
personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
@Override
public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) {
selectionService.setSelection(newValue);
System.out.println("set: " + newValue);
}
});
.
.
.
}
my controller class is not able to inject selection service here.
Question is
(a) is it possible to inject selectionService/controllerclass using ContextInjectionFactory? i don't know what(controller/service) i should inject and where(view/controller) i should inject and is it recommended?
(b) (i) so what currently i am doing is loading fxml and after that i am fetching my controlls from root of fxml and adding listener to my tableview. is this recommended?
root = FXMLLoader.load(PersonAbstractPart.class.getResource("PersonAbstractPart.fxml"));
AnchorPane box=(AnchorPane)root;
parent.setTop(box);
Node splitpane = box.getChildren().get(0);
SplitPane spnode = (SplitPane)splitpane;
Node anchornode = spnode.getItems().get(0);
AnchorPane anchorPane = (AnchorPane)anchornode;
personTable=(TableView<Person>)anchorPane.getChildren().get(0);
.
.
.
personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
@Override
public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) {
selectionService.setSelection(newValue);
System.out.println("set: " + newValue);
}
});
(ii) can i make my view to be controller? --> in view class @FXML is not fetching the controls after loading the fxml. and can't use easily as i can use in controller class.
any help appreciated.
Thanks,
Milan