Populating Arraylist from Dataset [message #1062070] |
Wed, 05 June 2013 12:44  |
Eclipse User |
|
|
|
Im trying to populate an ArrayList from my one of my Data Sets and then access that Arraylist in my html TextItem.
I currently have in Script: initialize
var contactsaddresses = new java.util.ArrayList();
reportContext.setPersistentGlobalVariable("contactsaddresses", contactsaddresses);
and in my DataSet Script: onFetch
var tempArray = reportContext.getPersistentGlobalVariable("contactsaddresses");
tempArray.add(row["Address String"]);
reportContext.setPersistentGlobalVariable("contactsaddresses", tempArray);
in my html TextItem:
<!DOCTYPE html><html> <script>
var locationarray = <value-of> reportContext.getPersistentGlobalVariable("contactsaddresses")
</value-of>;
for(i = 0;i<locationarray.length;i++) {
alert(locationarray[i]);
}
</script><body></body></html>
For testing purposes I commented out all the onfetch script, and in the intialize script I used var contactsaddresses = "[['Address String 1'], ['Address String 2']];"; instead of var contactsaddresses = new java.util.ArrayList(); and it worked.
I think my issue could be with my onfetch not updating the array properly or the array is not coming in the html textitem correctly since in testing i had to encapsulate my array with quotes.
Any help or direction is greatly appreciated.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04253 seconds