[Solved] Filtering City by state in java – Using Array


Sorry everyone for my uncompleted question.

My point is, when I select some value in my menu, this have to change another menu with the values in referente:

Front Implementation:

<h:panelGroup layout="block" class="col-md-3" id="panel-state">
<label>#{msg['state']}</label>

<h:selectOneMenu id="mdl-state" value="#{saisReportQueryBean.reportQuery.state}" binding="#{uf}" class="form-control input_no_round_corner">
<f:selectItem itemValue="#{null}" itemLabel="#{msg['select_state']}" noSelectionOption="true" />
<f:selectItems value="#{saisReportQueryBean.keyState}" var="estado" itemValue="#{estado}" itemLabel="#{estado}" />
<f:ajax listener="#{saisReportQueryBean.UpdateCityByState(uf.value)}" render=":panel-city" event="change" execute="@this" onevent="initializeChosenFieldsCity">
</f:ajax>
</h:selectOneMenu>
</h:panelGroup>
<h:panelGroup layout="block" class="col-md-3" id="panel-city">
<label>#{msg['city']}</label>
<h:selectOneMenu id="mdl-city" value="#{saisReportQueryBean.listCidades}" class="form-control input_no_round_corner">
<f:selectItem itemValue="#{null}" itemLabel="#{msg['select_city']}" noSelectionOption="true" />
<f:selectItems value="#{saisReportQueryBean.listCidades}" var="cidade" itemValue="#{cidade.municipio}" itemLabel="#{cidade.municipio}" />
</h:selectOneMenu>
</h:panelGroup>

Back implementation:

cidades = cidadesIbgeBeanRemote.findAll();


setKeyState(new ArrayList(estados.keySet()));
getKeyState().toString();
getKeyState().sort((f1, f2) -> f1.compareTo(f2));

solved Filtering City by state in java – Using Array