BeanFieldWrapper and ComboBox

Hi guys, I’m using BeanFieldWrapper to wrap a list of Entities to a ComboBox inside a form that use BeanItem as a datasource.

I’m facing a rare case, maybe I’m not understand very well how it’s supposed to work. this is the case:

  1. First I set my form datasource to a instance Object lets say MyObject this objects has a method getOtherObject mapped to a ComboBox, the combo contain a list of OtherObject readed from a Database, this steps work very well and the comboBox shows the selected item correctly.

  2. Then I make no changes to the form fields and I commit it, when commited the MyObject instance set the OtherObject instance to null using the method setOtherMethod

I have traced the error and found that it’s falling in the following code when no changes are made to the comboBox Selection it returns the value from the datasource, the value returned is the mapped id of the OtherObject and not the instance to be set in MyObject instance.

Hope you can understand my explanation… I’m not good at english :frowning:

This is the code used inside DEfaultFormFactory

ComboBox cronJobComboBox = new ComboBox();
.setRequiredError(“Debe seleccionar una tarea”);
BeanItemContainer container = new BeanItemContainer(
List cronJobs = cronJobService.listCronJobs();

				for (CronJob cronJob : cronJobs) {


				f = new BeanFieldWrapper<CronJob>(cronJobComboBox,
						CronJob.class, container, "id");

and this is how I set the datasource of the form

private void setFormDataSource(CronJobTrigger trigger) {
cronJobTrigger = trigger;
BeanItem cronJobTriggerBeanItem = new BeanItem(
Arrays.asList(new String { “id”, “name”, “description”,
“cronJob” /* THE COMBOBOX */, “expression” }));

this is the code that return the id value when the combobox is no modified:

public Object getValue() {

    // Give the value from abstract buffers if the field if possible
    if (dataSource == null || !isReadThrough() || isModified()) {
        return value;

    Object newValue = String.class == getType() ? dataSource.toString()
            : dataSource.getValue();

    return newValue;

Thank you guys!!! (14.2 KB) (3.76 KB) (5.58 KB)