动态填充 Griffon 应用程序中的组合框
我的 Griffon App(或 groovy swingBuilder)视图中有 2 个组合框。
country = comboBox(items:country(), selectedItem: bind(target:model, 'country',
value:model.country), actionPerformed: controller.getStates)
state = comboBox(items:bind(source:model, sourceProperty:'states'),
selectedItem: bind(target:model, 'state', value:model.state))
控制器中的 getStates(),根据所选国家/地区在模型中填充 @Bindable List states = []。
上面的代码没有给出任何错误,但状态从未被填充。
我将状态从 List 更改为范围对象(虚拟),它给我一个错误 MissingPropertyException No such property items for class java.swing.JComboBox。
我在这里错过了什么吗? Nabble 上有几个与此相关的条目,但没有任何内容是明确的。如果我有一个标签而不是第二个组合框,上面的代码就可以工作。
I have 2 comboBoxes in my View of Griffon App (or groovy swingBuilder)
country = comboBox(items:country(), selectedItem: bind(target:model, 'country',
value:model.country), actionPerformed: controller.getStates)
state = comboBox(items:bind(source:model, sourceProperty:'states'),
selectedItem: bind(target:model, 'state', value:model.state))
The getStates() in the controller, populates @Bindable List states = [] in the model based on the country selected.
The above code doesn't give any errors, but the states are never populated.
I changed the states from being List to a range object(dummy), it gives me an error MissingPropertyException No such property items for class java.swing.JComboBox.
Am I missing something here? There are a couple of entries related to this on Nabble but nothing is clear. The above code works if I had a label instead of a second comboBox.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信 items: 属性是不可观察的,它仅在构建节点时使用。通过在模型上设置绑定或使用 GlazedLists 的 EventList 可能会获得更好的结果。
I believe that the items: property is not observable and it's only used while the node is being built. You may have better results by setting the binding on the model or by using GlazedLists' EventList.
型号:
控制器:
视图:
Model:
Controller:
View: