Get value From ListBox

asked 2013-03-25 04:48:20 +0800

kleponboy gravatar image kleponboy flag of Indonesia
54 5

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();

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

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

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

                role = lc.getLabel();
                System.out.println("role = " + role);

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-04 07:06:18 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8

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();
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2013-03-25 04:48:20 +0800

Seen: 83 times

Last updated: Apr 04 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More