Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Wicket 6 ListItem add CSS

$
0
0
Hey

I'm trying to add a css class to a <tr> field inside a ListView.

Here is the code

add(new ListView<FinanceAccount>("financeAccounts", new
FinanceAccountListModelWithSum()) {
@Override
protected void populateItem(ListItem<FinanceAccount> itemOuter)

FinanceAccount fa = itemOuter.getModelObject();
itemOuter.add(new Label("accountNumber",
fa.getAccountNumber()));
itemOuter.add(new Label("accountName", fa.getName()));

switch (fa.getFinanceAccountType()) {
case PROFIT:
case EXPENSE:
case ASSET:
case LIABILITY: {
itemOuter.add(new Label("sum", fa.getSum()));
break;

case HEADLINE: {
itemOuter.add(new
AttributeAppender("class","test"));
itemOuter.add(new Label("sum", ""));
break;

case SUMFROM: {
//TODO calculate sum
itemOuter.add(new Label("sum", ""));
break;

});

And the markup

<table class="table table-condensed">
<tr>
<th>
<wicket:message key="account.number"></wicket:message>
</th>
<th>
<wicket:message key="account.name"></wicket:message>
</th>
<th>
<wicket:message key="account.sum"></wicket:message>
</th>
</tr>
<span wicket:id="financeAccounts">
<tr>
<td>
<span wicket:id="accountNumber"></span>
</td>
<td>
<span wicket:id="accountName"></span>
</td>
<td>
<span wicket:id="sum"></span>
</td>
</tr>
</span>
</table>

All that happens is that it creates a lot of <span> surrounding the <tr>
elements. Is it not possible to add a class directly to the <tr> element?

Med venlig hilsen / Best regards

Tommy Sadiq Hinrichsen

Viewing all articles
Browse latest Browse all 5648

Trending Articles