Skip to content

Instantly share code, notes, and snippets.

View jdmr's full-sized avatar

J. David Mendoza jdmr

View GitHub Profile
@jdmr
jdmr / gist:1570837
Created January 6, 2012 14:30
Grails textField generado
<g:field type="number" name="iva" required="" value='${fieldValue(bean: productoInstance, field: "iva")}' step="0.01"/>
@jdmr
jdmr / gist:1570844
Created January 6, 2012 14:32
Grails textField modificado
<g:field type="number" name="iva" required="" value='${productoInstance.iva}' step="0.01"/>
@jdmr
jdmr / gist:1570874
Created January 6, 2012 14:41
Búsqueda por Etiquetas en Liferay
@RequestMapping(params = "action=contenido")
public String contenido(RenderRequest request, @RequestParam("cursoId") Long id, Model model) throws SystemException {
log.debug("Edita contenido");
curso = cursoDao.obtiene(id);
model.addAttribute("curso", curso);
// Obtiene los datos del usuario de session
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
try {
// Obtiene el grupo en el que se encuentra trabajando el usuario firmado
long scopeGroupId = themeDisplay.getScopeGroupId();
@jdmr
jdmr / alfresco-global.properties
Created January 6, 2012 14:49
Alfresco mail configuration
#
# Outbound Email Configuration
#-------------
mail.host = smtp.gmail.com
mail.port = 465
mail.protocol = smtps
mail.username = test@gmail.com
mail.password = myGmailP455W0rD
mail.encoding = UTF-8
@jdmr
jdmr / custom-email-context.xml
Created January 6, 2012 14:55
Alfresco's xml mail configuration file
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- -->
<!-- MAIL SERVICE -->
<!-- -->
<bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host">
@jdmr
jdmr / Image.groovy
Created January 6, 2012 15:05
Groovy Image Domain
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)
@jdmr
jdmr / upload.gsp
Created January 6, 2012 15:08
GSP upload file
<g:form action="upload" method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
<input type="submit">
</g:form>
@jdmr
jdmr / UploadController.groovy
Created January 6, 2012 15:13
Groovy Upload File Controller
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')
@jdmr
jdmr / ShowImageController.groovy
Created January 6, 2012 15:14
Groovy Show Image Controller
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
}
@jdmr
jdmr / transaction.groovy
Created January 6, 2012 15:20
Groovy Transaction
Dominio.withTransaction {
// bloque dentro de la transacción
}