Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

Wicket Custom Pagination

i have been trying to trying to implement something like

<< < (textbox) of (totalnumberofpages) > >>

any suggestions on this

Thanks in advance...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are looking for pagination in DataView then ,all you need to do to enable paging is to call setItemsPerPage(int) on the dataview.

Check following example JAVA code

    public class RepeatingPage extends BasePage
{
    private static final long serialVersionUID = 1L;

    /**
     * Constructor
     */
    public RepeatingPage()
    {
        Iterator<Contact> contacts = new ContactDataProvider().iterator(0, 10);

        RepeatingView repeating = new RepeatingView("repeating");
        add(repeating);

        int index = 0;
        while (contacts.hasNext())
        {
            AbstractItem item = new AbstractItem(repeating.newChildId());

            repeating.add(item);
            Contact contact = contacts.next();

            item.add(new ActionPanel("actions", new DetachableContactModel(contact)));
            item.add(new Label("contactid", String.valueOf(contact.getId())));
            item.add(new Label("firstname", contact.getFirstName()));
            item.add(new Label("lastname", contact.getLastName()));
            item.add(new Label("homephone", contact.getHomePhone()));
            item.add(new Label("cellphone", contact.getCellPhone()));

            final int idx = index;
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>()
            {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject()
                {
                    return (idx % 2 == 1) ? "even" : "odd";
                }
            }));

            index++;
        }
    }
}

HTML code

<wicket:extend xmlns:wicket="http://wicket.apache.org">
<br/><br/>

<table cellspacing="0" class="dataview">
    <tr>
        <th>Actions</th>
        <th>ID</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Home Phone</th>
        <th>Cell Phone</th>
    </tr>
    <tr wicket:id="repeating">
        <td><span wicket:id="actions">[actions]</span></td>
        <td><span wicket:id="contactid">[contactid]</span> </td>
        <td><span wicket:id="firstname">[firstname]</span></td>
        <td><span wicket:id="lastname">[lastname]</span></td>
        <td><span wicket:id="homephone">[homephone]</span></td>
        <td><span wicket:id="cellphone">[cellphone]</span></td>
    </tr>
</table>

</wicket:extend>

If you need pagination in listView then check for PageableListView


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...