on 07-27-2005 2:42 PM
Hi all,
Have a doubt about DropDownByKey UI Element.
I have a DropDownByKey with information from a Simple Type from my Local Dictionary. I when I run my application, I have to compare the value that I select from my Dropdownbykey with another string... he code I'm using for this is..
String str1 =
(String) wdContext.currentContextElement.getcontext1();
String str2 =
(String) "Test";
if (str1 == str2) {
//do something
}
else {
//do something
}
So, the problem is...when I try to compare this two strings and I already know they are the same, the program also takes de else option and never goes throught the if condition.
Please, help me with this...
Thanks in advance,
Jesus
Jesus,
Just a wild Guess...! Are you using '==' to compare the strings. (It compares the objects). If so use .equals() or .equalsIgnoreCase().
If this is not the case, pls let me know. I'll send you the code for this.
Hope this helps,
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jesus,
Change the if condition like the following
if (str1.equals(str2)) {
//do something
}
else {
//do something
}
This should solve your problem
Regards,
Santhosh.C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
What do you mean by "<i>So, the problem is...when I try to compare this two strings and I already know they are the same, the program also takes de else option and never goes throught the if condition.</i>"
Well say you have a simple type element called ST_List which has a set of values like Blue, Yellow,Orange etc.
Now you create a context attribute say str1 which is of type ST_List.
Now check with .equals .
In the onSelect event of dropdown write code like
String dropdownvalue = wdContext.currentContextElement().getStr1();
String otherStr = "Blue";
if(dropdownvalue.equals(otherStr))
{
///do code
}
else
{
///do code
}
Well moreover see when you say wdContext.currentContextElement().getStr1() it will get you the current selected element. Now when you are comparing with the otherStr and as per your post you say you have fixed it as some value. Now only if the selected value from the dropdown matches the otherStr then it would go into the else and execute it. Just a thought. I dont know what exactly you meant by that line but just in case do let me know if it worked.
regards
ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.