Pagination Wicket自定义分页
我一直在尝试实现类似的功能 >> 有什么建议吗Pagination Wicket自定义分页,pagination,wicket,Pagination,Wicket,我一直在尝试实现类似的功能 >> 有什么建议吗 提前感谢…如果您正在DataView中查找分页,那么启用分页所需做的就是在DataView上调用setItemsPerPage(int) 检查以下示例JAVA代码 public class RepeatingPage extends BasePage { private static final long serialVersionUID = 1L; /** * Constructor */ p
提前感谢…如果您正在DataView中查找分页,那么启用分页所需做的就是在DataView上调用setItemsPerPage(int) 检查以下示例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++;
}
}
}
<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>
公共类RepeatingPage扩展了BasePage
{
私有静态最终长serialVersionUID=1L;
/**
*建造师
*/
公共重复页面()
{
迭代器联系人=新的ContactDataProvider()。迭代器(0,10);
RepeatingView repeating=新RepeatingView(“repeating”);
添加(重复);
int指数=0;
while(contacts.hasNext())
{
AbstractItem=newAbstractItem(repeating.newChildId());
重复。添加(项目);
Contact-Contact=contacts.next();
添加(新操作面板(“操作”,新的可拆卸联系人模型(联系人));
添加(新标签(“contactid”,String.valueOf(contact.getId())));
添加(新标签(“firstname”,contact.getFirstName());
添加(新标签(“lastname”,contact.getLastName());
添加(新标签(“homephone”,contact.getHomePhone());
添加(新标签(“手机”,contact.getmobile());
最终int idx=索引;
add(AttributeModifier.replace(“类”,新的AbstractReadOnlyModel()
{
私有静态最终长serialVersionUID=1L;
@凌驾
公共字符串getObject()
{
返回值(idx%2==1)?“偶数”:“奇数”;
}
}));
索引++;
}
}
}
HTML代码
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++;
}
}
}
<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>
行动
身份证件
名字
姓
家庭电话
手机
[行动]
[联系人ID]
[名字]
[姓氏]
[家庭电话]
[手机]
如果您需要在listView中分页,请检查请详细说明您正在尝试做什么,并提供一些您已经有的cod。