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
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. It says “Target model Type is no a Collection or Array”
What does that mean? I need to change List<> to any collection type?
The page suppose to display the items I selected in the first page.
This
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.
So, make sure .selectedBook is a collection.
Regards!