for (var i = 0; i < f.numItems; i++){
l.value = l.value +"\n"+f.getItemAt(i, false);
arr[i] = [f.getItemAt(i,false), f.getItemAt(i)];}
arr.sort(compare);
f.setItems(arr);
The function set Items is in the ScriptableObject subclass . Current
implementation is like this - which adds native array object to my
text.
public void jsFunction_setItems(Object result)
{
if (result instanceof NativeArray) {
// Convert JavaScript array to Collection
NativeArray arr = (NativeArray) result;
int len = (int) arr.getLength();
List list = new ArrayList(len);
for (int i = 0; i < len; i++) {
Object obj = arr.get(i, arr);
Context.toObject(obj, arr);
if (obj == Context.getUndefinedValue()) {
obj = null;
}
list.add(obj);
}
Object[] arr1 = list.toArray();
for (int i = 0; i < arr1.length; i++) {
if (arr1[i] instanceof Object[]) {
Object[] arr2 = (Object[]) arr1[i];
jsFunction_insertItemAt(arr2[0].toString(), arr2[1]
.toString(), i);
} else {
jsFunction_insertItemAt(arr1[i].toString(), arr1[i]
.toString(), i);
}
}
}
}
Have you tried using Context.getElements?
--N
It still has array of nativeArray objects. I am not able to to the
actual data in it.
Thanks
It doesn't do a deep convert; you'll have to pass each element to
Context.getElements as well. Could those elements also be arrays? If
so, you'll have to take a different approach.
What are you trying to do?
--N
I can get an array of array from javascript. I have to get each
element at feed it to a listbox or combobox. That is why I need each
entry in the array. This array comes from an API called setItems on a
combobox and then I iterate thr' all items and insert them one by one.
Thanks