I have an issue with a listbox and the combobox behaviour. I have a listbox with a group of rows and I try to edit inline and change the value of a field based on the values of a combobox. But when I select one value in the combo of one row then all the values of the comboboxes of the other rows change to the same value. Please, let me know what I am doing wrong. Thanks for your help!
Here is my code:
<template name="model" var="item">
<listitem >
<listcell label="@load(item.id)"/>
<listcell label="@load(item.descCodigoTrafico)"/>
<listcell label="@load(item.descAmbitoDeTrafico)"/>
<listcell>
<combobox
model="@load(vm.listaPrecioEspecial)"
onChange="@command('addToUpdate', entry=item)"
selectedItem="@load(item.precioEspecial) @save(item.precioEspecial, before='updateItems')">
<template name="model" var="el">
<comboitem label="@load(el)"/>
</template>
</combobox>
</listcell>
<listcell label="@load(item.tipoDescuento)" />
<listcell>
<decimalbox inplace="true"
value="@load(item.ppm) @save(item.ppm, before='updateItems')"
onChange="@command('addToUpdate', entry=item)"
format="#.0000"/>
</listcell>
</listitem>
</template>
And the code of the two methods in de VM:
@Command
public void addToUpdate(@BindingParam("entry") TblEscenarioCondTrafico item){
itemsToUpdate.add(item);
LOGGER.info(item.toString());
for(TblEscenarioCondTrafico i : itemsToUpdate){
LOGGER.info("Item a guardar " + i.toString());
//LOGGER.info("Elemento...");
}
}
@NotifyChange("listaTraficos")
@Command
public void updateItems() throws Exception{
EscenarioCondTraficoService ects = new EscenarioCondTraficoService(em);
for (TblEscenarioCondTrafico i : itemsToUpdate){
LOGGER.info("Guardando " + i.toString());
ects.save(i);
}
itemsToUpdate.clear();
listaTraficos = getListaTraficos();
}
The problem should be that
model="@load(vm.listaPrecioEspecial)"
sets the same Collection
to every Combobox
as its model and so it is bound to all Combobox
instances.