1
我正在进军Griffon世界,并且我有一个小型的懒惰应用程序,我下载时会抛出错误。我的观点看起来像这样。Griffon-JavaFX:查看抛出有关模型的NPE
@ArtifactProviderFor(GriffonView)
class PennyPackerView {
FactoryBuilderSupport builder
PennyPackerController controller
PennyPackerModel model
void initUI() {
builder.application(title: application.configuration['application.title'],
sizeToScene: true, centerOnScreen: true, name: 'mainWindow') {
scene(fill: WHITE, width: 200, height: 60) {
gridPane {
label(id: 'clickLabel', row: 0, column: 0,
text: bind(model.clickCount))
button(row: 1, column: 0, prefWidth: 200,
controller.click())
}
}
}
}
}
的gradle使用后:奔跑,它抛出,导致我相信,我的模式没有被注入,至少在结合发生时的误差。
Warning, could not locate neither a JavaFX property nor a JavaBean property for class
javafx.scene.control.Label, property: '0'
[2014-10-20 13:30:56,166] [JavaFX Application Thread]
ERROR griffon.core.GriffonExceptionHandler
- Uncaught Exception
java.lang.NullPointerException: Cannot bind to null
at javafx.beans.property.StringPropertyBase.bind(StringPropertyBase.java:161)
at javafx.beans.property.Property$bind.call(Unknown Source)
at groovyx.javafx.factory.FXHelper$__clinit__closure26.doCall(FXHelper.groovy:454)
以下是型号代码,它不是非常复杂。
@ArtifactProviderFor(GriffonModel)
class PennyPackerModel {
@FXObservable String clickCount = "0"
}
任何帮助,为什么这个NPE被抛出或任何其他问题非常感激。我相信我从懒骨头获得的是griffon-javafx-groovy首发应用。
编辑:所以我一直在调试,它看起来像模型被注入,但设置绑定时出现问题。在StringPropertyBase类中,传递给它的newObservable的值为null。
public void bind(ObservableValue<? extends String> newObservable) {
if (newObservable == null) {
throw new NullPointerException("Cannot bind to null");
}
我不知道为什么发生这种情况,或如何解决它=(