John John - 22 days ago 5
Java Question

Wicket and Java: CheckGroup contains a null model object

Im getting this error:

CheckGroup contains a null model object, must be an object of type java.util.Collection

Im not sure what is causing this issue, nor can anyone in my team resolve this.

Ive had to redact this as it contains business related items.

Java:

Form<?> form = new Form<Object>("myform");
add(form);
CheckGroup<?> checkGroup = new CheckGroup<Object>("checkgroup");
form.add(checkGroup);
checkGroup.add(new CheckGroupSelector("groupselector"));
listView = new ListView<info>("listView", sessionObject.getList())
{
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<info> item)
{
item.add(new Check("recordSelected", item.getModel()));
item.add(new Label("IDListItem", new PropertyModel<String>(item.getModel(), "Number")));
}
};
checkGroup.add(listView);


HTML:

<table wicket:id="checkgroup">
<tr>
<td width="20"><input wicket:id="groupselector" type="checkbox" /></td>
<td width="80"><b>Number</b></td>
</tr>
<tr wicket:id="listView">
<td width="20"><input wicket:id="recordSelected" type="checkbox" /></td>
<td width="80"><span wicket:id="IDListItem"></span></td>
</tr>
</table>

Answer

Looks like you are following an example from wicketstuff.org. But that example is incomplete as it doesn't pass a model to CheckGroup. Igor Vaynberg mentioned in the Wicket user forums, that a compound model was used [1].

So pass a model and you'll be fine.