1 Reply Latest reply on Feb 12, 2009 12:39 PM by Dhiraj Thakur

    arrayList problem with @WebRemote

    Dhiraj Thakur Newbie

      my method on server returns ArrayList  when i am iterating it on server it is showing only first object from arrayList


      server side code




      public List<Message> displayMessage() {
                System.out.println("displaymsg called");
                List<Message> msgList = new ArrayList<Message>();
                for (int i = 0; i < 10; i++) {
                     msgList.add(new Message("dhiraj"+i,"hi"+1,"raj"+1));
                }
                System.out.println(msgList.size());
                return msgList;
                
                
           }




      client side java script



                   var reply = function (data){
                          alert("size of data" + data.length);
                          
                          
                          for(var i = 0; i< data.length; i++){
                          var message = new Object();
                          message = data[i];
                          alert("msg is " + message.messageText);
                          
                          }
                          
                     }
                     
                     function displayMessage(){
                          
                          var test = Seam.Component.getInstance("chat");
                           test.displayUserMessage (reply); 

                                     }
            displayMessage();


        • 1. Re: arrayList problem with @WebRemote
          Dhiraj Thakur Newbie

          i forget to add i
          here is the changed version but still it is repeating first object
          i tried the same on dwr but there it worked every thing perfectly




               public List<Message> displayMessage() {
                    System.out.println("displaymsg called");
                    List<Message> msgList = new ArrayList<Message>();
                    for (int i = 0; i < 10; i++) {
                         msgList.add(new Message("dhiraj"+i,"hi"+i,"raj"+i));
                    }
                    System.out.println(msgList.size());
                    return msgList;
                    
                    
               }