Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
n999
Contributor II
Contributor II

override context variables in java

Hi

 

Not sure if this is the case in DI jobs as well, but it seems that if you want to override the value of a context variable using Java in a cConfig in a Route, you HAVE to do this:

 

context.variable1 = "new value";

and that this

 

context.setProperty("variable1", "new value");

will not work, even though the code compiles and runs.....

 

I would like to iterate through a separate collection of context variable names and values and set them programmatically, so I can't do this using the  context.variable1 = "new value"; approach. I need to be able to pass in name, value pairs...

 

Is there anyway of overriding context variables in the way I would like to do?

 

thanks

 

n

Labels (2)
3 Replies
Anonymous
Not applicable

Hi n999
I see you mentioned in another topic that you are able to override the context variable with with the following code
//override context_param value
context_param.setProperty(name, value);
//refresh talend context with context_params
readContextValues(contextStr);

Let me know if you still have any issue on this subject.

Regards
Shong
n999
Contributor II
Contributor II
Author

yes - thanks for the reply.

 

I guess my only concern is how supported is this approach - 

 

* using context_param

* calling readContextValues()

 

- in future versions after 6.4 and beyond?

 

There is also the option to load up properties from files, into the camel context. And I think accessing the apache context is possible from any component using ether the {{var}} notation or "camelContext.resolvePropertyPlaceholders("{{var}}")?

 

Which would you recommend/support?

n999
Contributor II
Contributor II
Author

Hi Shong

Would still be very interested to know what Talend would officially support re my last post?

Cheers

n