This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • A Simple DataView Example
Skip to end of metadata
Go to start of metadata

This does assume you have a "Base Page".

Sub1Page.java
import java.io.Serializable;
import java.util.ArrayList;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

public class Sub1Page extends BasePage {

    public Sub1Page() {
        
        Contact contact = null;
        ArrayList list = new ArrayList();

        char character;
        
        // a - z
        for (int i = 97; i < 123; i++) {
            character = (char) i;
            contact = new Contact(String.valueOf(character));
            list.add(contact);
        }
        
        final DataView dataView = new DataView("simple", new ListDataProvider(
                list)) {
            public void populateItem(final Item item) {
                final Contact user = (Contact) item.getModelObject();
                item.add(new Label("id", user.getId()));
            }
        };

         dataView.setItemsPerPage(10);
        
        add(dataView);

        add(new PagingNavigator("navigator", dataView));
    }

}

class Contact implements Serializable {

    private final String id;

    public Contact(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

}
Sub1Page.html
<wicket:extend>

<table cellspacing="0" class="dataview">
    <tbody>
       <tr wicket:id="simple">
         <td><span wicket:id="id">Test ID</span></td>
       </tr>
    </tbody>
</table>

<div wicket:id="navigator"></div>

</wicket:extend>