Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf javax.faces.FacesException:的值必须是数组或集合_Jsf_Selectmanymenu - Fatal编程技术网

Jsf javax.faces.FacesException:的值必须是数组或集合

Jsf javax.faces.FacesException:的值必须是数组或集合,jsf,selectmanymenu,Jsf,Selectmanymenu,我得到一个错误: javax.faces.FacesException:“frmrapport:type”的值必须是数组或集合 从XHTML文件: <p:selectManyMenu id="type" required="true" value="#{userReporting.getTypeParId(userReporting.selected)[0].nomType}"> <f:selectItem itemLabel="co" itemValu

我得到一个错误:


javax.faces.FacesException:“frmrapport:type”的值必须是数组或集合

从XHTML文件:

<p:selectManyMenu id="type" required="true"
        value="#{userReporting.getTypeParId(userReporting.selected)[0].nomType}">
    <f:selectItem itemLabel="co" itemValue="co" />
    <f:selectItem itemLabel="pi" itemValue="pi" />
    <f:selectItem itemLabel="si" itemValue="si" />
</p:selectManyMenu>

问题是bean是一个
列表
,我无法将该列表转换为
字符串[]

用户报告。getTypeParId(userReporting.selected)
正在返回一个
列表
。您无法访问
List[0]
,必须使用
List\get(int index)

此外,请注意泛型:最好指定包含返回集合的内容,例如:

public List<Type> getTypeParId(int id){
     return this.genTypeFacade.getTypeParId(id);
}
public List getTypeParId(int-id){
返回此.genTypeFacade.getTypeParId(id);
}

另一个“还”:您的方法
getTypeParId
返回的类型多于1个?如果是,它应该被称为
getTypesParId

你的答案比我的正确,我最好删除我的答案。@hamena314你本可以让它,因为它回答了TO的问题;不是问题,而是问题:pjavax.faces.FacesException:“frmrapport:type”的值必须是数组或collection@MohamedNani这确实是个例外。也许你想用一句话来概括p如果你在英语方面有困难,你可以在评论中用法语解释(这个答案),我会更新你的问题。@hamena314好吧,他似乎真的想要一个列表,所以我将把它标记为一个副本:如果问题是“如何将列表转换为字符串[]”,它是一个副本,在互联网上很容易找到,等等。但我相信这不是你真正的问题。
value="#{userReporting.getTypeParId(userReporting.selected).get(0).nomType}"
public List<Type> getTypeParId(int id){
     return this.genTypeFacade.getTypeParId(id);
}