0 Replies Latest reply: Aug 16, 2013 10:11 AM by anemdhana RSS

    cascade dropdown on selection of one dropdown

    anemdhana

      Hi,

      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"/>
           </h:selectOneMenu><br/>
      
           <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 />
           </h:selectOneMenu>
      


      Pls correct me if I have missed anything..