【发布时间】:2013-01-07 11:40:01
【问题描述】:
我正在使用 wicket 来显示表格列表。表的数量和每个表中的行数都是动态的。
我试图保持简单,并为每个使用 RepeatingView,并将它们嵌套,但检票口说:
java.lang.IllegalArgumentException: id 为“table”的孩子已经存在
这是我的 Java:
RepeatingView view = new RepeatingView("listoftables");
for (CCSubscription sub: getCustomer().getSubscriptions()) {
//resource balance table
ResourceBalance[] resBals = sub.getResourceBalances();
if(resBals!=null && resBals.length>0) {
ListView<ResourceBalance> resBalTable = new ListView<ResourceBalance>("table", Arrays.asList(resBals)) {
@Override
protected void populateItem(ListItem<ResourceBalance> item) {
ResourceBalance bal = item.getModelObject();
item.add(new Label("resource", bal.getResource().getName()));
item.add(new Label("balance", bal.getBalance()));
}
};
view.add(resBalTable);
} //end if sub has non-null resource balance
} //end loop through subscriptions
add(view);
我的 html 是:
<ul>
<li wicket:id="listoftables">
<fieldset>
<legend><b>Resource Balances</b>
</legend>
<table class="dataview" style="width:50%">
<thead>
<tr class="headers">
<th>Resource</th>
<th>Balance</th>
</tr>
</thead>
<tr wicket:id="table">
<td>
<span wicket:id="resource"></span>
</td>
<td>
<span wicket:id="balance"></span>
</td>
</tr>
</table>
</fieldset>
<br/>
我承认我可能会以错误的方式解决这个问题,但我看不出正确的方式应该是什么。
希望有人能帮忙!?
【问题讨论】:
标签: java listview html-table wicket