小门定制分页 [英] Wicket Custom Pagination

查看:106
本文介绍了小门定制分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试实现

<< < (文本框),共(totalnumberofpages)> >>

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

关于此的任何建议

预先感谢...

推荐答案

如果您正在DataView中寻找分页,那么启用分页所需要做的就是在数据视图上调用setItemsPerPage(int).

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.

检查以下示例 JAVA 代码

    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 代码

<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>

如果您需要在listView中进行分页,请检查

If you need pagination in listView then check for PageableListView

这篇关于小门定制分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