I am trying to implement a SelectItem bound to an xml.ds datasource. The select list displays correctly, however when I select and item from the list or change the selection, I am having difficulty assigning a value from the selected record to a field in the current form. I am following the pattern from the "Selected Value" item from the Showcase:
Here is my code
final SelectItem vendSI = new SelectItem();
vendSI.setTitle("Vendor");
vendSI.setPickListWidth(250);
vendSI.setOptionDataSource(vendors);
vendSI.setDisplayField("vendName");
vendSI.setSortField("vendName");
vendSI.setValueField("vendorName");
catItemForm.setItems(vendSI);
vendSI.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
catItemForm.setValue("vendName", event.getValue());
}
});
In Eclipse this code throws and error that "event.getValue() is an object and cannot be assigned to a String (event.getValue() does not have to be cast to be assigned to a string) . If I cast event.getValue() to string, there is no returned value.
Finally, ultimately, I would like to assign two values from the optionDataSource to the catItemForm. What is the best way to do this?
Thank you for your help.
Here is my code
final SelectItem vendSI = new SelectItem();
vendSI.setTitle("Vendor");
vendSI.setPickListWidth(250);
vendSI.setOptionDataSource(vendors);
vendSI.setDisplayField("vendName");
vendSI.setSortField("vendName");
vendSI.setValueField("vendorName");
catItemForm.setItems(vendSI);
vendSI.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
catItemForm.setValue("vendName", event.getValue());
}
});
In Eclipse this code throws and error that "event.getValue() is an object and cannot be assigned to a String (event.getValue() does not have to be cast to be assigned to a string) . If I cast event.getValue() to string, there is no returned value.
Finally, ultimately, I would like to assign two values from the optionDataSource to the catItemForm. What is the best way to do this?
Thank you for your help.
Comment