my code was working in javafx 2.1.1 but not in 2.2
Basically gerLoader will get the loader I set into the controller when the controller is first initialized.
The Exception appears when load() is called.
Code:
getLoader().setControllerFactory(new Callback<Class<?>, Object>() {
@Override
public Object call(Class<?> clazz) {
System.out.println("callback : class=" + clazz.getName());
if (BaseController.this.getClass() == clazz) {
return BaseController.this;
} else {
try {
Constructor c = clazz.getConstructor();
return c.newInstance();
} catch (Exception ex) {
Logger.getLogger(BaseController.this.getClass().getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
});
tempStackPane = (Pane) getLoader().load();
Exception:
Root value already specified.
...
at javafx.fxml.FXMLLoader.createElement(FXMLLoader.java:2362)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2311)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
at com.sxgrp.javafx.common.controller.BaseController.reloadPane(BaseController.java:310)
at com.sxgrp.javafx.common.controller.BaseController.reloadChangedLocalePane(BaseController.java:320)
at com.sxgrp.pos.sxposclient.fxmlcontrollers.MainController.onSelect(MainController.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1435)
...
Basically gerLoader will get the loader I set into the controller when the controller is first initialized.
The Exception appears when load() is called.
Code:
getLoader().setControllerFactory(new Callback<Class<?>, Object>() {
@Override
public Object call(Class<?> clazz) {
System.out.println("callback : class=" + clazz.getName());
if (BaseController.this.getClass() == clazz) {
return BaseController.this;
} else {
try {
Constructor c = clazz.getConstructor();
return c.newInstance();
} catch (Exception ex) {
Logger.getLogger(BaseController.this.getClass().getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
});
tempStackPane = (Pane) getLoader().load();
Exception:
Root value already specified.
...
at javafx.fxml.FXMLLoader.createElement(FXMLLoader.java:2362)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2311)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
at com.sxgrp.javafx.common.controller.BaseController.reloadPane(BaseController.java:310)
at com.sxgrp.javafx.common.controller.BaseController.reloadChangedLocalePane(BaseController.java:320)
at com.sxgrp.pos.sxposclient.fxmlcontrollers.MainController.onSelect(MainController.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1435)
...