Pessoal,
Estou com problemas no Struts. Tenho uma página com duas listas. O usuário seleciona os items na primeira que alimenta a segunda. Porém, quando eu executo o submit no form, obtenho o seguinte erro:
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
....
java.lang.IllegalArgumentException: Cannot invoke form.formSelecionaFiltro.setLstSelecionados - argument type mismatch
Segue os códigos:
Jsp:
<html:form action="selecionaFiltro.do?com=save" onsubmit="return validaSelecao()">
<table>
<tr>
<td>
<html:select name="formSelecionaFiltro" property="lstValores" size="20" style="width:250" onclick="addOne()">
<html:optionsCollection property="lstValores" label="nomValor" value="valValor"/>
</html:select>
</td>
<td>
<html:select name="formSelecionaFiltro" property="lstSelecionados" size="20" style="width:250" multiple="true">
<html:optionsCollection property="lstSelecionados" label="nomValor" value="valValor"/>
</html:select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<html:submit value="Enviar"/>
</td>
</tr>
</table>
</html:form>
action-form:
private Collection lstValores = null;
private List lstSelecionados = new ArrayList();
public List getLstSelecionados() {
return lstSelecionados;
}
public void setLstSelecionados(List lstSelecionados) {
this.lstSelecionados = lstSelecionados;
}
public Collection getLstValores() {
return lstValores;
}
public void setLstValores(Collection lstValores) {
this.lstValores = lstValores;
}
Action:
//Obtém o form
formSelecionaFiltro nForm = (formSelecionaFiltro)form;
//Obtém o parâmetro do get
String com = request.getParameter("com");
//Verifica se é um submit
if (com != null) {
System.out.println("[+]Items selecionados:"+nForm.getLstSelecionados().size());
}
//Cria a lista de valores
ArrayList lstValores = new ArrayList();
Valor nValor = new Valor();
int index;
for (index=0;index<10;index++) {
nValor = new Valor();
nValor.setNomValor("Valor"+index);
nValor.setValValor("Valor"+index);
lstValores.add(nValor);
}
//Carrega o form e chama a página
nForm.setLstValores(lstValores);
return mapping.findForward("sucesso");