Skip to content

Instantly share code, notes, and snippets.

@masanobuimai
masanobuimai / gist:61269
Created February 10, 2009 06:17
Grailsでファイルのダウンロード
class FileStore {
String filename
FileContent content
String contentType
public String toString() { "$id:$filename" }
static mapping = {
content lazy: true
}
@masanobuimai
masanobuimai / blueprint css
Created February 10, 2009 07:28
blueprint css
--- html ---
<link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="screen, projection">
<!--[if IE]><link rel="stylesheet" href="css/blueprint/lib/ie.css" type="text/css" media="screen, projection"><![endif]-->
--- gsp ---
<link rel="stylesheet" href="${createLinkTo(dir:'css/blueprint',
file:'screen.css')}" type="text/css" media="screen, projection">
<link rel="stylesheet" href="${createLinkTo(dir:'css/blueprint',
file:'print.css')}" type="text/css" media="print">
@masanobuimai
masanobuimai / gist:61337
Created February 10, 2009 10:20
GrailsでExcelダウンロード
import groovy.xml.MarkupBuilder
class ExcelController {
def type1 = {
render(contentType: "application/vnd.ms-excel") {
html {
body {
h1 "Books"
table(border:1) {
tr { th "a"; th "b" }
@masanobuimai
masanobuimai / gist:61344
Created February 10, 2009 10:36
Grailsでファイルのアップロード
------ view.gsp ------
<g:form action="save" method="post" enctype="multipart/form-data">
<input type="file" id="fileStore.content" name="fileStore.content"/>
</g:form>
------ Controller.groovy ------
def save = {
def f = request.getFile('fileStore.content')
if (!f.empty) {
def fileContent = new FileContent()
@masanobuimai
masanobuimai / gist:62022
Created February 11, 2009 14:11
Hudson Remote APIのxpath, excludeの指定例
= /hudson/description要素だけを得る =
http://deadlock.netbeans.org/hudson/api/xml?xpath=/hudson/description
= 一番最初のJobを得る =
http://deadlock.netbeans.org/hudson/api/xml?xpath=/hudson/job[1]
= /hudson/description要素を除外する =
http://deadlock.netbeans.org/hudson/api/xml?xpath=/&exclude=/hudson/description
= /hudson/description, /hudson/view要素を除外する =
@masanobuimai
masanobuimai / gist:63044
Created February 13, 2009 04:12
Grails:画像をアップロードして,サムネイル作成。
grails install-plugin http://www.arquetipos.co.cr/blog/files/grails-image-tools-1.0.3.zip
class Picture {
byte[] imagefile
}
def save = {
def downloadedFile = request.getFile('imagefile')
def pictureInstance = new Picture(params)
def imageTool = new ImageTool()
@masanobuimai
masanobuimai / GORM
Created February 17, 2009 08:40
Grails:楽観ロックのサンプル
class Person {
String name
Long lock_version
static transients = [ 'lock_version' ]
static constraints = {
version validator: { v, o -> !o.lock_version ?: o.lock_version == v }
}
}
@masanobuimai
masanobuimai / GORM
Created February 17, 2009 08:44
Grails:DynamicJasperの最も簡単な例
class Person {
def static reportable = true
def static reportFileName = 'person-report'
String name
Integer age
}
@masanobuimai
masanobuimai / gist:71339
Created February 27, 2009 07:52
Grails1.1でjoin fetch
class Blog {
String title
String body
FileInfo uploadedFile
static constraints = {
title()
body maxSize: 4000
uploadedFile nullable: true
}
@masanobuimai
masanobuimai / gist:71341
Created February 27, 2009 07:56
Grails1.0.4でjoin fetchする
class BlogController {
def scaffold = true
def list = {
[blogInstanceList: Blog.findAll([fetch: [uploadedFile: 'eager']])]
}
: