Skip to content
This repository has been archived by the owner on Oct 31, 2018. It is now read-only.

Commit

Permalink
Introduced a demo page with all fields used in the scaffolding process.
Browse files Browse the repository at this point in the history
  • Loading branch information
joergrech committed Oct 27, 2012
1 parent 1a1d6cb commit a4b2a77
Show file tree
Hide file tree
Showing 19 changed files with 752 additions and 158 deletions.
@@ -1,6 +1,6 @@
class KickstartWithBootstrapGrailsPlugin {
// the plugin version
def version = "0.8.1"
def version = "0.8.3"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "2.0.0 > *"
// the other plugins this plugin depends on
Expand Down
10 changes: 4 additions & 6 deletions kickstartWithBootstrap/README.mediawiki
Expand Up @@ -39,12 +39,6 @@ Affected files and directories (as of version 0.8.0; see script/Kickstart.groovy
* /views/index.gsp will be '''deleted'''!
* /views/error.gsp will be '''deleted'''!
== Rare Problems ==
During development and testing several strange error have emerged (they might be problems caused by the G&G Tool Suite - a restart of the GGTS helped me):

* Sometimes the conf/URLmappings.groovy file is not copied by the Kickstart script into the conf directory of your project. If you run-app your project and get a 404 regarding the page "/WEB-INF/grails-app/views/index.jsp" you have to copy it yourself manually.
* Sometimes the I18N files from the Kickstart plugin are not used. If you see I18N-codes such as "default.welcome.title" you have to copy the content of the I18N files into the property files in your project.
== Terms of Use ==

* Web Layout: [http://twitter.github.com/bootstrap/ Bootstrap 2.1], from Twitter Licensed under the Apache License v2.0. Documentation licensed under CC BY 3.0. (@TwBootstrap , http://twitter.github.com/bootstrap/)
Expand All @@ -56,6 +50,10 @@ During development and testing several strange error have emerged (they might be
== Changelog ==

;0.8.3
: Introduced a demo page with all fields used in the scaffolding process.
;0.8.2
: Corrected missing copy of resources.groovy.
;0.8.1
: Fixed error when copying UrlMappings.groovy, which was not packaged into the plugin.
;0.8.0
Expand Down
16 changes: 8 additions & 8 deletions kickstartWithBootstrap/application.properties
@@ -1,26 +1,26 @@
#Grails Metadata file
#Tue Oct 23 21:16:12 CEST 2012
#Sat Oct 27 20:08:39 CEST 2012
app.grails.version=2.1.1
app.name=kickstartWithBootstrapGrailsPlugin
app.stats.Controllers.files=2
app.stats.Controllers.loc=90
app.stats.Domain_Classes.files=1
app.stats.Domain_Classes.loc=12
app.stats.Domain_Classes.loc=47
app.stats.Groovy_Helpers.files=1
app.stats.Groovy_Helpers.loc=10
app.stats.Scripts.files=5
app.stats.Scripts.loc=122
app.stats.Scripts.loc=134
app.stats.Tag_Libraries.files=1
app.stats.Tag_Libraries.loc=279
app.stats.Totals.files=12
app.stats.Totals.loc=623
app.stats.Totals.loc=670
app.stats.Unit_Tests.files=2
app.stats.Unit_Tests.loc=110
app.version=0.8.1
app.version.build=123
app.version.build.date=Okt 23, 2012
app.version=0.8.3
app.version.build=150
app.version.build.date=Okt 27, 2012
app.version.build.env=development
app.version.revision=c59697e
app.version.revision=ada1626
plugins.hibernate=2.1.1
plugins.jquery=1.8.0
plugins.lesscss-resources=1.3.0.3
Expand Down
@@ -0,0 +1,107 @@
package kickstartwithbootstrapgrailsplugin

import org.springframework.dao.DataIntegrityViolationException

/**
* _DemoPageController
* A controller class handles incoming web requests and performs actions such as redirects, rendering views and so on.
*/
class _DemoPageController {

static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

def index() {
redirect(action: "list", params: params)
}

def list() {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
[_DemoPageInstanceList: _DemoPage.list(params), _DemoPageInstanceTotal: _DemoPage.count()]
}

def create() {
[_DemoPageInstance: new _DemoPage(params)]
}

def save() {
def _DemoPageInstance = new _DemoPage(params)
if (!_DemoPageInstance.save(flush: true)) {
render(view: "create", model: [_DemoPageInstance: _DemoPageInstance])
return
}

flash.message = message(code: 'default.created.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), _DemoPageInstance.id])
redirect(action: "show", id: _DemoPageInstance.id)
}

def show() {
def _DemoPageInstance = _DemoPage.get(params.id)
if (!_DemoPageInstance) {
flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
redirect(action: "list")
return
}

[_DemoPageInstance: _DemoPageInstance]
}

def edit() {
def _DemoPageInstance = _DemoPage.get(params.id)
if (!_DemoPageInstance) {
flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
redirect(action: "list")
return
}

[_DemoPageInstance: _DemoPageInstance]
}

def update() {
def _DemoPageInstance = _DemoPage.get(params.id)
if (!_DemoPageInstance) {
flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
redirect(action: "list")
return
}

if (params.version) {
def version = params.version.toLong()
if (_DemoPageInstance.version > version) {
_DemoPageInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
[message(code: '_DemoPage.label', default: '_DemoPage')] as Object[],
"Another user has updated this _DemoPage while you were editing")
render(view: "edit", model: [_DemoPageInstance: _DemoPageInstance])
return
}
}

_DemoPageInstance.properties = params

if (!_DemoPageInstance.save(flush: true)) {
render(view: "edit", model: [_DemoPageInstance: _DemoPageInstance])
return
}

flash.message = message(code: 'default.updated.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), _DemoPageInstance.id])
redirect(action: "show", id: _DemoPageInstance.id)
}

def delete() {
def _DemoPageInstance = _DemoPage.get(params.id)
if (!_DemoPageInstance) {
flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
redirect(action: "list")
return
}

try {
_DemoPageInstance.delete(flush: true)
flash.message = message(code: 'default.deleted.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
redirect(action: "list")
}
catch (DataIntegrityViolationException e) {
flash.message = message(code: 'default.not.deleted.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
redirect(action: "show", id: params.id)
}
}
}
@@ -0,0 +1,84 @@
package kickstartwithbootstrapgrailsplugin

/**
* _DemoPage
* A domain class describes the data object and it's mapping to the database
*/
class _DemoPage {

/* Default (injected) attributes of GORM */
// Long id
// String version

String name = "The Demo Page"

// fields with special use (e.g., datepicker, new visual representation, etc.)
Date myDate
boolean myBoolean

// other fields used in the scaffolding process:
int myInt
short myShort
long myLong
float myFloat
double myDouble
byte myByte
char myChar

byte[] myByteArray
// char[] myCharArray // Grails original URL scaffolding seems to have problems

// URL myURL // Grails original URL scaffolding seems to have problems
Integer myInteger
TimeZone myTimeZone
Locale myLocale
Currency myCurrency

public enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }
Suit myEnum

/* Automatic timestamping of GORM */
Date dateCreated
Date lastUpdated

// static belongsTo = [] // tells GORM to cascade commands: e.g., delete this object if the "parent" is deleted.
// static hasOne = [] // tells GORM to associate another domain object as an owner in a 1-1 mapping
// static hasMany = [] // tells GORM to associate other domain objects for a 1-n or n-m mapping
// static mappedBy = [] // specifies which property should be used in a mapping

static mapping = {
}

static constraints = {
// make all fields nullable to speed up demo usage (e.g., saves)
name nullable: true

myDate nullable: true
myBoolean nullable: true

myInt nullable: true
myShort nullable: true
myLong nullable: true
myFloat nullable: true
myDouble nullable: true
myByte nullable: true
myChar nullable: true

myByteArray nullable: true
// myCharArray nullable: true

// myURL nullable: true
myInteger nullable: true
myTimeZone nullable: true
myLocale nullable: true
myCurrency nullable: true
}

/*
* Methods of the Domain Class
*/
@Override // Override toString for a nicer / more descriptive UI
public String toString() {
return "${name}";
}
}
2 changes: 2 additions & 0 deletions kickstartWithBootstrap/grails-app/i18n/messages.properties
Expand Up @@ -64,3 +64,5 @@ security.signoff.label = Sign out

checkbox.on.label = On
checkbox.off.label = Off

default.date.format = yyyy-MM-dd
2 changes: 2 additions & 0 deletions kickstartWithBootstrap/grails-app/i18n/messages_de.properties
Expand Up @@ -63,3 +63,5 @@ security.signoff.label = Ausloggen

checkbox.on.label = An
checkbox.off.label = Aus

default.date.format = dd. MM. yyyy

0 comments on commit a4b2a77

Please sign in to comment.