Galera estou tendo um problema com uma popup que não esta retornando o valor.
Eu tenho essa mesma popup em outro projeto, porém sem o Spring.
O que acontece, na tela de cadastro de locação, eu preciso selecionar o cliente e o veiculo. Para isso, eu abro um popup que mostra a lista com todos os clientes ou veiculos, e quando o usuario clica em selecionar, ele deveria retornar apenas o codido e modelo do veiculo, ou codigo e nome do cliente. Porém, quando clico em selecionar, não esta acontecendo nada, nem sequer o window.close esta rolando.
Se alguém souber o que posso fazer, eu agradeço.
Segue o código.
Formulario de cadastro
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
<script>
var popup; //A global variable that will act as the Popup ID
function selecionarCliente() {
//Create the popup and store the returning id in the variable
popup = window.open("selecaoCliente", "popup_id",
"scrollbars,resizable,width=800,height=400");
}
function selecionarVeiculo() {
//Create the popup and store the returning id in the variable
popup = window.open("selecaoVeiculo", "popup_id",
"scrollbars,resizable,width=600,height=600");
}
</script>
</head>
<body>
<h3>Adicionar Locação</h3>
<form action="adicionaLocacao" method="post"><br>
dataLocacao:* <input type="text" name="dataLocacao"> <br>
dataDevolucaoPrev:* <input type="text" name="dataDevolucaoPrev"> <br>
ID cliente:* <input type="text" name="idCliente"> <input type="button" value="Selecionar" onclick="selecionarCliente()"> <br>
Nome cliente:* <input type="text" name="nomeCliente"> <br>
ID veiculo:* <input type="text" name="idVeiculo"> <input type="button" value="Selecionar" onclick="selecionarVeiculo()"><br>
Modelo veiculo:* <input type="text" name="modeloVeiculo"> <br>
bebe: <input type="checkbox" name="bebe"> <br>
gps: <input type="checkbox" name="gps"> <br>
motorista: <input type="checkbox" name="motorista"> <br>
valor: <input type="text" readonly="readonly" name="valor"> <br>
multa: <input type="text" readonly="readonly" name="multa"> <br>
total: <input type="text" readonly="readonly" name="total"> <br>
<input type="submit" value="Adicionar">
</form>
</body>
</html>
Lista de seleção
<html>
<head>
<!--Importa JSTL-->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<script>
function putData(id, modelo) {
var data1 = id;
var data2 = modelo;
window.opener.document.getElementById('idVeiculo').value = data1;
window.opener.document.getElementById('modeloVeiculo').value = data2;
window.close();
}
</script>
</head>
<body>
<form action="buscaVeiculo">
Procurar: <input type="text" name="filtro">
<input type="submit" value="Buscar">
</form>
<table>
<tr>
<th>Id</th>
<th>Fabricante</th>
<th>Modelo</th>
<th>Portas</th>
<th>Reservado</th>
<th>KM</th>
<th>Selecionar</th>
</tr>
<c:forEach items="${veiculos}" var="veiculo">
<tr>
<td>${veiculo.id}</td>
<td>${veiculo.fabricante}</td>
<td>${veiculo.modelo}</td>
<td>${veiculo.portas}</td>
<c:if test="${veiculo.reservado eq false}">
<td>Dispoível</td>
</c:if>
<c:if test="${veiculo.reservado eq true}">
<td>Reservado</td>
</c:if>
<td>${veiculo.km}</td>
<td><input type="button" value="Selecionar" onClick="putData('${veiculo.id}', '${veiculo.modelo}')"></td>
</tr>
</c:forEach>
</table>
</body>
</html>