2014-06-27 90 views
-3

我一直在努力試圖實現(totalnumberofpages)提前類似檢票自定義分頁

< < <(文本)> >>

任何建議,這個

謝謝..

+0

請解釋更多你所想做並提供一些你已經擁有的鱈魚。 – Martin

回答

1

如果您在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++; 
     } 
    } 
} 

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的分頁然後檢查PageableListView