PDA

View Full Version : read out ComboBox<KeyValueModel> @server



Kalle1985
14 Oct 2009, 7:02 AM
Hi,

i want to read out the value of the my comboBox @ server side.
When i try to get the value of the selected comboBox, i just get the "label".

But i need the "value" !!!

Here the snippet of client-code:




public ComboBox<KeyValueModel> getComboBox() {
if(combo == null) {
combo = new ComboBox<KeyValueModel>();
combo.setEditable(false);
combo.setAllowBlank(false);
combo.setName("comboBox");
combo.setEmptyText("Waehlen Sie den Parametertyp...");


ListStore<KeyValueModel> store = new ListStore<KeyValueModel>();


store.add(new KeyValueModel("aaa", "3"));
store.add(new KeyValueModel("bbb", "2"));
store.add(new KeyValueModel("ccc", "1"));


combo.setStore(store);
combo.setFieldLabel("Parameterart ");
combo.setValueField(KeyValueModel.VALUE);
combo.setDisplayField(KeyValueModel.LABEL);
combo.addSelectionChangedListener(new SelectionChangedListener<KeyValueModel>() {


@Override
public void selectionChanged(SelectionChangedEvent<KeyValueModel> se) {
checkFields();
}
});
}
return combo;
}




Here where i try to get the "value" of the selected field (comboBox) in the "doPost" method @ my extended class of HttpServlet:




while(it.hasNext()) {
FileItem item = (FileItem) it.next();
if(item.getFieldName().equals("fileUpload")) {
if (!item.isFormField()) {
String dateinameMitTyp = item.getName().substring(item.getName().lastIndexOf("\\"));
String dateiname = dateinameMitTyp.substring(1, dateinameMitTyp.indexOf("."));
GregorianCalendar gc = new GregorianCalendar();
File uploadedFile = new File("D:\\paramUpload\\"
+ dateiname + "_"
+ uid + "_"
+ gc.getTimeInMillis()
+ dateinameMitTyp.substring(dateinameMitTyp.indexOf(".")));
item.write(uploadedFile);
}
} else if(item.getFieldName().equals("comboBox")) {
if(item.isFormField()) {
//WHAT SHOULD I DO HERE?
System.out.println(value);
}
}
}




I send the data via POST in my FormPanel(). (formpanel.submit())...
I want to get the "3", not the "aaa"...


Does anyone know a solution?

pengod
14 Oct 2009, 12:15 PM
I have the similar issue here as well, I want to submit the "valueField" according to my combobox's selection, but I get the "displayField" in the my servlet ... I checked the value of combobox component before I do submit through firebug, it shows the correct valueField info, but why the server side doesn't get the correct value?

Can any please help me?

pengod
14 Oct 2009, 12:22 PM
I figured it out... I used hiddenName property in my combobox and then it submit the value to my servlet...:D

Kalle1985
14 Oct 2009, 10:56 PM
Hi, can you please post your affected code?
I don`t know the "hiddenName" property.
Where do you set this?