|
52
|
Programación / Desarrollo Web / Spring MVC, problema de redireccionamiento despues de submit un modal
|
en: 3 Marzo 2021, 06:45 am
|
Hola, pasa que cuando hago un CRUD al confirmar el modal me redirije al index, como hago para que se fije en la misma pagina donde estaba? Estoy usando pagination. Por ejemplo en el borrar... <td><a data-toggle="modal" data-target="#removeModalNoticias" class="btn btn-danger delBtn" th:attr="data-target='#removeModalNoticias'+${noticia.id}">Eliminar <i class="fa fa-trash"></i> </a> <!-- #Modal for removing noticias --> <div class="modal fade" th:id="removeModalNoticias+${noticia.id}" id="removeModalNoticias" tabindex="-1" role="dialog" aria-labelledby="removeModalCenterTitle" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="removeModalCenterTitle">Eliminar <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <p class="alert alert-danger">Are You sure You want to <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close </button> <a th:href="@{/delete/(id=${noticia.id})}" class="btn btn-danger" id="delRef">Delete </a>
Y en el Controller... @GetMapping("/delete/{id}") noticia.deleteById(id); return "redirect://noticias"; }
Y el listar con pagination buenooo... @GetMapping(value = "/noticias") public String findAll (@RequestParam Map <String, Object > params, Model model ) { int page = params. get("page") != null ? Integer. valueOf(params. get("page"). toString()) - 1 : 0; PageRequest pageRequest = PageRequest.of(page, 5); Page<Noticia> pageNoticia = noticia.findAll(pageRequest); int totalPage = pageNoticia.getTotalPages(); if (totalPage > 0) { List<Integer> pages = IntStream.rangeClosed(1, totalPage).boxed().collect(Collectors.toList()); model.addAttribute("pages", pages); } model.addAttribute("list", pageNoticia.getContent()); model.addAttribute("current", page + 1); model.addAttribute("next", page + 2); model.addAttribute("prev", page); model.addAttribute("last", totalPage); return "noticias"; }
Me ayudan?
|
|
|
53
|
Programación / Desarrollo Web / Actualizar registro de tabla usando modal con SPring Boot, Java, thymeleaf
|
en: 3 Marzo 2021, 01:46 am
|
Hola, quiero hacer el modificar usando un modal, que se carguen los datos en el modal y luego de modificarlos salvarlos, no se como cargarlo ni nada, en otras tecnologias usaba metodos como onclick()="que lo hacia todo" jeje!! pero aca me cuesta este sería el "boton" <td><a data-toggle="modal" data-target="#updateModal" class="btn btn-warning" th:attr="data-target='#updateModal'+${noticia.id}">Editar <i
este el modal, lo deje afuera pero se q va a dentro de la etiqueta </td> <!--#Modal form for noticia update--> <div class="myFormUpdate"> <form th:action="@{/save}" method="post"> id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="updateModalLabel">Modificar <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <p class="alert alert-info">Input data to the fields </p> <!--<label for="id" class="col-form-label">User id:</th:text></label>--> <input type="hidden" class="form-control" id="id" th:name="id" value="" /> type="text" class="form-control" id="titulo" th:name="titulo" value="" /> <label for="descripcion" class="col-form-label">Descripcion: </label> <input type="text" class="form-control" id="descripcion" th:name="descripcion" value="" /> type="date" class="form-control" id="fecha" th:name="fecha" value="" /> <input id="fileUpload" type="file" style="margin-left: 20px" value="" th:name="imagen" /> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close </button> <input type="submit" class="btn btn-primary" value="Save" /> <!--End update form-->
mmm.. Y este es el método de mi controlador que debería actualizar el registro seleccionado @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public String edit (@PathVariable ("id") Long id, Model model ) { Optional<Noticia> noticia = this.noticia.findById(id); model.addAttribute("noticia", noticia); return "redirect:/noticias"; }
Me ayudan? Por lo menos a cargar el modal con los datos del registro...
|
|
|
54
|
Programación / Desarrollo Web / Crud en Spring Boot con Modales, Java, Spring Boot thymeleaf.
|
en: 2 Marzo 2021, 03:02 am
|
Hola, estoy intentando hacer un CRUD con las tecnologías mencionadas en el titulo pero no se que pasa, me sale error al cargar la página. este es mi html. <div th:insert="layout/header :: header"></div> <button type="button" class="btn btn-success" data-toggle="modal" data-target="#agregarNoticiaModal">Agregar </button> <div class="modal fade" id="agregarNoticiaModal" tabindex="-1" role="dialog" aria-labelledby="addClassModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="agregarNoticiaModalLabel">Agregar <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <form action="#" method="POST" th:action="@{/save}" th:object="${noticia}"> class="form-control" id="titulo" value="" th:name="titulo" /> class="form-control" id="descripcion" value="" th:name="descripcion" /> <input id="fileUpload" type="file" style="margin-left: 20px" value="" th:name="imagen" /> <input type="submit" value="Aceptar" /> <table class="table table-bordered table-responsive p-3"> <thead class="thead-dark"> <th style="width: 6%">ID </th> <th style="width: 10%">Imagen </th> <th style="width: 11%">Fecha </th> <th style="width: 10%">Editar </th> <th style="width: 10%">Eliminar </th> <tr class="text-center" th:each="noticia : ${list}"> <td th:text="${noticia.id}"></td> <td th:text="${noticia.titulo}"></td> <td th:text="${noticia.descripcion}"></td> <td><img class="card-img-top m-auto" th:src="${noticia.imagen}"></td> <td th:text="${noticia.fecha}"></td> <td><a class="btn btn-warning">Editar <i class="fa fa-edit"></i></a></td> <input type="hidden" name="id" /> <button type="submit" class="btn btn-danger"> Eliminar <i class="fa fa-trash"></i> <nav aria-label="Pagination"> <ul class="pagination justify-content-center"> th:classappend="${prev == 0 ? 'disabled': ''}"><a class="page-link" th:href="@{|/noticias/?page=${prev}|}">Anterior </a></li> <li class="page-item" th:each="page : ${pages}" th:classappend="${current == page ? 'active': ''}"><a class="page-link" th:href="@{|/noticias/?page=${page}|}" th:text="${page}"></a></li> th:classappend="${current == last ? 'disabled': ''}"><a class="page-link" th:href="@{|/noticias/?page=${next}|}">Siguiente </a></li> </nav> <div th:insert="layout/footer :: footer"></div>
Y los métodos de mi controlador para guardar son estos: @RequestMapping(value = "/save", method = RequestMethod.POST) public String save (@ModelAttribute ("noticia") Noticia noticia ) { this.noticia.save(noticia); return "redirect:/"; }
Que puede ser? Tambien sucede que cuando hago un alta me redirecciona al /index , cuando debería ser a /noticias
|
|
|
57
|
Programación / Programación General / DART modificar para que funcione la app
|
en: 13 Noviembre 2020, 18:15 pm
|
Esa es mi aplicacion debe leer un qr y el codigo enviarlo como peticion GET a un sitio devolver algo, con el json devuelto evalueo algunas cosas y segun eso muestro dos mensajes diferentes en la pantalla import 'package:flutter/material.dart'; //Agrego esta weas de librerias import 'package:barcode_scan/barcode_scan.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; void main() => runApp(MaterialApp( theme: ThemeData(primarySwatch: Colors.green), home: MyHomePage(), )); class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { ScanResult _scanResult; //Acá va la magía @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Lector códigos QR'), ), body: Center( child: _scanResult == null ? Text('Esperando datos de código') : Column( children: [ Text('Contenido: ${_scanResult.rawContent}'), Text('Estado: ${_validado}'), ], )), floatingActionButton: FloatingActionButton( onPressed: () { _scanCode(); }, child: Icon(Icons.camera), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, ); } //Método para escanear el codigo Qr Future<void> _scanCode() async { var result = await BarcodeScanner.scan(); recibirRespuestaGET(result.toString()); if (this._id == result.toString() && this._estado == "CONFIRMADO") { setState(() { _validado = "CONFIRMADO"; }); } else { setState(() { _validado = "DENEGADO"; }); } } Future<void> recibirRespuestaGET(String result) async { final respuesta = await http .get('https://mi-sitio.com/algo/?id=' + result); if (respuesta.statusCode == 200) { setState(() { var parsedJson = json.decode(respuesta.body); _id = parsedJson["_id"]; _estado = parsedJson["estado"]; }); } else { throw Exception("Fallo"); } } String _id; String _estado; String _validado = ""; }
|
|
|
59
|
Programación / Programación General / No me deja generar APK Flutter en Android Studio
|
en: 9 Noviembre 2020, 08:11 am
|
Alguien sabe, me sale esto :c You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64. If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size. To generate an app bundle, run: flutter build appbundle --target-platform android-arm,android-arm64,android-x64 Learn more on: https://developer.android.com/guide/app-bundle To split the APKs per ABI, run: flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\anne\Desktop\GitHub\qrCoder\lector_qr\android\build.gradle' line: 33 * What went wrong: A problem occurred evaluating root project 'android'. > Could not find method android() for arguments [build_eoh40gz68wo3bxgdfkmy2r7vf$_run_closure5@5a9e48fa] on root project 'android' of type org.gradle.api.Project. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.orgBUILD FAILED in 3s Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... Done 5,4s Gradle task assembleRelease failed with exit code 1 Que horror :c
|
|
|
|
|
|
|