Hello,
I am trying to create a web page that lists contact addresses in a table.
My repeater can easily lay out one address per row, but I need to be able
to list 2 addresses per row (actually, ideally I'd like to list N
addresses per row). The problem is that ListView's operation
[populateItem()] only provides you with one item to work with. So with
this markup:
<html xmlns:wicket>
<body>
<wicket:panel>
<table wicket:id="addressesTable" style="width: 100%;">
<tr wicket:id="addresses">
<td wicket:id="address" style="width:
50%;"></td>
<!--
I NEED ANOTHER CELL LIKE THE
ONE ABOVE HERE
<td wicket:id="address2" style="width:
50%;"></td>
-->
</tr>
</table>
</wicket:panel>
</body>
</html>
If I uncomment the second cell above, I need to be able to access the
"next" item, something like:
final ListView<Address> rowContainer = new ListView<Address>(
"addresses", model) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<Address> item) {
Address a = item.getModelObject();
AddressPanel ap = new AddressPanel("address",
new CompoundPropertyModel<Address>(
new
AddressLoadableDetachableModel(a.getId())));
item.add(ap);
/*
// DOES SUCH AN API EXIST?
//
if (item.hasNext()) {
item.next();
a = item.getModelObject();
AddressPanel ap2 = new AddressPanel("address2",
new CompoundPropertyModel<Address>(
new
AddressLoadableDetachableModel(a.getId())));
item.add(ap2);
}
*/
}
};
My only solution currently is that I convert the list of addresses to a
list of address tuples (pairs), so that I am able to repeat over pairs of
addresses. In short, I am just wondering if there is a better way to do
this rather than (pseudocode):
List<Address> addresses = myRepository.loadAddressList();
List<Tuple<Address,Address>> addressPairs = convertToPairs(addresses);
// Make the above repeater iterate over "List<Tuple<Address,Address>>"
having access
// to two addresses per repetition
Any pointers on this? Thank you in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org