-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there, I have two combobox and both of them has same model. I want to disable a comboitem that i select in the first combobox. I use setModel method with BindingListModelList for my second combobox. Because it's the only modellist that i can run correctly.
I tried this in my composer class:
this.secondComboBox.getItemAtIndex(this.firstComboBox.getSelectedIndex()).setDisabled(true);
It throws null pointer exception; but it looks make sense to me.
It should work. The following example works just fine (ZK 7.0.5). Try to test it. Maybe something else is wrong with your models.
<zk>
<window title="MVC Various Tests" border="normal" apply="mvctest.MvcTestController">
<combobox id="cmbAreas" />
<combobox id="cmbAreas2" />
</window>
</zk>
public class MvcTestController extends SelectorComposer<Component> {
private static final long serialVersionUID = 1L;
@Wire private Combobox cmbAreas;
@Wire private Combobox cmbAreas2;
private ListModel<String> areas;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
List<String> data = new ArrayList<String>();
data.add("Greece");
data.add("Germany");
data.add("France");
data.add("Spain");
areas = new ListModelList<String>(data);
cmbAreas.setModel(areas);
cmbAreas2.setModel(areas);
}
@Listen("onSelect = #cmbAreas")
public void onSelectArea(SelectEvent event) {
for (Comboitem i : cmbAreas2.getItems())
i.setDisabled(false);
int index = cmbAreas.getSelectedIndex();
cmbAreas2.getItemAtIndex(index).setDisabled(true);
}
}
/Costas
Asked: 2015-08-31 14:18:50 +0800
Seen: 33 times
Last updated: Aug 31 '15