Darkwing
Darkwing

Reputation: 314

Value of must be an array or a collection (javax.servlet.ServletException)

I am getting javax.faces.FacesException: Value of 'groupList 'must be an array or a collection error. I've googled for it, but I still don't get an idea as for me it seems I have a collection: it is List, also i see in debugger that it is populated.

form.xhtml:

<p:selectManyCheckbox id="groupList" value="">
    <f:selectItems value="#{formBean.groups}"/>
</p:selectManyCheckbox>

formBean.java:

...
private List<String> groups;

...
public void initFormBean()
{
    groups = repository.getAllGroups(); // debugger info: groups = (java.util.ArrayList) "size = 138"
}

...
public List<String> getGroups() {
    return groups;
}

public void setGroups(List<String> groups) {
    this.groups = groups;
}

Upvotes: 1

Views: 2056

Answers (1)

Buurman
Buurman

Reputation: 1984

I'm guessing you need to bind the value of the checkbox by setting the value-attribute of the p:selectManyCheckbox tag. That way it has somewhere to store which of the possible items have been selected.

See also http://www.tutorialspoint.com/jsf/jsf_selectmanycheckbox_tag.htm

Upvotes: 3

Related Questions