public Result listarAlumnos() { Result res; List<Alumno> alumnos = Alumno.findAll(); if (ControllerHelper.acceptsJson(request())) { res = ok(Json.toJson(alumnos)); } else if (ControllerHelper.acceptsXml(request())) { res = ok(views.xml.alumnos.render(alumnos)); } else { res = badRequest(ControllerHelper.errorJson(1, "unsupported_format", null)); } return res; }
// {"id":"12345678", "nombre":"aaaa", "apellido1":"bbbb", "apellido2":"ccccc"} public Result getAlumno(String id) { Result res; Alumno alumno = Alumno.find.byId(id); if (alumno == null) { res = notFound(); } else { if (ControllerHelper.acceptsJson(request())) { res = ok(Json.toJson(alumno)); } else if (ControllerHelper.acceptsXml(request())) { res = ok(views.xml.alumno.render(alumno)); } else { res = badRequest(ControllerHelper.errorJson(1, "unsupported_format", null)); } } return res; }