0 Replies Latest reply on Oct 6, 2012 11:36 AM by raorve

    How to pass a full array of Seam to Javascript

    raorve

      Hi all,

       

      I have an array in seam and I need use it in javascript, my java code

       

       

      @Name("seleccion")
      @Scope(ScopeType.SESSION)
      public class seleccion{
                private double[] Puntos;
                Puntos = {0,1,2,3};
      
                
                @WebRemote //this method dont work well because
               public double pass(int i) {        
                   return Puntos[i];
               }
      }
      

       

      my xhtml code

       

       

       <s:remote include="seleccion"/>
        
            <script type="text/javascript">
                
                var vector = new Array();
                 var i = 0;
      
                function move() {
                    while(i != 4){
                          Seam.Component.getInstance("seleccion").pass(i, callback);
                          i++;
                    }     
                    var callback = function(result) {
                           vector[i] = result;
                      
                    };          
                }        
            </script>
      

       

       

      that return a wrong arrange array

      vector = {1,3,2,0} due to "callback"

       

       

      How can pass the array to javascript?

       

      Thanks and sorry my bad English