PDA

View Full Version : ComboxBox with Id and Label



marman
10 May 2009, 4:32 AM
Can anyone point me to an example which shows ComboBox working with a FormBinding? I have a list of Objects i want to display of the form: id, label. I want to the Combo to show all the labels and then have the form binding either give me back the id of what was selected or better yet the Object representing the id and label.

my data is like:
[ 1, "Yellow" ]
[ 2, "User Custom label" ]
[ 3, "Purple" ]
etc...

I can not just infer the Id from the label as the labels are user defined and I do not want to query the database to match the label.

The examples only show a SimpleComboBox which returns the label, but i need the Id. Any help would be greatly appreciated. thanks in advance.

sven
10 May 2009, 4:36 AM
combo.getValue()

returns the object of the current selected value. So
combo.getValue().getId() (or what your method name is like) will return your id.

marman
10 May 2009, 5:08 PM
combo.getValue()

returns the object of the current selected value. So
combo.getValue().getId() (or what your method name is like) will return your id.

Thanks for the response. I got things working, however now i have a new issue. Is there a way to pass nested ModelData Objects back to the server? I get a serialization exception:


Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'com.mycompany.web.client.data.AccountTypeVO' was not included in the set of types which can be deserialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be deserialized.

I have an AccountVO which includes an AccountTypeVO. When i pass this nested Object back to the server, it blows up. I worked around it with a hack to remove the AccountTypeVO from the Account and only pass back the Integer id, but this is messy