This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <dependencies> | |
| <dependency> | |
| <groupId>javax.servlet</groupId> | |
| <artifactId>jstl</artifactId> | |
| <version>1.2</version> | |
| </dependency> | |
| <dependency> | |
| <groupId>taglibs</groupId> | |
| <artifactId>standard</artifactId> | |
| <version>1.1.2</version> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package edu.swau.forms.utils; | |
| import edu.swau.forms.dao.RoleDao; | |
| import edu.swau.forms.dao.UserDao; | |
| import edu.swau.forms.model.Role; | |
| import edu.swau.forms.model.User; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.context.ApplicationListener; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package edu.swau.forms.utils; | |
| import java.sql.Driver; | |
| import java.sql.DriverManager; | |
| import java.sql.SQLException; | |
| import java.util.Enumeration; | |
| import java.util.Set; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.springframework.context.ApplicationListener; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def nuevo() { | |
| def producto = new Producto(params) | |
| producto.iva = new BigDecimal(params.iva) | |
| producto.save() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DominioService { | |
| static transactional = true | |
| //Método transaccional | |
| def metodo1() { | |
| // código dentro de la transacción | |
| } | |
| // Método transaccional 2 | |
| def metodo2(param1, param2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dominio.withTransaction { | |
| // bloque dentro de la transacción | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def imagen = { | |
| def imagen = Imagen.get(params.id) | |
| log.debug "Mostrando imagen ${imagen?.nombre}" | |
| response.setHeader("Content-disposition", "attachment; filename=${imagen?.nombre}") | |
| response.contentType = imagen?.tipoContenido | |
| byte[] archivo = imagen?.archivo | |
| response.contentLength = imagen?.tamano | |
| response.outputStream << imagen.archivo | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def upload = { | |
| def f = request.getFile('myFile') | |
| if (!f.empty) { | |
| def imagen = new Imagen( | |
| nombre : f.originalFilename | |
| , tipoContenido : f.contentType | |
| , tamano : f.size | |
| , archivo : f.bytes | |
| ).save() | |
| response.sendError(200,'Done') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <g:form action="upload" method="post" enctype="multipart/form-data"> | |
| <input type="file" name="myFile"> | |
| <input type="submit"> | |
| </g:form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Imagen { | |
| String nombre | |
| String tipoContenido | |
| Long tamano | |
| byte[] archivo | |
| static constraints = { | |
| nombre(maxSize:64,nullable:true) | |
| tipoContenido(maxSize:64,nullable:true) | |
| tamano(nullable:true) |