One Star

[resolved] t_Java and setting a global variable

I was wondering if anyone could help me figure out why this code does not work (it executes just does not do what I want it to).
I have a tMap that sends one row to a tJava transformation. The t_Java is designed to set a global variable with the following code:
System.out.println("Value Of Input:" + setVariable.varTOP);
globalMap.put("context.rowTOP", setVariable.varTOP);
System.out.println("Value Of Input:" + setVariable.varTOP);
System.out.println("Value of Global Var: "+(Integer) globalMap.get("context.rowTOP"));
I have added the println for validation. No matter what I send as input from the tMap to the tJava equation it results in 0 being displayed by all of the println's above. I have tried to manually set the value in my tMap as 1 and it still displays 0 in the tJava. I am on talend 4.2.2.
Anyone have any ideas?
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions

Re: [resolved] t_Java and setting a global variable

Hi ricepato
Connect a tjavarow to your tmap instead of a tjava.
tmap --main--> tjavarow
and using the following code in the tjavarow:
System.out.println("Value Of Input: "+input_row.varTOP);
globalMap.put("varTOP", input_row.varTOP);
System.out.println("Value Of GlobalVar: "+globalMap.get("varTOP"));
2 REPLIES

Re: [resolved] t_Java and setting a global variable

Hi ricepato
Connect a tjavarow to your tmap instead of a tjava.
tmap --main--> tjavarow
and using the following code in the tjavarow:
System.out.println("Value Of Input: "+input_row.varTOP);
globalMap.put("varTOP", input_row.varTOP);
System.out.println("Value Of GlobalVar: "+globalMap.get("varTOP"));
One Star

Re: [resolved] t_Java and setting a global variable

Yes, just figured that out actually. Thanks for the response though!