JSFタグh:selectManyListboxを使用して、Beanからの項目のリストを表示します。JSF selectManyListboxは値バインディングのエラーを表示します
<h:selectManyListbox value="#{settingsBean.statusIds}" style="width: 100%; height: 200px;">
<f:selectItem value="#{settingsBean.statusItems}" />
</h:selectManyListbox>
statusItemsオブジェクトは、次のBeanクラスで定義されています
:SettingsBean.javaこれをロードするときに
public class SettingsBean {
private List<String> statusIds;
private List<SelectItem> statusItems;
public SettingsBean() {
initStatus();
}
private void initStatus() {
statusItems = new ArrayList<SelectItem>();
statusItems.add(new SelectItem("v1", "lbl1"));
statusItems.add(new SelectItem("v2", "lbl2"));
statusItems.add(new SelectItem("v3", "lbl3"));
}
public ArrayList getStatusItems(){
return getStatusItemsList(false);
}
@SuppressWarnings("unchecked")
private ArrayList getStatusItemsList(boolean selected) {
ArrayList ids = new ArrayList();
if (!selected) {
boolean inSelIds = false;
for (int i=0; i < statusItems.size(); i++) {
inSelIds = false;
SelectItem item = (SelectItem)statusItems.get(i);
if (selected==inSelIds) {
String text = item.getLabel();
//ids.add(text);
ids.add(new SelectItem(item.getValue(), text));
}
}
}
return ids;
}
}
しかし、私はエラーメッセージを取得しています
HTTP Status 500 - java.lang.IllegalArgumentException: Value binding '#{settingsBean.statusItems}' of UISelectItem : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /jsp/Settings.jsp][Class: javax.faces.component.html.HtmlSelectManyListbox,Id: _id3][Class: javax.faces.component.UISelectItem,Id: _id4]} does not reference an Object of type SelectItem
この問題は何が原因で発生するのでしょうか?あなたの助けをありがとう
それはあなたの代わりに他の –