Bom dia a todos,
Estou com um probleminha ao tentar desassociar um registro que esta numa DIV.
Tenho uma DIV que tem alguns registros numa lista e cada registro tem um checkbox para associar ou desassociar.
A associação estou conseguindo fazer normalmente, mas a desassociação não consigo de jeito nenhum.
Vou postar aqui o código que estou usando.
JSP:
<TR>
<TD width="102" bgColor="#dceaf5" height="12">
<font id="lblgerenteCanal" face="verdana" color="#336699" size="1">Gerentes de conta associados:</font>
</TD>
<TD vAlign="top" width="468" bgColor="#dceaf5" height="12">
<DIV class=div2>
<c:forEach var="listaGerenteConta" items="${lstGC}" varStatus="listaCount">
<html:multibox styleId="${listaCount.count}" property="chkgerenteconta">
<bean:write name="listaGerenteConta" property="codgc"/>
</html:multibox>
<font id="descrgc" face="verdana" color="#336699" size="1">
<bean:write name="listaGerenteConta" property="descrgc"/><BR>
</font>
</c:forEach>
</DIV>
</TD>
<TD bgColor="#dceaf5" height="12"></TD>
</TR>
Action:
public class CadGerenteContaAction extends DispatchAction {
/**
*
* Carrega a lista de gerentes de conta(List lstGC)
* e seta como atributo no escopo da sessão.
*
* @return cadGerenteConta.jsp.
*/
Log log = LogFactory.getLog(this.getClass());
public ActionForward executaLista( ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
CadGerenteContaDAO cadGCDAO = new CadGerenteContaDAO();
List<CadGerenteContaVO> lista = cadGCDAO.getListaGC();
if(lista.isEmpty())
session.removeAttribute("lstGC");
else
session.setAttribute("lstGC", lista);
return mapping.findForward("success");
}
DAO:
/**
*
* Carrega uma lista com os registros dos Gerentes de Conta ordenados por descrição
* contendo código,descrição, email e status.
*
* @return List<CadGerenteRegionalVO>
*
*/
public List<CadGerenteContaVO> getListaGC(){
System.out.println("CadGerenteContaDAO.getlistaGC.");
List<CadGerenteContaVO> listaGC = new ArrayList<CadGerenteContaVO>();
try{
Connection con = getConnection();
pstm = con.prepareStatement("SELECT cod_gc, descr_gc, email, bstatus FROM tblgerenteconta order by descr_gc");
rs = pstm.executeQuery();
while(rs.next()){
CadGerenteContaVO cadGCVO = new CadGerenteContaVO();
cadGCVO.setCodgc(rs.getInt("cod_gc"));
cadGCVO.setDescrgc(rs.getString("descr_gc"));
cadGCVO.setEmail(rs.getString("email"));
cadGCVO.setBstatus(rs.getInt("bstatus"));
if (rs.getInt("bstatus") == 0){
cadGCVO.setBstatustexto("Não");
}else{
cadGCVO.setBstatustexto("Sim");
}
listaGC.add(cadGCVO);
};
}catch(SQLException sqlException){
sqlException.printStackTrace();
log.error("Exception: "+ sqlException);
}catch(Exception e){
e.printStackTrace();
log.error("Exception: "+ e);
}finally{
try{
con.close();
}catch(SQLException sqlException){
sqlException.printStackTrace();
log.error("Exception: "+ sqlException);
}
}
return listaGC;
}
Agradeço desde já,
Vitor