I want to click a column and send the cell index to a new stage. But I can\'t pass my parameter (int clickIndex
) to another controller EditClientControlle
When moving from one controller to another(one view to another), you could initialize the EditClientController with the required parameters
Eg:
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("editClient.fxml"));
EditClientController ctrl = new EditClientController();
ctrl.setCellIndex(id);
fxmlLoader.setController(ctrl);
If you have specified the controller in the fxml file, the you could use:
editWrapper.getCurrentController().setCellIndex(id);
where editControllerWrapper is a class that loads the new view and has a method getCurrentController that returns an instance of javafx controller.
Eg: public class EditControllerWrapper {
private Parent root;
public EditControllerWrapper () {
try
{
FXMLLoader loader = new FXMLLoader(getClass().getResource("editClient.fxml"),
...
} catch (Exception e) {
...
}
}
public T getCurrentController () {
return loader.getController();
}