Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have different name context like :
user12 = johnny
user20 = bob
user54 = billy
I my job, i have my id user.
Can i use a dynamic name context like :
context."user"+id
or
String my_user = "user"+id;
context.my_user
I try more syntaxes but it's not ok
Thanks for your help,
Arnaud
I find a solution with a method context : getProperty()
String my_user = context.getProperty("user" + current_id);
It works !
If my current_id doesn't match with an existing context name as context.getProperty("user" + 25465)
> return null
Thanks everyone !!
no for context variable you can't do so.
I try to help you if you explain your problem more clearly
or you can do with the below strategy(in tJava component):
int id=25;
context.my_user = context.user+id; //where id is a variable
Here is my context.
To get my context :
context.user12 > I have my response : johnny
Now, i want to get my context dynamically. I try different syntaxes but it's not ok
current_id = 12
context."user"+current_id > cannot be resolved
context.user+current_id > cannot be resolved
Do you have any idea ?
You cannot construct context variable names as they must exist at compile time.
On the other hand, you can do it with global variables but depending of why you try to do, maybe it's not a solution for you.
I find a solution with a method context : getProperty()
String my_user = context.getProperty("user" + current_id);
It works !
If my current_id doesn't match with an existing context name as context.getProperty("user" + 25465)
> return null
Thanks everyone !!