[英]Error after submitting data using <h:selectManyMenu> in JSF?
index.xhtml 的index.xhtml
<h:selectManyMenu style="height:70px" value="#{bookBean.selectedBook}">
<f:selectItems value="#{bookBean.books}"/>
</h:selectManyMenu>
<h:commandButton action="#{bookBean.doClick}" value="Submit" />
BookBean.java BookBean.java
List<SelectItem> books = new ArrayList<SelectItem>();
public List<SelectItem> getBooks() {
return books;
}
So, the problem is after I choose multiple items in the ManyMenu list and click the commandButton in xhtml file, it gives an error. 因此,问题出在我在ManyMenu列表中选择多个项目并单击xhtml文件中的commandButton之后,它给出了错误。 It says "Target model Type is no a Collection or Array"
它说“目标模型类型不是集合或数组”
What does that mean? 这意味着什么? I need to change List<> to any collection type?
我需要将List <>更改为任何集合类型吗?
The page suppose to display the items I selected in the first page. 该页面假定显示我在第一页中选择的项目。
This 这个
value="#{bookBean.selectedBook}">
has to be a collection. 必须是一个集合。
Think about it, you are selecting many items, so you have to store them in a collection. 想一想,您选择了许多项目,因此必须将它们存储在集合中。 Even if you are selecting one SelectItem then it has to be stored in a collection as well.
即使您选择一个SelectItem,也必须将其存储在一个集合中。
So, make sure .selectedBook is a collection. 因此,请确保.selectedBook是一个集合。 Regards!
问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.