Chamada de métodos com struts 1

3 respostas
arthurgon

Olá galera…meu problema é o seguinte…tenho uma classe Action, e a partir dela preciso chamar campos de consulta q serão exibidos em uma tela JSP.
Preciso saber como faço para chamar esses campos da minha classe DAO. Não tenho a menor experiencia com JDBC.
Os campos…a classe DAO…está tudo pronto. Só preciso chamar agora o método. Como faço esse método?

3 Respostas

alanbrasil1984

posta ai os codigos que fica melhor de expliar…

F

Pra chamar um método da action a partir do jsp é só usar o nomedaaction.do?method=nomedometodo

arthurgon

alanbrasil1984:
posta ai os codigos que fica melhor de expliar…

Preciso de uma action q chame esse método:

// CAMPOS INSERIDOS PARA VIZUALIZAR DADOS DA CONTA DO CLIENTE NA TELA DE
// CONSULTA DE CLIENTES

/**
 * @param id
 *            o ID do cliente
 * @param tipoPessoa
 *            o tipo de pessoa (fisica ou juridica)
 * 
 * @return o cliente pelo seu ID e o tipo
 * 
 * @throws CommerceException
 */
public ClienteBean getConsultaCliente(Long  codigoCliente, 
	String tipoPessoa)throws CommerceException {

	
	ClienteBean cBean = null;

	Connection con = null;
	PreparedStatement ps = null;
	ResultSet rs = null;

	try {

		
		StringBuffer campos = new StringBuffer();
			
			//ATRIBUTOS DA TABELA CLIENTE_CONTA
			
			//campos.append("SELECT ");
			
			campos.append("ID_CONTA, ");
			campos.append("VL_LIM_DIA, ");
			campos.append("VL_LIM_GLOB_CONCEDIDO, ");
			campos.append("VL_LIM_GLOB_DISPONIVEL, ");
			campos.append("VL_LIM_COMP_DISPONIVEL, ");
			campos.append("DT_BASE, ");
			campos.append("CD_AFINIDADE, ");
			// ATRIBUTOS DA TABELA CLIENTE_CARTAO
			campos.append("NR_CARTAO,  ");
			campos.append("ST_TITULAR,   ");
			campos.append("VL_LIM_CRED_DISPONIVEL,   ");
			campos.append("ID_CONVENIO,    ");
			
			//campos.append("FROM ");
			//campos.append("V_CLIENTE_CARTAO ");
			
			//campos.append("WHERE ");
			//campos.append("ID_CLI = ?");
	
		con = super.getConnection();

		ps = con.prepareStatement(this.getQueryCliente(campos, tipoPessoa,
				true, false, false));

		ps.setLong(1,  codigoCliente.longValue());

		rs = ps.executeQuery();

		if (rs.next()) {
			//ATRIBUTOS CLIENTE_CONTA
			cBean.setIdConta(new Long(rs.getLong("ID_CONTA")));
			cBean.setAfinidade(rs.getInt("CD_AFINIDADE"));
			cBean
					.setVlLimiteDia(new Double(rs
							.getDouble("VL_LIM_DIA")));
			cBean.setVlLimiteGlobConcedido(new Double(rs
					.getDouble("VL_LIM_GLOB_CONCEDIDO")));
			cBean.setVlLimiteGlobDisponivel(new Double(rs
					.getDouble("VL_LIM_GLOB_DISPONIVEL")));
			cBean.setVlLimiteCompDisponivel(new Double(rs
					.getDouble("VL_LIM_COMP_DISPONIVEL")));
			cBean.setDataBase(new Integer(rs.getInt("DT_BASE")));
			//ATRIBUTOS CLIENTE_CARTAO
			cBean.setNrCartao(new Long(rs.getLong("NR_CARTAO")));
			cBean.setSitTitular(rs.getString("ST_TITULAR"));
			cBean.setVlLimiteCredDispovivel(new Double(rs
					.getDouble("VL_LIM_CRED_DISPONIVEL")));
			cBean.setIdConvenio(new Integer(rs.getInt("ID_CONVENIO")));
		
			
			
			this.setDadosComplementaresCliente(cBean, con);
			
			//this.visualizarDetalheContaCliente_executar(codigoCliente, tipoPessoa, mapping, form, request, response);
		
			
		
		}

		return cBean;

	} catch (SQLException e) {
		throw new CommerceException(e.getMessage(), e.getErrorCode());
	} catch (Exception e) {
		throw new CommerceException(e.getMessage());
	} finally {
		super.closeObjetosConexao(con, ps, rs);
	}

}

Criado 1 de abril de 2008
Ultima resposta 1 de abr. de 2008
Respostas 3
Participantes 3