我尝试从selectManyListbox恢复项目时出错

时间:2011-07-15 14:45:02

标签: java jsf-2

我正在使用JSF2.0 / Primefaces,我使用了包含元素(项目名称)的selectManyListbox,我应该恢复这些元素并根据选择生成另一个selectManyListbox包含其他元素。

首先,我尝试填充我的第一个selectManyListbox并恢复选择的项目,但发生错误:

我的JSF:

    <h:selectManyListbox size="3"  value="#{TestAjax.selectedProjects} ">
      <f:selectItems value="#{TestAjax.getMyListProject()}" />
     </h:selectManyListbox>

我的豆子:

private List<String> selectedProjects; // + getter + setter
private List<SelectItem> MyListproject;

  public List<SelectItem> getMyListProject()  {
       FindProject fproj =new FindProject();
            if (MyListproject == null) {
            MyListproject = new ArrayList<SelectItem>();
            for (String val : fproj.FindListprojects()) { 
         MyListproject.add(new SelectItem(val));
       }
    }
 return MyListproject;
}

错误是:

javax.faces.FacesException: Target model Type is no a Collection or Array
at     com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:392)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:129)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:315)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

更新 问题已解决

这是一个小小的错误:size =“3”应该在value属性之后!

1 个答案:

答案 0 :(得分:0)

更新:问题已解决

这是一个奇怪的错误:size =“3”应该在value属性之后!