所以
我有一个包含State和City值的ArrayList,并且我必须检查state是否等于某个变量,让我们将其称为“ var1”,如果此状态等于,我必须获取城市名字...
我正在创建菜单过滤器。
<div class="col-md-3">
<label>#{msg['state']}</label>
<h:selectOneMenu id="mdl-state" value="#{saisReportQueryBean.keyState}" class="form-control">
<f:ajax listener="#{saisReportQueryBean.Teste()}"/>
<f:selectItem itemValue="#{null}" itemLabel="#{msg['select_state']}" noSelectionOption="true" />
<f:selectItems value="#{saisReportQueryBean.keyState}" var="estado" itemValue="#{estado}" itemLabel="#{estado}" />
</h:selectOneMenu>
</div>
<div class="col-md-3">
<label>#{msg['city']}</label>
<h:selectOneMenu id="mdl-city" value="#{saisReportQueryBean.keyCity}" class="form-control">
<f:selectItem itemValue="#{null}" itemLabel="#{msg['select_city']}" noSelectionOption="true" />
<f:selectItems value="#{saisReportQueryBean.keyCity}" var="cidade" itemValue="#{cidade}" itemLabel="#{cidade}" />
</h:selectOneMenu>
</div>
When I select the state, I've to update my city itens with just only city in references with the state selected.
Here is my java code.:
protected void updateData() {
this.reportQuery = new SaisReportQuery();
this.queryExecuted = false;
cidades = cidadesIbgeBeanRemote.findAll();
cidades.sort((f1, f2) -> f1.getMunicipio().compareTo(f2.getMunicipio()));
Map<String, List<CidadeIbge>> estados = cidades.stream().collect(Collectors.groupingBy(CidadeIbge::getUf));
setKeyState(estados.keySet());
getKeyState().toString();
System.out.println(keyState);
}
Tks。
答案 0 :(得分:0)
对不起我所有未完成的问题。
我的意思是,当我在菜单中选择某个值时,这必须更改另一个菜单中具有参考值的值:
前端实现:
<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>
回溯实施:
cidades = cidadesIbgeBeanRemote.findAll();
setKeyState(new ArrayList(estados.keySet()));
getKeyState().toString();
getKeyState().sort((f1, f2) -> f1.compareTo(f2));