Hello
I have one page, where I have several <h:selectOneMenu > elements, some of those selectOneMenu are father elements and others are children , The options that I have in the father elements are always the same, but the options that are displayed in the children elements depend in the father's value.
All the elements are inside the same form. Every time the user chooses one option in one of the selectOneMenu the form is submitted and the value selected is stored in the bean, then the data is processed and the children elements are populated according to the father value.
In each selectOneMenu I have the attributes onchange and valueChangeListener, the onchange attribute submits the form, meanwhile the valueChangeListener saves the new value that was selected for that selectOneMenu element.
Now, this is the problematic situation, when I select a new value in a father element, the father's onchange and valueChangeListener are triggered and the children element is populated with the values that correspond to the selection in the father element, but If i decided to change again the value of the father element, the father's onchange and valueChangeListener are triggered , the children is populated with new values , and as the children now has DIFFERENT values, the children's valueChangeListener is triggered and its value is submitted together with the father element to the bean.
So first question. How can I avoid that the children's valueChangeListener is triggered every time that I want to populate again its value?
The second problem is very similar or is linked with the last problem. In order to populate the children element, I read what the father's value is( <f:selectItems value="#{parameter.paramOptions}" /> ) then I execute a query to get the values for the children, and I populate the children element. Now , the problem comes when I want to select a children value, because when I do it, the form is submitted, and the children is populated again (this time with different values). It looks like the application is not reading what the father's selected value was, instead is reading one of the different possibles father's value, so every time the a new children value is selected, a different father value is loaded and and the children element is repopulated.
Does anyone know why this is happening and how i can avoided?
Thanks in advance