Wicket and DataView

You have a table and you want to populate it.

        <th>A num</th>
    <tr wicket:id="anumlst">
        <td wicket:id="anum"></td>

Also you have a pojo

public class Anum implements IClusterable {

    private String anum;

    public String getAnum() {
        return anum;

    public void setAnum(String anum) {
        this.anum = anum;

And then you can populate the table. On this one i use ListDataProvider

    private List<Anum> anums = new ArrayList<Anum>();

    DataView anumlst = new DataView("anumlst",new ListDataProvider(anums)) {
            protected void populateItem(Item item) {
                item.add(new Label("anum",((Anum)item.getModelObject()).getAnum()));

Thus you populate the table.
You can also make your own dataprovider (For example a dataprovider fetching data through hibernate).

Plus with dataview you can have easy paging.

You can Just add a PagingNavigator (or an AjaxPagingNavigator in case of a modal window)

Just after the end of the table tag add

<span wicket:id="pager">/span>

and at the java class

PagingNavigator pagingNavigator = new PagingNavigator("pager", anumlst);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s