You are not logged in.

#1 2010-05-18 12:37:09

nicolasdiogo
Member
455 posts

set variable in context with tJava fails when using tContextDump

hi,

i have a child package that needs to check for folders and return these found directories as variables to the parent package, using:
tContextDump -> tBufferOutput

the problem comes when setting the values for these variables.
i have a tJava that sets values for these variables as:
context.variableA = "c:/some_folder/";

i have a tFileExists that checks for the existence of this folder - and returns true

but when using tContextDump this very same variable returns the value <null>

how is that possible.

it seems to be the same issue raised on this other forum topic:
http://www.talendforge.org/forum/viewtopic.php?id=4761


is there some work around this problem???

thanks,

Nicolas

Offline

#2 2010-06-07 01:27:55

alevy
Member
1922 posts

Re: set variable in context with tJava fails when using tContextDump

I can't any more find where I came up with this answer but apparently context values are stored in more than one place and tContextDump picks up only those values defined when the job begins so if you set context values dynamically using tJava you need to follow with the following statement so that tContextDump will use the new values:

context.synchronizeContext();

Offline

#3 2010-06-07 14:12:31

nicolasdiogo
Member
455 posts

Re: set variable in context with tJava fails when using tContextDump

Many thanks Alevy,

i will try your suggestion.

Offline

#4 2010-10-03 14:35:33

SMaz
Member
188 posts

Re: set variable in context with tJava fails when using tContextDump

alevy wrote:

I can't any more find where I came up with this answer but apparently context values are stored in more than one place and tContextDump picks up only those values defined when the job begins so if you set context values dynamically using tJava you need to follow with the following statement so that tContextDump will use the new values:

context.synchronizeContext();

THANKS!  I've been going around in circles with this for the last 24 hours.

This needs to be a sticky post - or - better yet - they need to add that one line of code to the tContextDump component.
But, in case someone actually wants it to work that way, just add a Synchronize checkbox to the Basic Settings.

Offline

#5 2010-10-15 17:12:15

pedro4l
Member
3 posts

Re: set variable in context with tJava fails when using tContextDump

Thank you very much for that answer, it is 4 hours i am fighting with forwarding context from child to parent and was not able to do it because of that context.synchronizeContext()...
This post should be awarded !
thanks again

Offline

#6 2012-12-21 10:17:11

ICR
Member
1 post

Re: set variable in context with tJava fails when using tContextDump

This post saves my life the 2012-12-21 (le 21 dec-2012) Isnt it paradoxal ?

Offline

Board footer

Talend Contributor Agreement - Talend Website Privacy Policy