elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


  Mostrar Temas
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 31
51  Programación / Desarrollo Web / algun curso de spring boot? en: 13 Marzo 2021, 07:47 am
gracias!  :huh:
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...

Código
  1. <td>
  2. <td><a data-toggle="modal" data-target="#removeModalNoticias"
  3. class="btn btn-danger delBtn"
  4. th:attr="data-target='#removeModalNoticias'+${noticia.id}">Eliminar
  5. <i class="fa fa-trash"></i>
  6. </a> <!-- #Modal for removing noticias -->
  7. <div class="modal fade" th:id="removeModalNoticias+${noticia.id}"
  8. id="removeModalNoticias" tabindex="-1" role="dialog"
  9. aria-labelledby="removeModalCenterTitle" aria-hidden="true">
  10. <div class="modal-dialog modal-dialog-centered" role="document">
  11. <div class="modal-content">
  12. <div class="modal-header">
  13. <h4 class="modal-title" id="removeModalCenterTitle">Eliminar
  14. Noticia</h4>
  15. <button type="button" class="close" data-dismiss="modal"
  16. aria-label="Close">
  17. <span aria-hidden="true">&times;</span>
  18. </button>
  19. </div>
  20. <div class="modal-body">
  21. <p class="alert alert-danger">Are You sure You want to
  22. delete this Noticia?</p>
  23. </div>
  24. <div class="modal-footer">
  25. <button type="button" class="btn btn-secondary"
  26. data-dismiss="modal">Close</button>
  27. <a th:href="@{/delete/(id=${noticia.id})}"
  28. class="btn btn-danger" id="delRef">Delete</a>
  29. </div>
  30. </div>
  31. </div>
  32. </div></td>
  33. </td>

Y en el Controller...

Código
  1. @GetMapping("/delete/{id}")
  2. public String delete(Long id) {
  3. noticia.deleteById(id);
  4. return "redirect://noticias";
  5. }

Y el listar con pagination buenooo...

Código
  1. @GetMapping(value = "/noticias")
  2. public String findAll(@RequestParam Map<String, Object> params, Model model) {
  3.  
  4. int page = params.get("page") != null ? Integer.valueOf(params.get("page").toString()) - 1 : 0;
  5.  
  6. PageRequest pageRequest = PageRequest.of(page, 5);
  7.  
  8. Page<Noticia> pageNoticia = noticia.findAll(pageRequest);
  9.  
  10. int totalPage = pageNoticia.getTotalPages();
  11.  
  12. if (totalPage > 0) {
  13. List<Integer> pages = IntStream.rangeClosed(1, totalPage).boxed().collect(Collectors.toList());
  14. model.addAttribute("pages", pages);
  15. }
  16.  
  17. model.addAttribute("list", pageNoticia.getContent());
  18. model.addAttribute("current", page + 1);
  19. model.addAttribute("next", page + 2);
  20. model.addAttribute("prev", page);
  21. model.addAttribute("last", totalPage);
  22.  
  23. return "noticias";
  24. }

Me ayudan?   :huh:
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"

Código
  1. <td><a data-toggle="modal" data-target="#updateModal"
  2. class="btn btn-warning"
  3. th:attr="data-target='#updateModal'+${noticia.id}">Editar <i
  4. class="fa fa-edit"></i>
  5. </a></td>

este el modal, lo deje afuera pero se q va a dentro de la etiqueta </td>

