I'm using Talend for an integration, I'm wondering it is it possible to pass data from tJavaRow
to tJava
components.
For example:
tJavaRow
component:
String check = input_row.foo;
if( check.contains("Yes")){
String ret = "OK";
return ret;
}
tJava
component:
System.out.println(ret);
Is there a way to print ret
, which is a result of a computation of a previous component inside a next component?
The solution is to use the globalMap
or a tSetGlobalMap
globalMap.put("ret", ret);
and recover it with
globalMap.get("ret");
/!\ IMPORTANT /!\
But note that if you use a tJava
in a main flow like
tRowGenerator > row1 > tJava > row2> tLogRow
tRowGenerator
generating 10 rows for 1 to 10 tJava
like System.out.println("foo");
tLogRow
print the numeric valueThe output will be
foo
1
2
3
4
5
6
7
8
9
10
The code in tJava
is only executed once before the first row is even generated. Checking the generated code, you can see
System.out.println("foo");
....
for(int i = 0; i < 10; i++){
logrow.print(i);
}