-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Let's say i have a listbox that contain ten items, and then i set five items for every page, so now the listbox have two pages
and the problem is everytime i want to get the value in listbox it only get five items instead ten items.
im using ListItemRenderer on My Listbox
below is my code :
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);
}
});
}
below my code to get the value :
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);
}
}
}
If you will check this line
List<Listitem> lists = box.getItems();
So it will give all items of selected page... If you want to get the items you have to use below code..
ListModel model = box.getModel();
Asked: 2013-03-25 04:48:20 +0800
Seen: 98 times
Last updated: Apr 04 '13
composite component help [closed]
EL in a forEach @command not working?
Different template for each grid row
Cardlayout animation is broken
Grid RowRender slow using 6.5.1 and sizable=true
setVisible(false), component will load or not
Decimalbox and doublebox value rounded on iPad