Boa tarde, estou com uma dúvida a respeito script, eu tenho um tela que mostra os pedidos referente a certo usuario
e nessa tela tem uma opção de mostra os detalhes desse pedido, pensei em fazer com aquelas caixas de dialogos
até achei um modelo e já fiz todo o processo para recuperar os dados, mas como faço para essa caixa de dialogo aparece sobre a primeira tela que abri com o resultados dos pedidos do usuario
segue abaixo o que conseguir fazer
Essa tela é onde eu chamo os detalhes referente ao pedido selecionado
`<%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core”%>
<%@taglib uri=“http://java.sun.com/jsp/jstl/fmt” prefix=“f”%>
<div id="fundo">
<div id="Layer1">
<div align="center" class="style1">PEDIDOS</div>
</div>
<div id="divtable2">
<table id="t01" width="750" align="center">
<tr align="center" bgcolor="#F58634">
<th>Id</th>
<th>Quantidade Total</th>
<th>Valor Total</th>
<th>Data do Pedido</th>
<th>Nome Cliente</th>
<th>Detalhes</th>
</tr>
<c:forEach var="lista" items="${listaPedidos}" >
<tr>
<td align="center">${lista.id}</td>
<td align="center">${lista.quantidadeTotal}</td>
<f:setLocale value="pt_BR"/>
<td align="center"><f:formatNumber minFractionDigits="2" type="currency">${lista.valorTotal} </f:formatNumber></td>
<td align="center"><f:formatDate value="${lista.dataPedido.time}" pattern="dd/MM/yyyy"/></td>
<td align="center">${lista.cliente.nome}</td>
<td align="center"><a href="/ControlePedidos/PesquisaPedidos?acao=detalhes&id=${lista.id}"><img src="imagens/iconePesq.jpg" width="18" height="18"></a></td>
</tr>
</c:forEach>
</table>
</div>
`
Essa tela é onde recupero as informações referente ao detalhes do pedido:
`package br.com.acme.cadastro.controle;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import br.com.acme.cadastro.cliente.ItemPedidoNegocio;
import br.com.acme.cadastro.cliente.PedidoNegocio;
import br.com.acme.cadastro.entidade.ClienteEntidade;
import br.com.acme.cadastro.entidade.ItemPedidoEntidade;
import br.com.acme.cadastro.entidade.PedidoEntidade;
import br.com.acme.cadastro.excecoes.CampoVazioException;
@WebServlet(urlPatterns = {"/PesquisaPedidos"})
public class PesquisaPedidos extends HttpServlet {
private static final long serialVersionUID = 1L;
private String acao = null;
private PedidoNegocio pedidoNegocio = null;
private ClienteEntidade objCliente = null;
private List<PedidoEntidade> listPedidos = null;
private ItemPedidoNegocio itemNegocio = null;
private PedidoEntidade objPedido = null;
private Long idCliente = null;
private List<ItemPedidoEntidade> listaDetalhada = null;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
acao = request.getParameter("acao");
if(acao == null)acao = "";
try {
if (acao.contains("detalhes")) {
idCliente = Long.parseLong(request.getParameter("id"));
objPedido = new PedidoEntidade();
objPedido.setId(idCliente);
listaDetalhada = new ArrayList<ItemPedidoEntidade>();
itemNegocio = new ItemPedidoNegocio();
listaDetalhada = itemNegocio.detalharPedido(objPedido);
request.setAttribute("detalhesPedidos", listaDetalhada);
RequestDispatcher rd = request.getRequestDispatcher("cadastro/mostraDetalhesPedidos.jsp");
rd.forward(request, response);
} else {
objCliente = new ClienteEntidade();
objCliente.setId(Long.parseLong(request.getParameter("cmbCliente")));
listPedidos = new ArrayList<PedidoEntidade>();
pedidoNegocio = new PedidoNegocio();
listPedidos = pedidoNegocio.pesquisar(objCliente);
request.setAttribute("listaPedidos", listPedidos);
RequestDispatcher rd = request.getRequestDispatcher("cadastro/listPedidos.jsp");
rd.forward(request, response);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (CampoVazioException e) {
e.printStackTrace();
}
}
}
Tela do script:
<%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core”%>
<%@taglib uri=“http://java.sun.com/jsp/jstl/fmt” prefix=“f”%>
<table id="t01" width="750" align="center">
<tr align="center" bgcolor="#F58634">
<th>Descrição</th>
<th>Quantidade</th>
<th>Valor Total</th>
</tr>
<c:forEach var="lista" items="${detalhesPedidos}" >
<tr>
<td align="center">${lista.produto.descricao}</td>
<td align="center">${lista.quantidade}</td>
<f:setLocale value="pt_BR"/>
<td align="center"><f:formatNumber minFractionDigits="2" type="currency">${lista.valorTotal} </f:formatNumber></td>
</tr>
</c:forEach>
</table>
teste de dialogo
` se alguém puder dar uma mãozinha