Código
  1. <!--#Modal form for noticia update-->
  2. <div class="myFormUpdate">
  3. <form th:action="@{/save}" method="post">
  4. <div class="modal fade"
  5. id="updateModal" tabindex="-1" role="dialog"
  6. aria-labelledby="updateModalLabel" aria-hidden="true">
  7. <div class="modal-dialog" role="document">
  8. <div class="modal-content">
  9. <div class="modal-header">
  10. <h4 class="modal-title" id="updateModalLabel">Modificar
  11. Noticia</h4>
  12. <button type="button" class="close" data-dismiss="modal"
  13. aria-label="Close">
  14. <span aria-hidden="true">&times;</span>
  15. </button>
  16. </div>
  17. <div class="modal-body">
  18. <p class="alert alert-info">Input data to the fields</p>
  19. <div class="form-group">
  20. <!--<label for="id" class="col-form-label">User id:</th:text></label>-->
  21. <input type="hidden" class="form-control" id="id" th:name="id"
  22. value="" />
  23. </div>
  24. <div class="form-group">
  25. <label for="titulo" class="col-form-label">Titulo:</label> <input
  26. type="text" class="form-control" id="titulo" th:name="titulo"
  27. value="" />
  28. </div>
  29. <div class="form-group">
  30. <label for="descripcion" class="col-form-label">Descripcion:</label>
  31. <input type="text" class="form-control" id="descripcion"
  32. th:name="descripcion" value="" />
  33. </div>
  34. <div class="form-group">
  35. <label for="fecha" class="col-form-label">Fecha:</label> <input
  36. type="date" class="form-control" id="fecha" th:name="fecha"
  37. value="" />
  38. </div>
  39. <div class="form-group">
  40. <label for="fileUpload">Imagen:</label>
  41. <fieldset style="margin-left: 10px;">
  42. <input id="fileUpload" type="file" style="margin-left: 20px"
  43. value="" th:name="imagen" />
  44. </div>
  45. </div>
  46. <div class="modal-footer">
  47. <button type="button" class="btn btn-secondary"
  48. data-dismiss="modal">Close</button>
  49. <input type="submit" class="btn btn-primary" value="Save" />
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </form>
  55. </div>
  56. <!--End update form-->

mmm..
Y este es el método de mi controlador que debería actualizar el registro seleccionado

Código
  1. @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
  2.    public String edit(@PathVariable("id") Long id, Model model) {
  3.        Optional<Noticia> noticia = this.noticia.findById(id);
  4.        model.addAttribute("noticia", noticia);
  5.        return "redirect:/noticias";
  6.    }
  7.  

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.

