0

在问一个问题之前,我想说标题没有给出清晰的画面。我的问题非常具体,因此无法框定标题。所以放一个无关紧要的标题。此外,我发现 Jgoodies with List Binding 但它没有提供以下场景所需的更好信息。

问题:

我有面板,它是标签、文本字段和组合框的列表。该列表是静态的,即它由 8 个这样的组合组成。我创建了一个模型,它扩展了 ListInfoBean 的 PresentationModel 。这个 ListBean 是一个 InfoBean 的列表。每个 InfoBean 由标签值、TextField 值和 ComboBox 值组成。

在控制器中,我想将标签列表、文本字段和组合框列表的视图(面板与标签、文本字段和组合框对应的每个 InfoBean 绑定。下面是绑定的代码片段。

PresentationModelBinder binder = Binders.binderFor(model); //model is member of controller
binder.bindBeanProperty(InfoBean.LABEL_PROPERTY).to(label); //This results an exception because binder is bind with model and model is extends to ListInfoBean not InfoBean. so its says LABEL_PROPERTY is not present in ListInfoBean. 

我也检查了 SeletionInListBean。据我了解,它与组合框或列表中的选择有关。但我的情况不同。任何想法或帮助都会非常有用。

class InfoBean extends Bean {
public static final String LABEL_PROPERTY = "label";
public static final String TEXT_PROPERTY = "text";
public static final String COMBOBOX_PROPERTY = "ComboxBox";
private String label;
private String text;
private String ComboxBox;

public void setLabel(String label) {
String oldValue = this.label;
this.label = label;
firePropertychange(LABEL_PROPERTY, oldValue , label);
}
//Similarly for text and ComboBox as well.
}
4

0 回答 0