Ola pessoal, eu consegui resolver o problema dos valores, mas agora estou com um outro problema.
Meu jsp usa uma classe para preencher o datatable e outra classe para pegar o valor selecionado, mas com isso não está me trazendo a tabela preenchida ele continua na tabela de seleção de data conforme abaixo:
Mês
03/2011
04/2011
06/2011
com isso eu selecionando o valor 04/2011 ele me traria a seguinte tela:
Faturas
sequencia tipo fatura valor vencimento Finalizar
02 financeira R$ 20,00 10/04/2011 Imprimir
Mas o que vem na realidade é novamente a tela anterior
Mês
03/2011
04/2011
06/2011
Debugando eu vi que ele não finaliza no return list deste metodo e sim em outro return de onde pega o valor de RowSelectorEvent
Como eu posso resolver este problema?
package br.com.financeiro.controle.usuario;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.servlet.http.HttpSession;
import com.icesoft.faces.component.ext.RowSelectorEvent;
import br.com.webdec.entidade.BoletoEmAberto;
import br.com.webdec.entidade.Competencia;
import br.com.webdec.util.ConnectionFactory;
public class ControleBoletoEmAberto {
private BoletoEmAberto boletoAberto;
private FacesContext context = (FacesContext) FacesContext.getCurrentInstance();
private HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
List<Competencia> lista;
List<Competencia> lista_comp;
String listar;
String valorLinha;
String chave = (String) session.getAttribute("chave_user");
ControleCompetencia controleCompetencia = new ControleCompetencia();
public BoletoEmAberto getBoletoAberto() {
return boletoAberto;
}
public void setBoletoAberto(BoletoEmAberto boletoAberto) {
this.boletoAberto = boletoAberto;
}
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
DataModel model;
BoletoEmAberto boleto;
Competencia competencias;
String competencia;
public ControleBoletoEmAberto() throws Exception{
boleto = new BoletoEmAberto();
boleto.setChave((String) session.getAttribute("seq_adotante"));
//boleto.setChave("PF29466");
}
public DataModel getTodos() throws Exception //throws Exception
{
model = new ListDataModel(todosBoletoEmAberto(competencia));
return model;
}
@SuppressWarnings("unchecked")
public List Competencia() throws Exception {
try{
this.conn = ConnectionFactory.getConnection();
String SQLCompetencia = "select distinct competencia from vw_web_boleto where seq_adotante = ? order by competencia";
stmt = conn.prepareStatement(SQLCompetencia);
stmt.setString(1,boleto.getChave());
rs = stmt.executeQuery();
List<Competencia> list = new ArrayList<Competencia>();
lista_comp = new ArrayList<Competencia>();
if(!rs.next()){
System.out.println("Nao ha Registros ");
}else{
while(rs.next()){
String competencia = rs.getString(1);
list.add(new Competencia(competencia));
lista_comp.add(new Competencia(competencia));
}
}
return list;
}catch(SQLException ex){
throw new Exception(ex);
}finally{
ConnectionFactory.closeConnection(conn, stmt, rs);
}
}
public List<Competencia> selecionouLinha(RowSelectorEvent linha) throws Exception { // pego o numero da linha selecionada
Competencia();
int selectedRowIndex = linha.getRow();
linha.getSelectedRows().toArray();
int selectedRow = linha.getRow();
int linhaselec = linha.getRow();
System.out.println(selectedRowIndex);
valorLinha = lista_comp.get(selectedRow).getCompetencia(); // aqui eu comparo o numero da linha com a lista
System.out.println(valorLinha);
todosBoletoEmAberto(valorLinha);
// ControleCompetencia cc = new ControleCompetencia(); // aqui eu chamo a outra classe e passo o numero da linha
// cc.selecionarLinha(linha);
// valorLinha = lista_comp.get(selectedRow).getCompetencia();
return lista;
}
@SuppressWarnings("unchecked")
public List todosBoletoEmAberto(String valorLinha) throws Exception{
try{
this.conn = ConnectionFactory.getConnection();
competencia = valorLinha;
System.out.println(competencia);
String SQLboleto = "select chave, valor,to_char(data_processamento,'dd/mm/yyyy') as data_processamento, "+
"to_char(data_vencimento,'dd/mm/yyyy') as data_vencimento1,"+
"nvl(plano,'00') as plano, destino, id_boleto "+
"from vw_web_boleto where seq_adotante=?"+
"and competencia = ?";
System.out.println(SQLboleto);
stmt = conn.prepareStatement(SQLboleto);
stmt.setString(1,boleto.getChave());
stmt.setString(2,competencia);
rs = stmt.executeQuery();
System.out.println(SQLboleto);
List<BoletoEmAberto> list = new ArrayList<BoletoEmAberto>();
if(!rs.next()){
System.out.println("Nao ha Registros ");
}else{
while(rs.next()){
String valor = rs.getString(2);
String dtProcessamento = rs.getString(3);
String dtVencimento = rs.getString(4);
String plano = rs.getString(5);
String destino = rs.getString(6);
String idboleto = rs.getString(7);
list.add(new BoletoEmAberto(valor,dtProcessamento,dtVencimento,plano,destino, idboleto));
}
}
return list;
}catch(SQLException ex){
throw new Exception(ex);
}finally{
ConnectionFactory.closeConnection(conn, stmt, rs);
}
}
public BoletoEmAberto getBoletoImprimir() {
BoletoEmAberto boleto = (BoletoEmAberto) model.getRowData();
session.setAttribute("venc_boleto",boleto.getDt_vencimento());
session.setAttribute("id_boleto", boleto.getId_boleto());
return boleto;
}
public String imprimir() {
setBoletoAberto(getBoletoImprimir());
return "sucesso";
}
public List<Competencia> getLista() {
return lista;
}
public void setLista(List<Competencia> lista) {
this.lista = lista;
}
} // fim