Código
  1.  
  2. <div th:insert="layout/header :: header"></div>
  3.  
  4. <div class="col-12">
  5. <h2>Noticias</h2>
  6. <div class="alert"></div>
  7.  
  8.  
  9. <button type="button" class="btn btn-success" data-toggle="modal"
  10. data-target="#agregarNoticiaModal">Agregar</button>
  11.  
  12. <div class="modal fade" id="agregarNoticiaModal" tabindex="-1"
  13. role="dialog" aria-labelledby="addClassModalLabel" aria-hidden="true">
  14. <div class="modal-dialog" role="document">
  15. <div class="modal-content">
  16. <div class="modal-header">
  17. <h4 class="modal-title" id="agregarNoticiaModalLabel">Agregar
  18. Noticia</h4>
  19. <button type="button" class="close" data-dismiss="modal"
  20. aria-label="Close">
  21. <span aria-hidden="true">&times;</span>
  22. </button>
  23. </div>
  24.  
  25. <div class="modal-body">
  26. <form action="#" method="POST" th:action="@{/save}"
  27. th:object="${noticia}">
  28. <div class="form-group">
  29. <label for="titulo">Titulo:</label> <input type="text"
  30. class="form-control" id="titulo" value="" th:name="titulo" />
  31. </div>
  32. <div class="form-group">
  33. <label for="descripcion">Descripcion:</label> <input type="text"
  34. class="form-control" id="descripcion" value=""
  35. th:name="descripcion" />
  36. </div>
  37.  
  38. <div class="form-group">
  39. <label for="fileUpload">Imagen:</label>
  40. <fieldset style="margin-left: 10px;">
  41. <input id="fileUpload" type="file" style="margin-left: 20px"
  42. value="" th:name="imagen" />
  43. </div>
  44.  
  45. <input type="submit" value="Aceptar" />
  46. </form>
  47. </div>
  48.  
  49. </div>
  50. </div>
  51.  
  52. </div>
  53.  
  54. <table class="table table-bordered table-responsive p-3">
  55. <thead class="thead-dark">
  56. <tr class="text-center">
  57. <th style="width: 6%">ID</th>
  58. <th>Titulo</th>
  59. <th>Descripción</th>
  60. <th style="width: 10%">Imagen</th>
  61. <th style="width: 11%">Fecha</th>
  62. <th style="width: 10%">Editar</th>
  63. <th style="width: 10%">Eliminar</th>
  64. </tr>
  65. </thead>
  66. <tr class="text-center" th:each="noticia : ${list}">
  67. <td th:text="${noticia.id}"></td>
  68. <td th:text="${noticia.titulo}"></td>
  69. <td th:text="${noticia.descripcion}"></td>
  70. <td><img class="card-img-top m-auto"
  71. th:src="${noticia.imagen}"></td>
  72. <td th:text="${noticia.fecha}"></td>
  73. <td><a class="btn btn-warning">Editar <i
  74. class="fa fa-edit"></i></a></td>
  75. <td>
  76. <form method="post">
  77. <input type="hidden" name="id" />
  78. <button type="submit" class="btn btn-danger">
  79. Eliminar <i class="fa fa-trash"></i>
  80. </button>
  81. </form>
  82. </td>
  83. </tr>
  84. </tbody>
  85. </table>
  86.  
  87. <div class="row">
  88. <div class="col-md-2"></div>
  89. <div class="col-md-8">
  90. <nav aria-label="Pagination">
  91. <ul class="pagination justify-content-center">
  92. <li class="page-item"
  93. th:classappend="${prev == 0 ? 'disabled': ''}"><a
  94. class="page-link" th:href="@{|/noticias/?page=${prev}|}">Anterior</a></li>
  95. <li class="page-item" th:each="page : ${pages}"
  96. th:classappend="${current == page ? 'active': ''}"><a
  97. class="page-link" th:href="@{|/noticias/?page=${page}|}"
  98. th:text="${page}"></a></li>
  99. <li class="page-item"
  100. th:classappend="${current == last ? 'disabled': ''}"><a
  101. class="page-link" th:href="@{|/noticias/?page=${next}|}">Siguiente</a></li>
  102. </ul>
  103. </nav>
  104. </div>
  105. <div class="col-md-2"></div>
  106. </div>
  107.  
  108. </div>
  109.  
  110.  
  111.  
  112.  
  113.  
  114. <div th:insert="layout/footer :: footer"></div>
  115. </body>

Y los métodos de mi controlador para guardar son estos:

Código
  1. @RequestMapping(value = "/save", method = RequestMethod.POST)
  2. public String save(@ModelAttribute("noticia") Noticia noticia) {
  3. this.noticia.save(noticia);
  4. return "redirect:/";
  5. }

