2013-03-26 75 views
0

比方說,我有一個包含10件商品列表框,然後我設置五個項目的每一頁,所以現在列表框中有無法從ZK列表框檢索值

兩頁,問題是,每次我想要獲得列表框中的值,它只能得到五個項目,而不是十個項目。

IM在我的列表框

下面

使用的ListItemRenderer是我的代碼:

AnnotationConfiguration config = new AnnotationConfiguration(); 
SessionFactory sessionFactory = config.configure().buildSessionFactory(); 

Session session = sessionFactory.openSession(); 
String str = "from Users"; 
Query q = session.createQuery(str); 

List<Users> user = q.list(); 
session.close(); 
sessionFactory.close(); 

list.setModel(new ListModelList<Users>(user)); 
list.setItemRenderer(new ListitemRenderer() { 

    @Override 
    public void render(Listitem item, Object data, int index) 
      throws Exception { 
     Users user = (Users) data; 
     item.setValue(user); 

     new Listcell(user.getUsername()).setParent(item); 
     new Listcell(user.getUserrole()).setParent(item); 
    } 
}); 

}

我下面的代碼來獲取值:

String name =""; 
String role =""; 

Users user = new Users(); 
Listbox box = (Listbox) list.getFellow("win").getFellow("list"); 
List<Listitem> lists = box.getItems(); 

//membaca setiap row yang ada pada list 
for(Listitem currentList : lists){ 

    List<Component> com = currentList.getChildren(); 

    //membaca setiap column pada row 
    for (Component currentComp : com){ 
     Listcell lc = (Listcell) currentComp; 
     if(lc.getColumnIndex() == 0){ 
      name = lc.getLabel(); 
      System.out.println("name = " + name); 
     } 

     if(lc.getColumnIndex()==1){ 
      role = lc.getLabel(); 
      System.out.println("role = " + role); 
     } 
    } 

} 
+1

因爲你的一個新的,以這樣:如果有人awnsers您的問題請,如果妳喜歡awnser給予好評,能否解決你的問題接受,如果它需要改進寫評論,如果是nonsens downvote和評論。泰 – 2013-03-27 14:59:35

回答

1

這是正確的行爲。正如你所描述的,這個清單是ViewView
從來沒有超過5 Items

你想得到Model所以得到Model

ListModelList lists = (ListModelList)box.getModel();