I'm trying to do scripting with Javascript in a Java program. I haven't found a way to iterate through a Java collection in Javascript. If I call the iterator() method for the collection, I get the method names instead of the elements.
Here's a sample code:
function getValue(row, components) {
var apartment = components.get(0);
var rooms = apartment.getRooms();
for (var room in rooms.iterator()) {
println(room);
}
return rooms.toString();
}
The apartment.getRooms() returns a collection of rooms. When I study the value returned by this function, I know that its content are correct, but the values that get printed are the method names.
I invoke the Javascript from my Java program like this:
getInvocable().invokeFunction("getValue", row, components);
getInvocable()? What libraries do you use? Edit your question