Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[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
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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"));

View solution in original post

2 Replies
Anonymous
Not applicable
Author

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"));
Anonymous
Not applicable
Author

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