Wicket 和 Java:CheckGroup 包含空模型对象
我收到此错误:
CheckGroup 包含一个空模型对象,必须是 java.util.Collection 类型的对象
我不确定是什么导致了此问题,我的团队中的任何人也无法解决此问题。
我必须对此进行编辑,因为它包含与业务相关的项目。
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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来您正在遵循 wicketstuff.org 中的示例。但该示例并不完整,因为它没有将模型传递给 CheckGroup。 Igor Vaynberg 在 Wicket 用户论坛中提到,使用了复合模型 [1]。
所以通过一个模型就可以了。
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.
尝试使用虚拟模型,例如
检查组 checkGroup = new CheckGroup
Javadoc 说:
,但我看不到在代码中创建此默认模型集合的位置...
Try using a dummy model e.g.
CheckGroup<?> checkGroup = new CheckGroup<Object>("checkgroup", new ArrayList<Object>());
Javadoc says:
when using 1-arg constructor, but I don't see where this default model collection is created in the code...
您应该将模型设置在使用位置。
示例代码:
You should set the model in use place.
example code: