<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Referencing context variables in a tJava component in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Referencing-context-variables-in-a-tJava-component/m-p/2242339#M29204</link>
    <description>Hi
&lt;BR /&gt;You have loaded the context value with tContextLoad component, and then you are able to use the context variable later in any other components. I don't think you need to put it into a global variable. For example:
&lt;BR /&gt;tFileInputProperties--main--tContextload
&lt;BR /&gt; |
&lt;BR /&gt;OnSubjobOK
&lt;BR /&gt; |
&lt;BR /&gt;other subjob (such as tJava)
&lt;BR /&gt;on Other subjob, you can use context variable and get its value by: context.varName; For example, a snippet code on tJava:
&lt;BR /&gt;String name=context.name;
&lt;BR /&gt;System.out.println(name);
&lt;BR /&gt;Best regards
&lt;BR /&gt;Shong</description>
    <pubDate>Tue, 14 Aug 2012 03:19:43 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-08-14T03:19:43Z</dc:date>
    <item>
      <title>Referencing context variables in a tJava component</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Referencing-context-variables-in-a-tJava-component/m-p/2242338#M29203</link>
      <description>I did not see an easier way to share context variables throughout a job including custom Java code.  Please post if you have a better solution.  I load my context variables from a properties file, but had trouble getting those values from inside my tJava component, so this is how I resolved it:&lt;BR /&gt;Insert a tJavaRow component between the tFileInputProperties file which reads the properties file, and the tContextLoad component which creates the context and loads it with values from the properties file.  &lt;BR /&gt;In the tJavaRow component, the snippet below loads values by key to the global map for use later by other tJava components:&lt;BR /&gt;//sets output row for consumption by tContextLoad&lt;BR /&gt;output_row.key=input_row.key;&lt;BR /&gt;output_row.value=input_row.value;&lt;BR /&gt;//creates key/value pair for use later in Java components&lt;BR /&gt;globalMap.put(input_row.key, input_row.value);&lt;BR /&gt;I hope this helps someone&lt;BR /&gt;--mike.blizman@housolutions.net</description>
      <pubDate>Mon, 13 Aug 2012 15:48:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Referencing-context-variables-in-a-tJava-component/m-p/2242338#M29203</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-13T15:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing context variables in a tJava component</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Referencing-context-variables-in-a-tJava-component/m-p/2242339#M29204</link>
      <description>Hi
&lt;BR /&gt;You have loaded the context value with tContextLoad component, and then you are able to use the context variable later in any other components. I don't think you need to put it into a global variable. For example:
&lt;BR /&gt;tFileInputProperties--main--tContextload
&lt;BR /&gt; |
&lt;BR /&gt;OnSubjobOK
&lt;BR /&gt; |
&lt;BR /&gt;other subjob (such as tJava)
&lt;BR /&gt;on Other subjob, you can use context variable and get its value by: context.varName; For example, a snippet code on tJava:
&lt;BR /&gt;String name=context.name;
&lt;BR /&gt;System.out.println(name);
&lt;BR /&gt;Best regards
&lt;BR /&gt;Shong</description>
      <pubDate>Tue, 14 Aug 2012 03:19:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Referencing-context-variables-in-a-tJava-component/m-p/2242339#M29204</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-14T03:19:43Z</dc:date>
    </item>
  </channel>
</rss>

