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: 
_AnonymousUser
Specialist III
Specialist III

[resolved] tmsbox, tjava

HI,
I use a tmsgbox : question (TOS 4.2.3) link (onComponentOK) to tjava component . I want to say what's value the OK and Cancel buttons return.
I want to test what's button the user click, in the tjava component.
This is the code i use in tjava component :
String result=(String)globalMap.get("tMsgBox_1_RESULT");
if(result.equals("0")){ //You have clicked on 'Yes' button
globalMap.put("continues", true);
}
if(result.equals("1")){ //You have clicked on 'NO' button
globalMap.put("continues", false);
}
but it don't work.
Best regards
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi, Fab972
Thanks for your attention on Talend. From your code:
String result=(String)globalMap.get("tMsgBox_1_RESULT");
if(result.equals("0")){ //You have clicked on 'Yes' button
globalMap.put("continues", true);
}
if(result.equals("1")){ //You have clicked on 'NO' button
globalMap.put("continues", false);
}

You will get three results:
1. If the user typing answer?such as ?i am Fab972?, click ok, the value of (String)globalMap.get("tMsgBox_1_RESULT") is "i am Fab972",
2. if the user don't input any answer, click directly OK button, the value of (String)globalMap.get("tMsgBox_1_RESULT") is "" //it is an empty string
3. if the user click Cancel button, the value of (String)globalMap.get("tMsgBox_1_RESULT") is null
So, the return value of (String)globalMap.get("tMsgBox_1_RESULT") is not 1 or 0, the returned value are the three cases as above.
For testing, you can use print the return value on the console using this code:
System.out.println((String)globalMap.get("tMsgBox_1_RESULT") );

. And you can change the code to :
if(result==null){ //You have clicked on 'Cancel' button
globalMap.put("continues", false);
}else{
//You have clicked on 'Yes' button
globalMap.put("continues", true);
}

Hope it will help you!
Best Regards
Sabrina

View solution in original post

4 Replies
Anonymous
Not applicable

I have no idea whats wrong with your code. For me it works perfectly!
alevy
Specialist
Specialist

If you're using the Question option for tMsgBox then (String)globalMap.get("tMsgBox_1_RESULT") contains the user input but is null if they click Cancel.
For all the other tMsgBox options, (String)globalMap.get("tMsgBox_1_RESULT") contains the number of the button clicked, starting from zero left-to-right.
Anonymous
Not applicable

Hi, Fab972
Thanks for your attention on Talend. From your code:
String result=(String)globalMap.get("tMsgBox_1_RESULT");
if(result.equals("0")){ //You have clicked on 'Yes' button
globalMap.put("continues", true);
}
if(result.equals("1")){ //You have clicked on 'NO' button
globalMap.put("continues", false);
}

You will get three results:
1. If the user typing answer?such as ?i am Fab972?, click ok, the value of (String)globalMap.get("tMsgBox_1_RESULT") is "i am Fab972",
2. if the user don't input any answer, click directly OK button, the value of (String)globalMap.get("tMsgBox_1_RESULT") is "" //it is an empty string
3. if the user click Cancel button, the value of (String)globalMap.get("tMsgBox_1_RESULT") is null
So, the return value of (String)globalMap.get("tMsgBox_1_RESULT") is not 1 or 0, the returned value are the three cases as above.
For testing, you can use print the return value on the console using this code:
System.out.println((String)globalMap.get("tMsgBox_1_RESULT") );

. And you can change the code to :
if(result==null){ //You have clicked on 'Cancel' button
globalMap.put("continues", false);
}else{
//You have clicked on 'Yes' button
globalMap.put("continues", true);
}

Hope it will help you!
Best Regards
Sabrina
_AnonymousUser
Specialist III
Specialist III
Author

Hi Sabrina,
Thanks for you reply. It's work.
best regards
Fab