passing List type to subjob

One Star

passing List type to subjob

Hi all,
I am trying to pass a context variable of type ArrayList to a subjob.
To achive this, I have the following process:
- define context variable of type Object
- component tJavaRow is creating a ArrayList and assign it to the context variable
- to check if this works, I do a cast from the Object back to the ArrayList and print the values, all fine
- the context variable is passed to the subjob
- in the subjob the same cast as before is perofrmed, but this time fails with: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList
it seems that the context variable is not of type object anymore but of type String.
Thanks in advance for any help,
Wolfgang
Community Manager

Re: passing List type to subjob

Hello
but this time fails with: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList

In Talend, all the values of context var are stored in a file with String type. eg;
context.list=
So, define a context var with string type in the child job, and then, cut the string and split it to a string array.
eg:
on tJava of child job
String list=context.list.substring(1,(context.list.length()-1));
String listArray[]=list.split(",");

Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business