Boa noite
Pessoal estou com um problema..
Meu sisteminha tem Cliente (classe pai) e PessoaFisica e PessoaJuridica que herda de cliente.
meu controlador esta assim:
public class ClienteCTR extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Cliente cli = new Cliente();
PessoaFisica pf = new PessoaFisica();
PessoaJuridica pj = new PessoaJuridica();
ClienteDAO daoC = new ClienteDAO();
cli.setCodigo(Integer.parseInt(request.getParameter("codigo").toUpperCase()));
cli.setNome(request.getParameter("nome").toUpperCase());
cli.setRua(request.getParameter("rua").toUpperCase());
cli.setNumero(request.getParameter("numero"));
cli.setCep(request.getParameter("cep"));
cli.setBairro(request.getParameter("bairro").toUpperCase());
cli.setCidade(request.getParameter("cidade").toUpperCase());
cli.setEstado(request.getParameter("estado"));
cli.setPais(request.getParameter("pais").toUpperCase());
cli.setTelefone(request.getParameter("telefone"));
//testando para passar as informações para a tela.
String tipo = request.getParameter("tipo");
if(tipo.equals("pFisica")){
pf = new PessoaFisica(cli);
// recupera os dados de fisico
pf.setRg(request.getParameter("rg"));
pf.setCpf(request.getParameter("cpf"));
DateFormat fmtData = new SimpleDateFormat("dd/MM/yyyy");
String data = request.getParameter("dataNascimento");
try {
pf.setDataNascimento(new Date(fmtData.parse(data).getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
pf.setSexo(request.getParameter("sexo"));
//salvar no banco
daoC.salvar(pf);
}
/*
pf.setRg(request.getParameter("rg").toUpperCase());
pf.setCpf(request.getParameter("cpf").toUpperCase());
pf.setSexo(request.getParameter("sexo").toUpperCase());
*/
if(tipo.equals("Pjuridica")){
pj = new PessoaJuridica(cli);
pj.setCnpj(request.getParameter("cnpj"));
pj.setInscricaoEstadual(request.getParameter("inscricaoEstadual"));
//salvar no banco
daoC.salvar(pj);
}
/*
pj.setCnpj(request.getParameter("cnpj"));
pj.setInscricaoEstadual(request.getParameter("inscricaoEstadual"));
*/
// daoC.salvar(cli);
response.setCharacterEncoding("ISO-8859-1");
request.setAttribute("cliente", cli);
request.setAttribute("pessoaJuridica", pj);
request.setAttribute("pessoaFisica", pf);
RequestDispatcher visao = request.getRequestDispatcher("respCliente.jsp");
visao.forward(request, response);
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
Nome:<input type="text" name="valorPesquisa" />
<button type="submit">Pesquisar</button>
</form>
<p/>
<table>
<tr>
<th>Código</th>
<th>Nome</th>
<th>Rua</th>
<th>Numero</th>
<th>CEP</th>
<th>Bairro</th>
<th>Cidade</th>
<th>Estado</th>
<th>Pais</th>
<th>Telefone</th>
<th>RG</th>
<th>CPF</th>
<th>Sexo</th>
<th>Data Nascimento</th>
<th>CNPJ</th>
<th>Ins. Estadual</th>
</tr>
<%
List<Cliente> listaCliente =(List<Cliente>)
request.getAttribute("listaCliente");
for(Cliente cli: listaCliente){
%>
<%
List<PessoaFisica> listaPF =(List<PessoaFisica>)
request.getAttribute("listaPF");
for(PessoaFisica pf: listaPF){
%>
<%
List<PessoaJuridica> listaPJ =(List<PessoaJuridica>)
request.getAttribute("listaPJ");
for(PessoaJuridica pj: listaPJ){
%>
<tr>
<td><%=cli.getCodigo()%></td>
<td><%=cli.getNome() %></td>
<td><%=cli.getRua() %></td>
<td><%=cli.getNumero() %></td>
<td><%=cli.getCep() %></td>
<td><%=cli.getBairro() %></td>
<td><%=cli.getCidade() %></td>
<td><%=cli.getEstado() %></td>
<td><%=cli.getPais() %></td>
<td><%=cli.getTelefone() %></td>
<td><%=pf.getRg() %></td>
<td><%=pf.getCpf() %></td>
<td><%=pf.getSexo() %></td>
<td><%=pf.getDataNascimento() %></td>
<td><%=pj.getCnpj() %></td>
<td><%=pj.getInscricaoEstadual() %></td>
</tr>
<%
}
%>
</table>
</div>
<jsp:include page="libs/rodape.jsp"></jsp:include>
</div>
</body>
</html>
Se eu tirar as lista de PF e PJ. O relatório sai com os dados de CLIENTE, os dados caso for PFisica ou Pjuridica.
como fazer o relatorio mostrar os dados completo???
Pode ser com expressão de linguagem também...
obrigado