2009/08/22 @Tokyo




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


 DTP                                Web
           90%Grails
JGGUG(                 )
 Grails     ...
$ grails create-app eventer
$ cd eventer




grails.project.plugins.dir="work_tmp/plugins"
grails.project.work.dir="work_t...
$ 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
    /*...
$ grails run-app
class Event implements Serializable {

   static mapping = {
     id generator:'uuid.hex',
     params:[type:'string']
   ...
event.label =
       event.eventName.label =




/**                 */
String eventName                 /**(.*)*/n(.*) (....
$ grails generate-all org.jggug.Event




$ grails run-app
$ grails install-plugin calendar


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



<calendar:datePicker name="ev...
yui-css               (        )
grails install-plugin http://grails.jp/sample/grails-yui-css-2.7.0-M2.zip
grails yui-css
...
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



                grai...
$ grails install-plugin gorm-jpa


resources.groovy       entityManagerFactory         transactionManager
entityManagerFac...
import org.datanucleus.jpa.annotations.Extension
import javax.persistence.*;

@Entity
class Event implements Serializable ...
def save = {
  def eventInstance = new Event(params)
  Event.withTransaction{
    if(eventInstance.save(flush:true)) {
   ...
$ 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...
$ 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'] = "           "
printl...
<system-properties>
  <property name="file.encoding" value="UTF-8"/>
  <property name="groovy.source.encoding"
           ...
Grails/Groovy
http://www.jggug.org/
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
Upcoming SlideShare
Loading in...5
×

G* on GAE/J 挑戦編

2,127

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,127
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

G* on GAE/J 挑戦編

  1. 1. 2009/08/22 @Tokyo def speaker = new Cast(name:”T.Yamamoto”,version:”G*S-2009-08-22”)
  2. 2. ( ) DTP Web 90%Grails JGGUG( ) Grails 9-11 Grails Acegi Plugin http://d.hatena.ne.jp/mottsnite/
  3. 3. $ 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"
  4. 4. $ grails run-app
  5. 5. $ grails create-domain-class org.jggug.Event $ grails create-controller org.jggug.Event
  6. 6. 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 = { } }
  7. 7. $ grails run-app
  8. 8. 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 }
  9. 9. 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 =
  10. 10. $ grails generate-all org.jggug.Event $ grails run-app
  11. 11. $ grails install-plugin calendar <head> <calendar:resources lang="en" theme="tiger"/> <calendar:datePicker name="eventDate" defaultValue="${eventInstance?.eventDate}" dateFormat="%Y/%m/%d" />
  12. 12. 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" />
  13. 13. export APPENGINE_HOME=/opt/appengine-java-sdk-1.2.2 google.appengine.sdk='/opt/appengine-java-sdk-1.2.2'
  14. 14. $ 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
  15. 15. $ 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
  16. 16. 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
  17. 17. 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] } } }
  18. 18. $ grails set-version 1 $ grails app-engine run
  19. 19. $ grails app-engine package $ rm target/war/WEB-INF/lib/jul-to-slf4j-1.5.6.jar $ appcfg.sh update ./target/war
  20. 20. 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
  21. 21. $ dev_appserver.sh ./war ※Windows .sh→.cmd
  22. 22. View request.setAttribute 'list', [1, 2, 3, 4] request.setAttribute 'date', new Date()   forward 'display.gtpl'
  23. 23. 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) )
  24. 24. <system-properties> <property name="file.encoding" value="UTF-8"/> <property name="groovy.source.encoding" value="UTF-8"/> </system-properties>
  25. 25. Grails/Groovy http://www.jggug.org/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×