This repository has been archived by the owner on Oct 31, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced a demo page with all fields used in the scaffolding process.
- Loading branch information
Showing
19 changed files
with
752 additions
and
158 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
kickstartWithBootstrap/KickstartWithBootstrapGrailsPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...trap/grails-app/controllers/kickstartwithbootstrapgrailsplugin/_DemoPageController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
kickstartWithBootstrap/grails-app/domain/kickstartwithbootstrapgrailsplugin/_DemoPage.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.