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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using JAVA Code for Default Context

Hi,
I use a parameter for my Job(it's OK) , but for the default value, I would like to have a today date (which is JAVA code) , and so the user doesn't enter every time. How can I do to indicate (syntaxe) for the Default value that is the JAVA code.
Thanks in advance for your help.
tle
Labels (3)
4 Replies
Anonymous
Not applicable
Author

This isn't exactly what you're asking for but if you're working with databases you can always ask the database for the current time. Adda DBInput component and you're ready. At least that's the way I do that so far.
Anonymous
Not applicable
Author

You can also avoid using a db query :
try with a single line tJava component at the beginning of your job, such as :
context.setProperty("yourDateContextParameter", routines.TalendDate.getDate("yyyyMMdd"));
Hope this helps
Anonymous
Not applicable
Author

Hi,
Thanks a lot for all help, but using db query is not exactly that I want. I have try with context.setProperty.
I can use both contexts of the Job and tJava component.
It's OK, but the context.setProperty don't accept integer value and I have set string value for my date .Do you know another way to have integer value ? . It's my screenshot.
tle
Anonymous
Not applicable
Author

Using java and context values, I admit you only can use String values, since 'contextValue' is a 'Properties' type variable
So why not set your "datecontrol" context parameter as an int ?
Then you can read it with : Integer.parseInt(((String)context.getProperty("datecontrol"))).intValue()
And you still can write it as a String.