Pois é, como eu faço isso? Esse é o mesmo problema do seguinte tópico: http://www.guj.com.br/posts/list/92383.java , porém ele está sem solução.
Bom, eu na minha aplicação conforme o exemplo desta página: http://www.javabeat.net/tips/49-hselectmanycheckbox-java-server-faces-jsf.html , porém não funcionou.
Vou postar os meus códigos:
trecho JSP
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="0" width="100%">
<h:selectOneMenu value="#{cadastroEvt.codEstado}" onchange="submit()">
<f:selectItems value="#{cadastroEvt.listaEstatos}"/>
</h:selectOneMenu>
<f:verbatim>
<div style="overflow:auto;width:250px;height:200px">
<h:selectManyCheckbox value="#{cadastroEvt.municipios}" layout="pageDirection">
<f:selectItems value="#{cadastroEvt.listaMunicipiosPorUf}"/>
</h:selectManyCheckbox>
</div>
</f:verbatim>
<h:selectManyListbox value="#{cadastroEvt.removeMunic}">
<f:selectItems value="#{cadastroEvt.listaMunicSelecionados}"/>
</h:selectManyListbox>
<f:verbatim></f:verbatim>
<h:commandButton value="Adicionar" action="#{cadastroEvt.adicionarMunicipios}"/>
<h:commandButton value="Remover" action="#{cadastroEvt.removerMunicipios}" />
</h:panelGrid>
Trechos Java
//declaração
private List<Integer> municipios;
//gettes and setters
public List<Integer> getMunicipios()
{
return municipios;
}
public void setMunicipios(List<Integer> municipios)
{
this.municipios = municipios;
}
//função que é acionada pelo botão:
public void adicionarMunicipios()
{
ArrayList<Integer> lst = new ArrayList<Integer>();
for (int i = 0; ( (municipios != null) && (i < municipios.size()) ); i++)
lst.add( municipios.get(i) );
for (int i = 0;( (municSelec != null) && (i < municSelec.size() ) ); i++)
lst.add( municSelec.get(i) );
if (lst != null)
municSelec = lst;
municipios = null;
}
Bom, eu não estou conseguindo capturar os dados marcados no checkbox. Ele sequer entra no set