Wicket and DataView

You have a table and you want to populate it.

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

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)) {
            
            @Override
            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);
Advertisement

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.