Boa noite parceiros,
Estou com um problema em minha aplicação, pois não consigo puxar informações na base e colocar nos campos.
Pagina:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<c:import url="/includes/imports.jsp" />
<script type="text/javascript">
function consultar(id) {
$.getJSON('<c:url value="/clinico/editaProcedimento/" />' + id, function(
json) {
$('#teste').val(json.Procedimento.nome);
})
}
</script>
<title>Procedimentos</title>
</head>
<body>
<c:import url="/includes/menu.jsp"></c:import>
<br><BR/>
<div id="principal">
<div id="actionBar">
<input type="text" name="pesquisa" value="Pesquisa por nome" />
<br />
<button>
Pesquisar
</button>
<br />
<c:forEach items="${procedimentoList}" var="procedimento">
<div class="pesquisa">
<a onclick="consultar(${procedimento.id})">${procedimento.nome}</a>
</div>
</c:forEach>
</div>
<div id="conteudo">
<fieldset>
<form action="<c:url value="/clinico/salvaProcedimento" />">
<button>
Salvar
</button>
<button>
Voltar
</button>
<br />
<br />
<table>
<tr>
<td>
ID
</td>
<td>
<input type="text" name="procedimento.id">
</td>
</tr>
<tr>
<td>
Nome
</td>
<td>
<input type="text" name="procedimento.nome">
</td>
</tr>
<tr>
<td>
Valor
</td>
<td>
<input type="text" name="procedimento.valor">
</td>
</tr>
<tr>
<td>
Especialidade
</td>
<td>
<select name="procedimento.especialidade">
<option>
Teste
</option>
<option>
Teste2
</option>
</select>
</td>
</tr>
<tr>
<td>
Descrição
</td>
<td>
<textarea cols="15" rows="4" name="procedimento.descricao"></textarea>
</td>
</tr>
</table>
</form>
</fieldset>
</div>
</div>
<c:import url="/includes/dock.jsp" />
</body>
</html>
Controller
@Path("/clinico/editaProcedimento/{procedimento.id}")
public void editaProcedimento(Procedimento procedimento) {
Procedimento procedimentoProcurado = new ProcedimentoDao().buscaPorId(procedimento);
result.use(json()).from(procedimentoProcurado).serialize();
}
Alguem pode me ajudar?
Obrigado!