SlideShare a Scribd company logo
1 of 79
Download to read offline
2009/08/22 @Tokyo




def speaker = new Cast(name:”T.Yamamoto”,version:”G*S-2009-08-22”)
(                   )


 DTP                                Web
           90%Grails
JGGUG(                 )
 Grails                9-11
Grails Acegi Plugin



 http://d.hatena.ne.jp/mottsnite/
$ grails create-app eventer
$ cd eventer




grails.project.plugins.dir="work_tmp/plugins"
grails.project.work.dir="work_tmp/work"


development {
 dataSource {
  dbCreate = "update"
  url = "jdbc:hsqldb:file:work_tmp/devDB;shutdown=true"
$ grails run-app
$ grails create-domain-class org.jggug.Event



$ grails create-controller org.jggug.Event
package org.jggug

class Event {

    /**               */
    String eventName
    /**       */
    Date eventDate
    /**            */
    String eventDesc
    /**     */
    String place
    /**          */
    String groupName
    /**     */               package org.jggug
    String content           class EventController {
                               def scaffold = true
    Date dateCreated         }
    Date lastUpdated

    static constraints = {
    }
}
$ grails run-app
class Event implements Serializable {

   static mapping = {
     id generator:'uuid.hex',
     params:[type:'string']
   }
   String id
 ...




static constraints = {
  eventName nullable:false,blank:false
  eventDate nullable:false,blank:false
  eventDesc nullable:false,blank:false
  place nullable:false,blank:false
  groupName nullable:false,blank:false
  content nullable:false,
          blank:false,maxSize:4000
  dateCreated display:false
  lastUpdated display:false
}
event.label =
       event.eventName.label =




/**                 */
String eventName                 /**(.*)*/n(.*) (.*)

/**       */                     event.$3.label = $1
Date eventDate

/**            */
String eventDesc                      event.eventName.label =
                                      event.eventDate.label =
                                      event.eventDesc.label =
$ grails generate-all org.jggug.Event




$ grails run-app
$ grails install-plugin calendar


  <head>
<calendar:resources lang="en" theme="tiger"/>



<calendar:datePicker name="eventDate"
  defaultValue="${eventInstance?.eventDate}"
  dateFormat="%Y/%m/%d" />
yui-css               (        )
grails install-plugin http://grails.jp/sample/grails-yui-css-2.7.0-M2.zip
grails yui-css




<head>             content=”main”    “yui-t1”
<meta name="layout" content="main" />

<meta name="layout" content="yui-t1" />
export APPENGINE_HOME=/opt/appengine-java-sdk-1.2.2


google.appengine.sdk='/opt/appengine-java-sdk-1.2.2'
$ grails install-plugin app-engine


Do you want to use JPA or JDO for persistence? (jpa, jdo)
jpa



                grails-app/conf/

datastore-indexes.xml
persistence.xml


  grails-app/conf/Config.groovy GAE
google.appengine.application="jggugv4"

 Grails
$ grails install-plugin gorm-jpa


resources.groovy       entityManagerFactory         transactionManager
entityManagerFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)
{
  beanClassLoader = ref("classLoader")
}

transactionManager(org.springframework.orm.jpa.JpaTransactionManager) {
  entityManagerFactory = entityManagerFactory
}


      datanucleus-enhancer*.jar
cp $APPENGINE_HOME/lib/tools/orm/datanucleus-enhancer-1.1.4.jar lib
import org.datanucleus.jpa.annotations.Extension
import javax.persistence.*;

@Entity
class Event implements Serializable {

  @Id
  @GeneratedValue (strategy = GenerationType.IDENTITY)
  @Extension (vendorName = "datanucleus",
               key = "gae.encoded-pk", value = "true")
  String id

  /**                */
  @Column //
  String eventName
def save = {
  def eventInstance = new Event(params)
  Event.withTransaction{
    if(eventInstance.save(flush:true)) {
      flash.message = "Event ${eventInstance.id} created"
      redirect action:"show", id:eventInstance.id
    }
    else {
      render view:'create', model:[eventInstance:eventInstance]
    }
  }
}
$ grails set-version 1


$ grails app-engine run
$ grails app-engine package
$ rm target/war/WEB-INF/lib/jul-to-slf4j-1.5.6.jar
$ appcfg.sh update ./target/war
export APPENGINE_HOME=/opt/appengine-java-sdk-1.2.2
export PATH=$PATH:$APPENGINE_HOME/bin


$ dev_appserver.sh -h
$ appcfg.sh -h

※Windows     .sh→.cmd
$ dev_appserver.sh ./war

※Windows     .sh→.cmd
View
request.setAttribute 'list', [1, 2, 3, 4]
request.setAttribute 'date', new Date()
 
forward 'display.gtpl'
import com.google.appengine.api.datastore.Entity

def person = new Entity("person")

person['name'] = "           "
println person['name']

person.age = 31
println person.age

//
person.save()

//
person.delete()

//
def q = new Query('person')
def list = datastoreService.prepare(q).asList(
                Builder.withLimit(20).offset(0) )
<system-properties>
  <property name="file.encoding" value="UTF-8"/>
  <property name="groovy.source.encoding"
            value="UTF-8"/>
</system-properties>
Grails/Groovy
http://www.jggug.org/

More Related Content

What's hot

Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Tsuyoshi Yamamoto
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSLadislav Prskavec
 
Quicli - From zero to a full CLI application in a few lines of Rust
Quicli - From zero to a full CLI application in a few lines of RustQuicli - From zero to a full CLI application in a few lines of Rust
Quicli - From zero to a full CLI application in a few lines of RustDamien Castelltort
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
わかった気になるgitit-0.8
わかった気になるgitit-0.8わかった気になるgitit-0.8
わかった気になるgitit-0.8Kiwamu Okabe
 
GPars For Beginners
GPars For BeginnersGPars For Beginners
GPars For BeginnersMatt Passell
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appBruce McPherson
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseBruce McPherson
 
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -Yusuke Wada
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetBruce McPherson
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Yusuke Wada
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email logBruce McPherson
 
gunicorn introduction
gunicorn introductiongunicorn introduction
gunicorn introductionAdam Lowry
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseBruce McPherson
 

What's hot (20)

Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
 
World of Logging
World of LoggingWorld of Logging
World of Logging
 
Quicli - From zero to a full CLI application in a few lines of Rust
Quicli - From zero to a full CLI application in a few lines of RustQuicli - From zero to a full CLI application in a few lines of Rust
Quicli - From zero to a full CLI application in a few lines of Rust
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
わかった気になるgitit-0.8
わかった気になるgitit-0.8わかった気になるgitit-0.8
わかった気になるgitit-0.8
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
CouchDB Day NYC 2017: MapReduce Views
CouchDB Day NYC 2017: MapReduce ViewsCouchDB Day NYC 2017: MapReduce Views
CouchDB Day NYC 2017: MapReduce Views
 
GPars For Beginners
GPars For BeginnersGPars For Beginners
GPars For Beginners
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as database
 
PHP 机智问答
PHP 机智问答PHP 机智问答
PHP 机智问答
 
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email log
 
gunicorn introduction
gunicorn introductiongunicorn introduction
gunicorn introduction
 
Virthualenvwrapper
VirthualenvwrapperVirthualenvwrapper
Virthualenvwrapper
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a database
 

Similar to Grails GAE Event App with YUI CSS Plugin

After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegapyangdj
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaveryangdj
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorialjbarciauskas
 
Building Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksBuilding Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksMike Hugo
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Librariesjeresig
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony AppsKris Wallsmith
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologyDaniel Knell
 
Building Robust jQuery Plugins
Building Robust jQuery PluginsBuilding Robust jQuery Plugins
Building Robust jQuery PluginsJörn Zaefferer
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Dirk Ginader
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it meansRobert Nyman
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScriptAndrew Dupont
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformanceJonas De Smet
 
Writing JavaScript that doesn't suck
Writing JavaScript that doesn't suckWriting JavaScript that doesn't suck
Writing JavaScript that doesn't suckRoss Bruniges
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloJavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloRobert Nyman
 

Similar to Grails GAE Event App with YUI CSS Plugin (20)

After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorial
 
Modular and Event-Driven JavaScript
Modular and Event-Driven JavaScriptModular and Event-Driven JavaScript
Modular and Event-Driven JavaScript
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Building Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksBuilding Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And Tricks
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 
Building Robust jQuery Plugins
Building Robust jQuery PluginsBuilding Robust jQuery Plugins
Building Robust jQuery Plugins
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
 
Writing JavaScript that doesn't suck
Writing JavaScript that doesn't suckWriting JavaScript that doesn't suck
Writing JavaScript that doesn't suck
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloJavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
 

More from Tsuyoshi Yamamoto

JJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-bootJJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-bootTsuyoshi Yamamoto
 
Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告Tsuyoshi Yamamoto
 
Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Tsuyoshi Yamamoto
 
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門Tsuyoshi Yamamoto
 
groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」Tsuyoshi Yamamoto
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」Tsuyoshi Yamamoto
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークTsuyoshi Yamamoto
 
JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、Tsuyoshi Yamamoto
 
GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!Tsuyoshi Yamamoto
 
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in TokyoGrails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in TokyoTsuyoshi Yamamoto
 

More from Tsuyoshi Yamamoto (20)

JJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-bootJJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-boot
 
Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告
 
JGGUG grails-spring-boot
JGGUG grails-spring-bootJGGUG grails-spring-boot
JGGUG grails-spring-boot
 
Grailsx@London 2011 報告
Grailsx@London 2011 報告Grailsx@London 2011 報告
Grailsx@London 2011 報告
 
Grails 2.0.0.M1の話
Grails 2.0.0.M1の話 Grails 2.0.0.M1の話
Grails 2.0.0.M1の話
 
Grails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLTGrails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLT
 
G * magazine 1
G * magazine 1G * magazine 1
G * magazine 1
 
G * magazine 0
G * magazine 0G * magazine 0
G * magazine 0
 
JGGUG 2011-02 LT
JGGUG 2011-02 LTJGGUG 2011-02 LT
JGGUG 2011-02 LT
 
Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。
 
Grailsのススメ(仮)
Grailsのススメ(仮)Grailsのススメ(仮)
Grailsのススメ(仮)
 
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門
 
groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトーク
 
JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、
 
ExtJS勉強会@名古屋
ExtJS勉強会@名古屋ExtJS勉強会@名古屋
ExtJS勉強会@名古屋
 
はじめてのGroovy
はじめてのGroovyはじめてのGroovy
はじめてのGroovy
 
GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!
 
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in TokyoGrails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
 

Grails GAE Event App with YUI CSS Plugin

  • 1. 2009/08/22 @Tokyo def speaker = new Cast(name:”T.Yamamoto”,version:”G*S-2009-08-22”)
  • 2. ( ) DTP Web 90%Grails JGGUG( ) Grails 9-11 Grails Acegi Plugin http://d.hatena.ne.jp/mottsnite/
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. $ grails create-app eventer $ cd eventer grails.project.plugins.dir="work_tmp/plugins" grails.project.work.dir="work_tmp/work" development { dataSource { dbCreate = "update" url = "jdbc:hsqldb:file:work_tmp/devDB;shutdown=true"
  • 13. $ grails create-domain-class org.jggug.Event $ grails create-controller org.jggug.Event
  • 14. package org.jggug class Event { /** */ String eventName /** */ Date eventDate /** */ String eventDesc /** */ String place /** */ String groupName /** */ package org.jggug String content class EventController { def scaffold = true Date dateCreated } Date lastUpdated static constraints = { } }
  • 16. class Event implements Serializable { static mapping = { id generator:'uuid.hex', params:[type:'string'] } String id ... static constraints = { eventName nullable:false,blank:false eventDate nullable:false,blank:false eventDesc nullable:false,blank:false place nullable:false,blank:false groupName nullable:false,blank:false content nullable:false, blank:false,maxSize:4000 dateCreated display:false lastUpdated display:false }
  • 17. event.label = event.eventName.label = /** */ String eventName /**(.*)*/n(.*) (.*) /** */ event.$3.label = $1 Date eventDate /** */ String eventDesc event.eventName.label = event.eventDate.label = event.eventDesc.label =
  • 18.
  • 19.
  • 20. $ grails generate-all org.jggug.Event $ grails run-app
  • 21.
  • 22. $ grails install-plugin calendar <head> <calendar:resources lang="en" theme="tiger"/> <calendar:datePicker name="eventDate" defaultValue="${eventInstance?.eventDate}" dateFormat="%Y/%m/%d" />
  • 23.
  • 24.
  • 25. yui-css ( ) grails install-plugin http://grails.jp/sample/grails-yui-css-2.7.0-M2.zip grails yui-css <head> content=”main” “yui-t1” <meta name="layout" content="main" /> <meta name="layout" content="yui-t1" />
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 40. $ grails install-plugin app-engine Do you want to use JPA or JDO for persistence? (jpa, jdo) jpa grails-app/conf/ datastore-indexes.xml persistence.xml grails-app/conf/Config.groovy GAE google.appengine.application="jggugv4" Grails
  • 41.
  • 42.
  • 43. $ grails install-plugin gorm-jpa resources.groovy entityManagerFactory transactionManager entityManagerFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) { beanClassLoader = ref("classLoader") } transactionManager(org.springframework.orm.jpa.JpaTransactionManager) { entityManagerFactory = entityManagerFactory } datanucleus-enhancer*.jar cp $APPENGINE_HOME/lib/tools/orm/datanucleus-enhancer-1.1.4.jar lib
  • 44.
  • 45. import org.datanucleus.jpa.annotations.Extension import javax.persistence.*; @Entity class Event implements Serializable { @Id @GeneratedValue (strategy = GenerationType.IDENTITY) @Extension (vendorName = "datanucleus", key = "gae.encoded-pk", value = "true") String id /** */ @Column // String eventName
  • 46. def save = { def eventInstance = new Event(params) Event.withTransaction{ if(eventInstance.save(flush:true)) { flash.message = "Event ${eventInstance.id} created" redirect action:"show", id:eventInstance.id } else { render view:'create', model:[eventInstance:eventInstance] } } }
  • 47. $ grails set-version 1 $ grails app-engine run
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54. $ grails app-engine package $ rm target/war/WEB-INF/lib/jul-to-slf4j-1.5.6.jar $ appcfg.sh update ./target/war
  • 55.
  • 56.
  • 57.
  • 58.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 67.
  • 68.
  • 69.
  • 70. View request.setAttribute 'list', [1, 2, 3, 4] request.setAttribute 'date', new Date()   forward 'display.gtpl'
  • 71.
  • 72.
  • 73.
  • 74.
  • 75. import com.google.appengine.api.datastore.Entity def person = new Entity("person") person['name'] = " " println person['name'] person.age = 31 println person.age // person.save() // person.delete() // def q = new Query('person') def list = datastoreService.prepare(q).asList( Builder.withLimit(20).offset(0) )
  • 76.
  • 77. <system-properties> <property name="file.encoding" value="UTF-8"/> <property name="groovy.source.encoding" value="UTF-8"/> </system-properties>
  • 78.