E ai pessoal, alguém pode me ajudar?
É o seguinte, estou fazendo um trabalho da faculdade em JSP (aprendendo por conta), e tenho um form meio gigante na pagina X, coloquei a parte que interessa:
<td>
<select name="npart" size="10" multiple style="width: 100pt">
<%
AlunoDAO alunoDAO = new AlunoDAO();
alunoDAO.selecionarAlunos();
String name, email;
int codigo;
try{
alunoDAO.bd.resultSet = alunoDAO.bd.callableStatement.executeQuery();
while(alunoDAO.bd.resultSet.next()){
codigo = alunoDAO.bd.resultSet.getInt(1);
name = alunoDAO.bd.resultSet.getString(2);
email = alunoDAO.bd.resultSet.getString(3);
%>
<option id="<%=codigo %>" value="<%=codigo%>"><%=name %></option>
<%
}
}catch(SQLException e) {
e.printStackTrace();
}
%>
</select>
</td>
<td>
<p>
<input type="button" name="insere" value=">>" onclick="TrocaList(document.form.npart,document.form.part);" />
</p>
<p>
<input type="button" name="remove" value="<<" onclick="TrocaList(document.form.part,document.form.npart);" />
</p>
</td>
<td>
<select name="part" size ="10" multiple style="width: 100pt"></select>
</td>
E a função javascript TrocaList:
function TrocaList(ListOrigem,ListDestino)
{
var i;
for (i = 0; i < ListOrigem.options.length ; i++)
{
if (ListOrigem.options[i].selected == true)
{
var Op = document.createElement("option");
Op.text = ListOrigem.options[i].text;
Op.value = ListOrigem.options[i].value;
ListDestino.options.add(Op);
ListOrigem.remove(i);
i--;
}
}
}
Na página Y que é chamada pelo form, tenho o seguinte scriptlet:
<jsp:useBean id="usuarioDAO" class="com.arara.UsuarioDAO" scope="session"/>
<%
TrabalhoDAO trabalhoDAO = new TrabalhoDAO();
trabalhoDAO.trabalho.setCurso(Integer.parseInt(request.getParameter("curso")));
trabalhoDAO.trabalho.setDataFinal(request.getParameter("dataFinal"));
trabalhoDAO.trabalho.setProfessor(usuarioDAO.getCodigoReal());
trabalhoDAO.trabalho.setTema(Integer.parseInt(request.getParameter("tema")));
trabalhoDAO.trabalho.setSemestre(Integer.parseInt(request.getParameter("semestre")));
trabalhoDAO.trabalho.setTitulo(request.getParameter("titulo"));
String[] alunos = request.getParameterValues("part");
String[] alunos2 = request.getParameterValues("npart");
out.println(trabalhoDAO.trabalho.getSemestre());
No entanto, ao executar o request.getParameterValues(“part”) e o request.getParameterValues(“part”) estão retornando null mesmo com conteúdo. No javadocs o retorno null só é feito quando o parâmetro requisitado não existe.
Como posso pegar o valor dos select multiple?