Passing integer array from javascript to java
Hi Everyone,
I am having trouble passing an array between javascript and java.I am using DWR.
Demo.getData(userId,f1,f2,f3,CreateTable);
Demo is the java class I need to access and CreateTable is the fuction I need to pass my javascript arrays to.
f1,f2,f3 are my javascript arrays.
in Demo.java CreateTable is declared as :
public List CreateTable(int userId,int[] f1,int[] f2,int[] f3)
I need to pass the arrays of f1,f2 and f3 as Integer[] objects;
This is how I am trying to this:
Integer[] intObj = null;
if(f1!=null){
intObj = new Integer[f1.length];
for(int a=0;a<f1.length;a++){
intObj[a] = new Integer(filter[a]);
}
}
I have to then pass this to a hashmap:
HashMap<String,Integer[]> filters = new HashMap<String,Integer[]>();
filters.put("tagIds", intObj);
I get a java.lang.NullPointerException
However this works:
Integer[] tags = new Integer[]{1,2,3,4};
filters.put("tagIds",tags);
I am sure that the javascript array is being correctly passed to CreateTable()
Can some one point out what I am doing wrong?
Thanks,
Lavanya