Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] how to iterate through ArrayList?

Hi,
I have an ArrayList I set in a tJavaFlex component
globalMap.put("list",list);
I can read the "global" value ie:
(java.util.List)globalMap.get("list")
I wander how I can iterate through x, y, then z, based on (java.util.List)globalMap.get("list")
iteration?
thanks in advance for any help.
JNB
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello
You can aslo use tLoop to iterate each value of list. see my screenshots.
Best regards
shong

View solution in original post

9 Replies
Anonymous
Not applicable
Author

I managed to iterate the list values that way
In a tJava component
Object ia[] = ((java.util.List<String>)globalMap.get("list")).toArray();
for(int k=0; k<ia.length; k++) {
context.val = context.val + ia<K> + ";";
}
Then I can process
tFixedFlowInput->tNormalize ... and iterate through each value of my initial arrayList.
I'm not sure it's the best way to do it but that works.
JNB
Anonymous
Not applicable
Author

Hello
You can aslo use tLoop to iterate each value of list. see my screenshots.
Best regards
shong
Anonymous
Not applicable
Author

Hi. This is similar to the scenario I am trying to develop, except instead of a tJava component, I want to feed each element of the List into a tMap. How do I arrange this? Can't seem to get the flows right to get myself access into the tMap.
i.e. something like
tLoop => . . . => tMap (for each element)
Thanks!
Anonymous
Not applicable
Author

Hi. This is similar to the scenario I am trying to develop, except instead of a tJava component, I want to feed each element of the List into a tMap. How do I arrange this? Can't seem to get the flows right to get myself access into the tMap.
i.e. something like
tLoop => . . . => tMap (for each element)
Thanks!

Hi
I am sure the code in tJava should also work in tMap, if you can't get the job work, please upload a screenshot of job.

Best regards
Shong
Anonymous
Not applicable
Author

Apologies for the late response; thanks Shong for your reply. It all worked out as you suggested. 0683p000009MACn.png
Anonymous
Not applicable
Author

Hi
I have scenario to iterate through Arraylist .I have list of customercode where i should check the custcode with the table if it exist it should go to the if condition there i m creating a temporary table to do bulk updation,if it doesn't exist it has to go to else part.
how can i solve this issue? i am facing problem while iterating a list.
Anonymous
Not applicable
Author

This tutorial might help. It was written to demonstrate how to replicate the "Connect By" Oracle functionality in Talend. But the first component receives data as an ArrayList and iterates through the list using a tJavaFlex. Take a look ( https://www.rilhia.com/tutorials/talend-connect-example).
Anonymous
Not applicable
Author

Hi Shong, 

 

Are you able to share me your screen shot. 

 

Kind Regards

 

Rits

Anonymous
Not applicable
Author

Hi Shong, 

 

Are you able to share me your screen shot. 

 

Kind Regards

 

Rits