
Anonymous
Not applicable
2009-06-19
09:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to access a Java variable?
Hi,
I've got a tJava and set a variable String var1 = "test";
Now I want to access this variable somewhere else, for example in a MsgBox or what else.
How can I access it?
globalMap.get("tJava_1_...");
There is only ERROR_MESSAGE .. _1_currentPath doesn't work either.
Can someone help me?
Thank you.
I've got a tJava and set a variable String var1 = "test";
Now I want to access this variable somewhere else, for example in a MsgBox or what else.
How can I access it?
globalMap.get("tJava_1_...");
There is only ERROR_MESSAGE .. _1_currentPath doesn't work either.
Can someone help me?
Thank you.
555 Views
9 Replies

Anonymous
Not applicable
2009-06-21
08:33 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to use the globalMap map variable or create a context variable and use that. The scope of the tJava components is limited. You need a global scoped variable.
555 Views

Anonymous
Not applicable
2009-06-21
11:07 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Frist, you need to set it to a global var. eg:
String var1="test";
globalMap.put("varName",var1);
then, use this var like this:
(String)globalMap.get("varName")
Best regards
shong
Frist, you need to set it to a global var. eg:
String var1="test";
globalMap.put("varName",var1);
then, use this var like this:
(String)globalMap.get("varName")
Best regards
shong
555 Views

Anonymous
Not applicable
2009-06-22
03:56 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
it works within one job, but when I call tRunJob and try to System.out.println the variable in the childjob I see: null
For the tRunJob I've choose to: Transmit whole content.
What do I have to do if I want to pass this variable to a child?
Bye, Chris
it works within one job, but when I call tRunJob and try to System.out.println the variable in the childjob I see: null
For the tRunJob I've choose to: Transmit whole content.
What do I have to do if I want to pass this variable to a child?
Bye, Chris
555 Views

Anonymous
Not applicable
2009-06-22
05:51 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The globalMap instance is specific to a job, transmitting the context to a child job wont changes this.
If you intent to transmit a variable to child job, use the context then, it should be straitforward.
If you intent to transmit a variable to child job, use the context then, it should be straitforward.
555 Views

Anonymous
Not applicable
2009-06-22
06:04 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Existing two way to manage variable and parameter in a talend job.
1) globalMap is used to set variable in a Job, it's a hashmap
2) context var is used to set parameters
So, to achieve your goal,
1) you need to create context var in your childjob
2) With the tRunJob, use the context param tab, create a row, select the childjob context var in the first column, and set your expresion in the second one : globalMap.get("MyVar")
the transmit whole context checkbox is only for to transmit value of context var with same name from fatherjob to childjob.
Existing two way to manage variable and parameter in a talend job.
1) globalMap is used to set variable in a Job, it's a hashmap
2) context var is used to set parameters
So, to achieve your goal,
1) you need to create context var in your childjob
2) With the tRunJob, use the context param tab, create a row, select the childjob context var in the first column, and set your expresion in the second one : globalMap.get("MyVar")
the transmit whole context checkbox is only for to transmit value of context var with same name from fatherjob to childjob.
555 Views

Anonymous
Not applicable
2009-06-22
06:21 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Eventually I got it .. I tried so hard to set a context in my fatherjob, I didn't get the idea to setup a context in the childjob!
Thank you for your help!
Thank you for your help!
555 Views

Specialist III
2011-01-25
07:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
How Can I share the global map between father an son job. I see that it's possible using context. In fact I have lots of parameters , so It will be hard to create a context variable for each parameter.
Thanks for your replay
James
How Can I share the global map between father an son job. I see that it's possible using context. In fact I have lots of parameters , so It will be hard to create a context variable for each parameter.
Thanks for your replay
James
555 Views

Contributor III
2020-01-29
09:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to do it for long data dype
555 Views

Creator II
2020-01-29
09:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
https://www.talendbyexample.com/talend-returning-values-from-subjobs.html
This is a technique for passing data down into, and back up from, child jobs. We use it a lot. We have a joblet that checks to see if context.sharedMap is initialized, and if not, creates a new ConcurrentHashMap. This joblet is placed at the start of every job that uses the context.sharedMap mechanism.
555 Views
