problem in controlling the content of dropdown list
I want to have three dropdownlists A, B and C. The values for B depends on the value selected for A and the values for C in turn depends on the value selected for B.
I have data with parent child relationship with three levels. So at first i want only A to be visible and depending upon the value selected for A i will make B appear the value selected for A has any child. Similarly B is made visible depending upon whether or not the value selected for B has any child.
How can i implement this.
Thanks
# 2
You need to point the valuechangelistener property to a method that populates your selectitems.
Your selectitems need to be bound to a property on a backing bean.
The onchange property needs to contain "submit()" so that the page is submitted and the valuechangelistener is called when a new item is selected. (Unless you use ajax, but I won't go into that here. MyFaces have some ajax selectitem components in their sandbox.)
Below is some sample jsf code:
<h:selectOneMenu id="productSelectReentry" value="#{DealForm.dynamicData['productId']}" onchange="submit()" valueChangeListener="#{QCDataForm.loadSelectItems}" rendered="#{DealForm.data.fieldMap['productId'].fieldType eq 'REENTRY'}" disabled="false" readonly="false">
<t:selectItems value="#{DealForm.data.fieldMap['productId'].selectItems}" var="Item" itemLabel="#{Item.label}" itemValue="#{Item.value}" id="productSelectItemsReentry"/>
<f:param name="path" value="fields[#{DealForm.data.fieldIndexes['productId']}].QCData"/>
</h:selectOneMenu>
# 3
Thanks
but i found strange behavior. Actually i have added valuechangelistener for first and second dropdown list(i.e A and B), actually any change in A will invoke its valuechangelistener method, i populate the data for dropdownlist B if present depending on whether or not the selected value has any child.
I found that the valuechangelistener method of B is also invoked when dropdownlist A is changed.
I mean the change in value of dropdownlist A is also triggering the value change listener method of dropdownlist B along with valuechangelistener method of dropdown A.