Pessoal,
Estou executando um metodo que eu inseri um campo de data e ao tentar carregar a pagina está dando erro de ClassCastException, so que eu nao consigo descobrir onde eu estou errado ! Segue o log, se alguem tiver uma luz !
Valew
Abs
Pessoal,
Estou executando um metodo que eu inseri um campo de data e ao tentar carregar a pagina está dando erro de ClassCastException, so que eu nao consigo descobrir onde eu estou errado ! Segue o log, se alguem tiver uma luz !
Valew
Abs
Posta o codigo da JSP e do Bean também.
[]´s
Daniel
A jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<f:subview id="subviewDoctype">
<jsp:include page="include/doctype.jsp" />
</f:subview>
<fmt:setLocale value='pt_BR' />
<f:view>
<f:loadBundle basename="/resources/ApplicationMessagesView" var="msgView" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/default.css">
<title>:: Raia ::</title>
</head>
<body>
<h:form id="extratoForm">
<h:inputHidden id="cartao" value="#{bloqueioClienteMBean.nroCartao}" />
<h:inputHidden id="matricula" value="#{bloqueioClienteMBean.nroMatricula}" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<f:subview id="subViewCabecalho">
<jsp:include flush="true" page="include/includeCabecalho.jsp" />
</f:subview>
<tr>
<td align="left" valign="top" class="fundoSistena">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<f:subview id="subViewCabecalho">
<jsp:include flush="true" page="include/includeMenu.jsp" />
</f:subview>
<tr>
<td height="459" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="36"> </td>
<td height="22"> </td>
<td width="52"> </td>
</tr>
<tr>
<td> </td>
<td height="40" align="left" valign="top">
<img src="img/tit_bloqueio_blue.gif" width="256" height="28" />
</td>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td> </td>
<td height="50" valign="top" class="ft12pxBoldRed">
<h:commandButton id="confirmar" value="Confirmar" action="#{bloqueioClienteMBean.confirmarBloqueio}" image="img/bt_sim.gif"
style=" width:70px; height:23px; border:0px; " />
<a href="<%=request.getContextPath() %>/jsp/convenio/exibirBloqueio.faces">
<img src="img/bt_nao.gif" alt="nao" width="70" height="23" border="0" />
</a>
</td>
<td valign="top" class="ft12pxBoldRed"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td valign="top">
<!--
<hdataTable id="gridClientes" value="#{bloqueioClienteMBean.clientes}" var="item"
columnClasses="" width="100%" border="0" cellspacing="0" cellpadding="0"
rendered="#{not empty bloqueioClienteMBean.clientes}"
headerClass="alteracao"> -->
<h:dataTable id="gridClientes" rendered="true"
binding="#{bloqueioClienteMBean.dataTableCliente}"
var="item" columnClasses="" width="100%" border="0" cellspacing="0" cellpadding="0" headerClass="alteracao">
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_numero_matricula}" />
</f:facet>
<h:outputText value="#{item.nrMatrFuncional}"
styleClass="tdMargemCza" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_numero_cartao}" />
</f:facet>
<h:outputText value="#{item.cdCliente}#{item.dgCliente}"
styleClass="tdMargemCza" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_nome}" />
</f:facet>
<h:outputText value="#{item.nmCliente}"
styleClass="tdMargemCza" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_data_bloqueio}" />
</f:facet>
<h:outputText value="#{item.dataBloqueio}" styleClass="tdMargemCza">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_data_fechamento}" />
</f:facet>
<h:outputText value="#{item.dataFechamento}"
styleClass="tdMargemCza">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_saldo_fechamento}" />
</f:facet>
<h:outputText value="#{item.saldoFechamento}"
styleClass="tdMargemCza">
<f:convertNumber type="currency" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_saldo_apos_fechamento}" />
</f:facet>
<h:outputText value="#{item.saldoAposFechamento}"
styleClass="tdMargemCza">
<f:convertNumber type="currency" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgView.lbl_status_bloqueio}" />
</f:facet>
<h:outputText value="#{item.statusCartaoAtual}"
styleClass="tdMargemCza" />
</h:column>
</h:dataTable></td>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="22" align="center" valign="middle" class="ftCinza">
<a href="#" class="a10pxCinza"><jsp:include page="include/includeRodape.jsp" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</h:form>
</body>
</html>
</f:view>
o bean
package br.com.drogaraia.raiaconvenio.beans;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import org.apache.commons.chain.Context;
import br.com.drogaraia.raiaconvenio.delegate.BloqueioDelegate;
import br.com.drogaraia.raiaconvenio.delegate.CartaoDelegate;
import br.com.drogaraia.raiaconvenio.delegate.ClienteDelegate;
import br.com.drogaraia.raiaconvenio.util.Constants;
import br.com.drogaraia.raiaconvenio.vo.CartaoVO;
import br.com.drogaraia.raiaconvenio.vo.TbClienteVO;
import br.com.drogaraia.raiaconvenio.vo.UsuarioSessionVO;
public class BloqueioClienteMBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(BloqueioClienteMBean.class.getName());
private Collection listMotivos = new ArrayList();
private CartaoVO cartaoVO = new CartaoVO();
private Integer retorno;
private Integer flagSegundaVia = new Integer(0);
private List clientes;
// private TbBloqueioClienteVO bloqueioClienteVO;
// private Map filter = new HashMap();
// private BloqueioDelegate bloqueioDelegate;
private HtmlDataTable dataTableCliente;
private List listaCliente;
/* atributos do formulario */
private String nroMatricula;
private String nroCartao;
private String codigoBloqueio;
private Long nroOcorrencia;
/**
* @throws Exception
*/
public BloqueioClienteMBean() throws Exception {
try {
BloqueioDelegate bloqueioDelegate = new BloqueioDelegate();
Context ctx = bloqueioDelegate.recuperarMotivoBloqueio();
this.setListMotivos((List) ctx.get(Constants.CTX_PARAM_BLOQUEIO_MOTIVOS));
retorno = new Integer(0);
}
catch (Exception ex) {
logger.log(Level.SEVERE, "Falha na construção da relação de motivos de bloqueio de funcionários.", ex);
throw ex;
}
}
private List recuperarDadosCartao(List lista, Map filter) throws Exception {
List result = null;
TbClienteVO clienteVO;
try {
Context ctx;
if (lista != null) {
CartaoDelegate cartaoDelegate = new CartaoDelegate();
result = new ArrayList();
Iterator iterator = lista.iterator();
while (iterator.hasNext()) {
clienteVO = (TbClienteVO) iterator.next();
filter.put(Constants.CTX_PARAM_BLOQUEIO_CODIGO_EMPRESA, clienteVO.getCdEmpresa());
filter.put(Constants.CTX_PARAM_BLOQUEIO_NUMERO_CARTAO, clienteVO.getCdCliente().toString().concat(clienteVO.getDgCliente().toString()));
ctx = cartaoDelegate.pesquisarCartao(filter);
cartaoVO = (CartaoVO) ctx.get(Constants.CTX_PARAM_BLOQUEIO_CARTAO_VO);
clienteVO.setSaldoFechamento(cartaoVO.getSaldoFechamento());
clienteVO.setSaldoAposFechamento(cartaoVO.getSaldoAposFechamento());
clienteVO.setDataFechamento(cartaoVO.getDataFechamento());
clienteVO.setStatusCartaoAtual(cartaoVO.getStatus());
clienteVO.setDataBloqueio(cartaoVO.getDataBloqueio());
result.add(clienteVO);
}
}
}
catch (Exception ex) {
logger.log(Level.SEVERE, "Falha na preparação da lista de dados do cartão.", ex);
throw ex;
}
return result;
}
/**
* Metodo que bloqueia um cartão dependendo de um motivo.
*
* @return
* @throws Exception
*/
public String bloquear() throws Exception {
Map filter = new HashMap();
BloqueioDelegate bloqueioDelegate = new BloqueioDelegate();
try {
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
UsuarioSessionVO usuarioVO = (UsuarioSessionVO) session.getAttribute(Constants.USUARIO_SESSION);
int codigoBloqueio = this.getCodigoBloqueio() == null ? 0 : Integer.parseInt(this.getCodigoBloqueio());
if (codigoBloqueio == Constants.FLAG_BLOQUEIO_MOTIVO_ROUBO_CARTAO || codigoBloqueio == Constants.FLAG_BLOQUEIO_MOTIVO_CANCELAMENTO_SEGUNDA_VIA || codigoBloqueio == Constants.FLAG_BLOQUEIO_MOTIVO_PERDA_CARTAO_CARTAO_C_ERRO_LEITURA) {
this.setFlagSegundaVia(new Integer(Constants.FLAG_BLOQUEIO_SOLICITAR_SEGUNDA_VIA));
}
else {
this.setFlagSegundaVia(new Integer(Constants.FLAG_BLOQUEIO_NAO_SOLICITAR_SEGUNDA_VIA));
}
filter.put(Constants.CTX_PARAM_BLOQUEIO_CODIGO_BLOQUEIO, new Integer(codigoBloqueio));
filter.put(Constants.CTX_PARAM_BLOQUEIO_CODIGO_EMPRESA, usuarioVO.getCodEmpresa());
filter.put("nroMatricula", getNroMatricula());
filter.put("nroCartao", getNroCartao());
ClienteDelegate clienteDelegate = new ClienteDelegate();
Context ctx = clienteDelegate.pesquisar(filter);
this.listaCliente = recuperarDadosCartao((List) ctx.get(Constants.CTX_PARAM_BLOQUEIO_CLIENTES), filter);
if (this.getDataTableCliente() != null) {
this.getDataTableCliente().setValue(listaCliente);
}
filter.put(Constants.CTX_PARAM_BLOQUEIO_CLIENTES, listaCliente);
ctx = bloqueioDelegate.bloquear(filter, new Integer(codigoBloqueio));
Integer invalido = (Integer) ctx.get(Constants.CTX_PARAM_BLOQUEIO_INVALIDO);
CartaoVO vo = cartaoVO;
Integer segundaVia = (Integer) ctx.get(Constants.CTX_PARAM_BLOQUEIO_SEGUNDA_VIA);
if (invalido != null) {
filter = new HashMap();
if (invalido.equals(new Integer(Constants.FLAG_BLOQUEIO_SEM_REGISTROS_PARA_FILTRO))) {
/* sem registro para o filtro */
retorno = new Integer(Constants.FLAG_BLOQUEIO_SEM_REGISTROS_PARA_FILTRO);
filter.put(Constants.CTX_PARAM_BLOQUEIO_RETORNO, retorno);
return Constants.FORWARD_BLOQUEIO_DADOS_INVALIDOS;
}
else {
/* cartão já bloqueado */
retorno = new Integer(Constants.FLAG_BLOQUEIO_CARTAO_BLOQUEADO);
filter.put(Constants.CTX_PARAM_BLOQUEIO_RETORNO, retorno);
return Constants.FORWARD_BLOQUEIO_DADOS_INVALIDOS;
}
}
else if (segundaVia != null) {
if( vo != null ) {
setNroMatricula(vo.getNroMatricula());
if( vo.getNroCartao() != null )
setNroCartao(vo.getNroCartao().toString());
}
this.setCartaoVO(vo);
return Constants.FORWARD_BLOQUEIO_SEGUNDA_VIA;
}
else {
filter = new HashMap();
this.setCartaoVO(vo);
filter.put(Constants.CTX_PARAM_BLOQUEIO_CLIENTE, (TbClienteVO) ctx.get(Constants.CTX_PARAM_BLOQUEIO_CLIENTE));
return Constants.FORWARD_BLOQUEIO_DEMISSAO;
}
}
catch (Exception ex) {
logger.log(Level.SEVERE, "Falha no bloqueio de funcionários.", ex);
throw ex;
}
}
public String confirmarBloqueio() throws Exception {
String forward = null;
BloqueioDelegate bloqueioDelegate = new BloqueioDelegate();
try {
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
UsuarioSessionVO usuarioVO = (UsuarioSessionVO) session.getAttribute(Constants.USUARIO_SESSION);
List listaClientes = (List) this.getDataTableCliente().getValue();
setClientes(listaClientes);
Map filter = new HashMap();
filter.put(Constants.CTX_PARAM_BLOQUEIO_CODIGO_BLOQUEIO, Constants.MOTIVO_DEMISSAO);
filter.put(Constants.CTX_PARAM_BLOQUEIO_CLIENTES, listaClientes);
filter.put("nroMatricula", getNroMatricula());
filter.put("nroCartao", getNroCartao());
filter.put("cdBloqueioString", getCodigoBloqueio());
Context ctx = bloqueioDelegate.confirmarBloquear(filter, usuarioVO);
Integer invalido = (Integer) ctx.get(Constants.CTX_PARAM_BLOQUEIO_INVALIDO);
this.setNroOcorrencia((Long) ctx.get("nroOcorrencia"));
filter = new HashMap();
filter.put(Constants.CTX_PARAM_BLOQUEIO_NUMERO_OCORRENCIA, ctx.get(Constants.CTX_PARAM_BLOQUEIO_NUMERO_OCORRENCIA));
if (invalido != null) {
if (invalido.equals(new Integer(Constants.FLAG_BLOQUEIO_CARTAO_BLOQUEADO))) {
/* cartão já bloqueado */
retorno = new Integer(2);
filter.put(Constants.CTX_PARAM_BLOQUEIO_RETORNO, retorno);
forward = Constants.FORWARD_BLOQUEIO_DADOS_INVALIDOS;
}
}
else {
forward = Constants.FORWARD_BLOQUEIO_CONFIRMAR_BLOQUEIO;
}
}
catch (Exception ex) {
logger.log(Level.SEVERE, "Falha na confirmação de bloqueio de funcionários.", ex);
throw ex;
}
return forward;
}
public String emitirSegundaVia() throws Exception {
return "sucesso";
}
public Collection getListMotivos() throws Exception {
return listMotivos;
}
public void setListMotivos(Collection listMotivos) {
this.listMotivos = listMotivos;
}
public CartaoVO getCartaoVO() {
return cartaoVO;
}
public void setCartaoVO(CartaoVO cartaoVO) {
this.cartaoVO = cartaoVO;
}
public Integer getRetorno() {
return retorno;
}
public void setRetorno(Integer retorno) {
this.retorno = retorno;
}
public Integer getFlagSegundaVia() {
return flagSegundaVia;
}
public void setFlagSegundaVia(Integer flagSegundaVia) {
this.flagSegundaVia = flagSegundaVia;
}
public List getClientes() throws Exception {
return clientes;
}
public void setClientes(List clientes) {
this.clientes = clientes;
}
/* Propriedades do formulario */
/**
* @return the nroMatricula
*/
public String getNroMatricula() {
return nroMatricula;
}
/**
* @param nroMatricula
* the nroMatricula to set
*/
public void setNroMatricula(String nroMatricula) {
this.nroMatricula = nroMatricula;
}
/**
* @return the nroCartao
*/
public String getNroCartao() {
return nroCartao;
}
/**
* @param nroCartao
* the nroCartao to set
*/
public void setNroCartao(String nroCartao) {
this.nroCartao = nroCartao;
}
/**
* @return the codigoBloqueio
*/
public String getCodigoBloqueio() {
return codigoBloqueio;
}
/**
* @param codigoBloqueio
* the codigoBloqueio to set
*/
public void setCodigoBloqueio(String codigoBloqueio) {
this.codigoBloqueio = codigoBloqueio;
}
/**
* @return the nroOcorrencia
*/
public Long getNroOcorrencia() {
return nroOcorrencia;
}
/**
* @param nroOcorrencia
* the nroOcorrencia to set
*/
public void setNroOcorrencia(Long nroOcorrencia) {
this.nroOcorrencia = nroOcorrencia;
}
public HtmlDataTable getDataTableCliente() {
return dataTableCliente;
}
public void setDataTableCliente(HtmlDataTable dataTableCliente) {
if (dataTableCliente != null && dataTableCliente.getValue() == null) {
dataTableCliente.setValue(listaCliente);
}
this.dataTableCliente = dataTableCliente;
}
}
Falo
Resolvido o problema !
valew pessoal