PDA

View Full Version : SimpleComboBox, binding and selected value



bbg5ne
11 Jan 2010, 4:47 AM
Hi!
I have a problem with SimpleComboBox.
This is my code:


public static Field<?> getField(final ResultsetField field, List<?> values, int labelWidth, boolean textarea) {
...
final SimpleComboBox f;
if ((fieldType.compareToIgnoreCase("int") == 0)) {
f = new SimpleComboBox<Integer>();
f.setTriggerAction(TriggerAction.ALL);
f.add(values);
} else {
f = new SimpleComboBox<String>();
f.setTriggerAction(TriggerAction.ALL);
f.add(values);
}
...


The problem is this, in the simpleComboBox I find all the value, but if the values is a list of Strings I can see the selected value, if they are Ints I see all values in simpleComboBox but I have not a value selected.

Can you help me?

Thanks

Mk

bbg5ne
11 Jan 2010, 5:49 AM
I try also with this:


public static Field<?> getField(final ResultsetField field, List<String> values, int labelWidth, boolean textarea) {
...
final SimpleComboBox f;
f = new SimpleComboBox<String>();
f.setTriggerAction(TriggerAction.ALL);
f.add(values);
...

I force to use Srings, the bind works, but I have the same problem: it doesn't select default value! :(

Love Yao
12 Jan 2010, 12:40 AM
I do not know what is your problems.
what is the "default value"

Are you chinese? i

Arno.Nyhm
14 Jan 2010, 9:01 AM
sorry - i also not understand your problem.

i think it is better if you make a standalone example class including the EntryPoint

remark the place in the code where the expected values are different from the existing values.

bbg5ne
14 Jan 2010, 9:10 AM
Sorry guys!
I was not enough clear...
I had a problem with int casted like string, now I fix it!
Thanks for you help

Arno.Nyhm
15 Jan 2010, 8:46 AM
and can you please post your fixed and changed code? this helps others with the same porblem.

bbg5ne
18 Jan 2010, 1:16 AM
I have to post a lot of files...ad it could not be enough simple to understand.

The idea is that:
When I had to create a simpleComboBox, I created it like a simpleComboBox<?>.
But when I got all values from db I cast them like String (for both string and integer), but when I got the selected value from db I had either string or integer, this was my problem.

I solved it changing the cast values when I got it from db and creating simpleComboBox<string> or simpleComboBox<integer> instead simpleComboBox<?>.

You can find here the changes:
http://code.google.com/p/jardin/source/detail?r=131

Arno.Nyhm
18 Jan 2010, 7:06 AM
thanks for the info.

BTW: jardin is an interesting project :-)

bbg5ne
19 Jan 2010, 9:08 AM
Thnaks! :">