Que puede ser? Tambien sucede que cuando hago un alta me redirecciona al /index , cuando debería ser a /noticias :(

55  Programación / Desarrollo Web / Problemita con mis urls, Java, Spring Boot thymeleaf en: 1 Marzo 2021, 02:55 am
Hola, tengo un problema con mi pagina luego de navegar por las paginas de una lista de noticias https://www.mipagina.com/noticias/?page=2 acá por ejemplo, hago click en el menu del header en inicio y me sale cualquier cosa la url, esto me sale
https://www.mipagina.com/noticias/inicio y eso tira error, cuando debería ser https://www.mipagina.com/inicio

Que puede ser chicos?

Estoy sospechando que están mal esas direcciones, como que debo limpiar la url para que me rediriga donde debería.

Código
  1. <ul class="navbar-nav mr-auto">
  2. <li class="nav-item active"><a class="nav-link" href="inicio">Inicio<span
  3. class="sr-only">(current)</span></a></li>
  4. <li class="nav-item"><a class="nav-link" href="noticias">Noticias</a></li>
  5. <li class="nav-item"><a class="nav-link" href="noticias">Usuarios</a></li>
  6. </ul>

Ahh perdón ya lo resolví, por si a alguien le sirve ahí esta la solución.

https://www.thymeleaf.org/doc/articles/standardurlsyntax.html
56  Programación / .NET (C#, VB.NET, ASP) / porque mi grilla me muestra dos registros y en mi bd solo tengo uno? WPF C# en: 15 Noviembre 2020, 02:57 am
una preguntonta, porque mi grilla me muestra dos registros y en mi bd solo tengo uno? que pasa?  :huh:
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
Código
  1. import 'package:flutter/material.dart';
  2. //Agrego esta weas de librerias
  3. import 'package:barcode_scan/barcode_scan.dart';
  4. import 'package:http/http.dart' as http;
  5. import 'dart:convert';
  6.  
  7. void main() => runApp(MaterialApp(
  8.      theme: ThemeData(primarySwatch: Colors.green),
  9.      home: MyHomePage(),
  10.    ));
  11.  
  12. class MyHomePage extends StatefulWidget {
  13.  @override
  14.  _MyHomePageState createState() => _MyHomePageState();
  15. }
  16.  
  17. class _MyHomePageState extends State<MyHomePage> {
  18.  ScanResult _scanResult;
  19.  
  20.  //Acá va la magía
  21.  
  22.  @override
  23.  Widget build(BuildContext context) {
  24.    return Scaffold(
  25.      appBar: AppBar(
  26.        title: Text('Lector códigos QR'),
  27.      ),
  28.      body: Center(
  29.          child: _scanResult == null
  30.              ? Text('Esperando datos de código')
  31.              : Column(
  32.                  children: [
  33.                    Text('Contenido: ${_scanResult.rawContent}'),
  34.                    Text('Estado: ${_validado}'),
  35.                  ],
  36.                )),
  37.      floatingActionButton: FloatingActionButton(
  38.        onPressed: () {
  39.          _scanCode();
  40.        },
  41.        child: Icon(Icons.camera),
  42.      ),
  43.      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  44.    );
  45.  }
  46.  
  47. //Método para escanear el codigo Qr
  48.  Future<void> _scanCode() async {
  49.    var result = await BarcodeScanner.scan();
  50.  
  51.    recibirRespuestaGET(result.toString());
  52.  
  53.    if (this._id == result.toString() && this._estado == "CONFIRMADO") {
  54.      setState(() {
  55.        _validado = "CONFIRMADO";
  56.      });
  57.    } else {
  58.      setState(() {
  59.        _validado = "DENEGADO";
  60.      });
  61.    }
  62.  }
  63.  
  64.  Future<void> recibirRespuestaGET(String result) async {
  65.    final respuesta = await http
  66.        .get('https://mi-sitio.com/algo/?id=' + result);
  67.    if (respuesta.statusCode == 200) {
  68.      setState(() {
  69.        var parsedJson = json.decode(respuesta.body);
  70.        _id = parsedJson["_id"];
  71.        _estado = parsedJson["estado"];
  72.      });
  73.    } else {
  74.      throw Exception("Fallo");
  75.    }
  76.  }
  77.  
  78.  
  79.  String _id;
  80.  String _estado;
  81.  String _validado = "";
  82. }
  83.  
  84.  
58  Programación / Programación General / obtener json (list) de una peticion get y evaluar los items en: 9 Noviembre 2020, 11:06 am
me gustaria evaluar lo sitems de un json en Dart, la lista es asi


{"item":[{"status":"A","_id":"5fa7","__v":0},,{"status":"A","_id":"5sd4","__v":0}]}


no se como hacerlo, esto es lo unico que tengo

//Ni se que devuelve
Future<http.Response> fetchPost() {
    return http.get('https://soyLinda.herokuapp.com/getAll');
  }

https://codea.app/flutter/leer-json-con-flutter
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.org

BUILD 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
60  Programación / Programación General / alguien sabe programar en Dart? en: 9 Noviembre 2020, 07:48 am
Necesito ayuda :'c
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 31
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines