I’am using JSF2.0/Primefaces,I have used selectManyListbox that contain elements(projects names),I should recuperate those elements and generate according to the choice another selectManyListbox contain other elments.
First I have tried to fill my first selectManyListbox and recuperate the choosen items but an error occure :
My JSF:
<h:selectManyListbox size="3" value="#{TestAjax.selectedProjects} ">
<f:selectItems value="#{TestAjax.getMyListProject()}" />
</h:selectManyListbox>
My Bean:
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;
}
the error is :
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)
UPDATE:
problem Resolved
it was a weard mistake : size=”3″ should be after the value attribute!
PDATE: problem Resolved
it was a weard mistake : size=”3″ should be after the value attribute!