# ZK ComboBox constraint firing on getSelectIndex()

javiut
90 1 5

hi i have a comboBox like this

<combobox id="ttr" constraint="\${cmv}" onChange="ttrSelected()">


the first time the comboBox have nothing selected but sometimes i need to know the value coming from a overlapped window to check a button[disabiling or enabliing]

as you can see the comboBox have a constraint looks like this.

public void validate(Component comp,Object value)throws WrongValueException
{
if (value.toString().isEmpty()){throw new WrongValueException(comp,"The field is mandatory");}
}


this is working OK but when i need to know the current selected item on the validation.

Student student = (Student)ttr.getModel().getElementAt(ttr.getSelectedIndex());


results in firing the constraint and of course the value is emtpy and 2 things occur.

1). the current execution of my validation stops because a WrongValueException is throw.

2). the validation occurs on the form.

my question is why the constraint is firing on getSelectedIndex()?? i think it should fire on setSelectedItem() or something..

why validated on an inmutable method?

i am using ZK 5.0.8 in MVC style

delete retag edit
Be the first one to answer this question!
[hide preview]