CompoundPropertyModelを使う

昨日のPageクラスをCompoundPropertyModelを使って書き直した。直したのはPageableListView#populateItem()のみ。

@Override
protected void populateItem(ListItem item) {
    Locale locale = (Locale) item.getModelObject();
    item.setModel(new CompoundPropertyModel(locale));
    item.add(new Label("index",
            String.valueOf(item.getIndex() + 1)));
    item.add(new Label("toString"));
    item.add(new Label("displayCountry"));
    item.add(new Label("displayLanguage"));
}

CompoundPropertyModelはwicket:idでプロパティ参照するらしいので、HTML側のwicket:idを上記のように変更した。
昨日のコードよりはだいぶスッキリ。