0 Replies Latest reply on Aug 16, 2013 3:11 PM by anemdhana

    cascade dropdown on selection of one dropdown



      I have customerController annotated as @Model, StateListProducer being @RequestScoped and the following is my view.


      on select of state dropdown, need to populate city dropdown by ajax call, I were successful using <f:ajax /> tag, but problem is when submitting the form, the dropdown value for city is being sent as invalid though I select right value and hence the error was throw 'value is invalid for city'.

           <div class="message"><h:message for="state" errorClass="invalid" /></div>
           <span><h:outputLabel for="state" value="#{msg['customer.state']}:" /></span>
           <h:selectOneMenu value="#{newCustomer.address[0].state.id}" id="state" requiredMessage="#{msg['field.required']}">
                <f:selectItem itemLabel="-- Select a State -- " />
                <f:selectItems value="#{states}" var="state_"
                     itemValue="#{state_.id}" itemLabel="#{state_.value}" />
                <f:validateRequired />
                <f:ajax event="change" listener="#{customerController.refreshCitiesBySelectedState()}" render="city" onevent="showLoadingIndicator"/>
           <div class="message"><h:message for="city" errorClass="invalid" /></div>
           <span><h:outputLabel for="city" value="#{msg['customer.city']}:" /></span>
           <h:selectOneMenu value="#{newCustomer.address[0].city.id}" id="city" requiredMessage="#{msg['field.required']}">
                <f:selectItem itemLabel="-- Select a city -- "/>
                <f:selectItems value="#{cities}" var="city_"
                     itemValue="#{city_.id}" itemLabel="#{city_.value}" />
                <f:validateRequired />

      Pls correct me if I have missed anything..