0 Replies Latest reply on May 21, 2009 9:17 AM by Manish Prajapati

    Sending Javascript Nested Arrays object to seam remote method using seam remoting but getting NULL in remote method

    Manish Prajapati Newbie
      Hi All,

      I am trying to send Javascript Arrays containing Arrays to seam remote method but in seam remote method i am getting it NULL.

      Following is my code snippets:

      XHTML Code:
      <s:remote include="decisionTableManager"/>
      function testMe(){
           var columnAndRowArray=null;
           var columnsArray;
           theTable=document.getElementById("testform:datatable");
           var columns=theTable.tHead.rows[1];
           columnsArray=new Array(columns.cells.length);
           for(var i=0;i<columns.cells.length;i++){
                columnsArray[i]=columns.cells[i].textContent;
           }     
           var allRows=theTable.tBodies[0].rows;
           var rowsArray=new Array(allRows.length);
           var rowLength=allRows.length;
           for(var i=0;i<rowLength;i++)
           {
                var rows=new Array(allRows[i].cells.length);
                var cellsLength=allRows[i].cells.length-1;
                for(var j=1;j<cellsLength;j++)
                {
                     var hiddenFieldId="hidden"+i+j;
                     rows[j]=document.getElementById(hiddenFieldId).value;
                }
                rowsArray[i]=rows;
           }
           columnAndRowArray=new Array();
           columnAndRowArray[0]=columnsArray;
           columnAndRowArray[1]=rowsArray;
           alert(columnAndRowArray);
           var listMap=new Seam.Remoting.Map();
           listMap.put("columnList",columnsArray);
           listMap.put("rowList",rowsArray);
           Seam.Component.getInstance("testTableManager").testMe(listMap,callBack);
      //Here in place of listMap i have also tried by passing columnAndRowArray array and in testMe parameter type i put Object[] but in that case also i am getting NULL.
      }

      Interface :


      @Local
      public interface TestTableManager {
           @WebRemote
           public boolean saveToXLS(Map<String,Object[]> listMap);
           public void remove();
           
      }

      Concrete Class:


      @Stateful
      @Name("decisionTableManager")
      @Scope(ScopeType.SESSION)
      public class TestTableManagerBean implements TestTableManager   {     

           public boolean testMe(Map<String,Object[]> listMap){
                System.out.println("***** saveToXLS is called *****");
                System.out.println(listMap.size());
                System.out.println("****** Printing details *********");
                try {
                     String [] columns=(String[])listMap.get("columnList");
                     Object [] rows=(Object[])listMap.get("rowList");
                     
                     List<String> columnList=Arrays.asList(columns);
                     System.out.println("************Column List is as given below *********");
                     System.out.println(columnList);
                     List<List<String[]>> rowList=new ArrayList<List<String[]>>();
                     System.out.println("**** Each Rule List *****");
                     for(int i=0;i<rows.length;i++){
                          List<Object> eachRuleRowList=(List<Object>)Arrays.asList(rows[i]);
                          System.out.println(eachRuleRowList);
                     }
                } catch (Exception e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                }
                //saveColumns(columnsAndRowsArray);
                return true;
           }
      }


      Can anybody tell me how i can accomplish my goal of passing Javascript Array of Arrays to testMe() remote method and get Actual values instead of NULL.

      Thanks in advance.

      Thanks,
      Manish