Permalink
Browse files

Installed fresh Grails 1.1.1 templates

  • Loading branch information...
1 parent 43c6017 commit 55e5798632a68c8e475f0150542747f64bd1fe68 @dima767 committed Jun 10, 2009
@@ -0,0 +1,4 @@
+@artifact.package@class @artifact.name@ {
+
+ def index = { }
+}
@@ -0,0 +1,5 @@
+@artifact.package@class @artifact.name@ {
+
+ static constraints = {
+ }
+}
@@ -0,0 +1,17 @@
+@artifact.package@class @artifact.name@ {
+
+ def filters = {
+ all(controller:'*', action:'*') {
+ before = {
+
+ }
+ after = {
+
+ }
+ afterView = {
+
+ }
+ }
+ }
+
+}
@@ -0,0 +1,7 @@
+includeTargets << grailsScript("Init")
+
+target(main: "The description of the script goes here!") {
+ // TODO: Implement script here
+}
+
+setDefaultTarget(main)
@@ -0,0 +1,8 @@
+@artifact.package@class @artifact.name@ {
+
+ boolean transactional = true
+
+ def serviceMethod() {
+
+ }
+}
@@ -0,0 +1,3 @@
+@artifact.package@class @artifact.name@ {
+
+}
@@ -0,0 +1,15 @@
+@artifact.package@import grails.test.*
+
+class @artifact.name@ extends @artifact.superclass@ {
+ protected void setUp() {
+ super.setUp()
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ }
+
+ void testSomething() {
+
+ }
+}
@@ -0,0 +1,54 @@
+class @webtest.name.caps@Test extends grails.util.WebTest {
+
+ // Unlike unit tests, functional tests are often sequence dependent.
+ // Specify that sequence here.
+ void suite() {
+ test@webtest.name.caps@ListNewDelete()
+ // add tests for more operations here
+ }
+
+ def test@webtest.name.caps@ListNewDelete() {
+ webtest('@webtest.name.caps@ basic operations: view list, create new entry, view, edit, delete, view') {
+ invoke(url:'@webtest.name.lower@')
+ verifyText(text:'Home')
+
+ verifyListPage(0)
+
+ clickLink(label:'New @webtest.name.caps@')
+ verifyText(text:'Create @webtest.name.caps@')
+ clickButton(label:'Create')
+ verifyText(text:'Show @webtest.name.caps@', description:'Detail page')
+ clickLink(label:'List', description:'Back to list view')
+
+ verifyListPage(1)
+
+ group(description:'edit the one element') {
+ clickLink(label:'Show', description:'go to detail view')
+ clickButton(label:'Edit')
+ verifyText(text:'Edit @webtest.name.caps@')
+ clickButton(label:'Update')
+ verifyText(text:'Show @webtest.name.caps@')
+ clickLink(label:'List', description:'Back to list view')
+ }
+
+ verifyListPage(1)
+
+ group(description:'delete the only element') {
+ clickLink(label:'Show', description:'go to detail view')
+ clickButton(label:'Delete')
+ verifyXPath(xpath:"//div[@class='message']", text:/@webtest.name.caps@.*deleted./, regex:true)
+ }
+
+ verifyListPage(0)
+ }
+ }
+
+ String ROW_COUNT_XPATH = "count(//td[@class='actionButtons']/..)"
+
+ def verifyListPage(int count) {
+ ant.group(description:"verify @webtest.name.caps@ list view with $count row(s)") {
+ verifyText(text:'@webtest.name.caps@ List')
+ verifyXPath(xpath:ROW_COUNT_XPATH, text:count, description:"$count row(s) of data expected")
+ }
+ }
+}
@@ -0,0 +1,99 @@
+
+
+<%=packageName ? "package ${packageName}\n\n" : ''%>class ${className}Controller {
+
+ def index = { redirect(action:list,params:params) }
+
+ // the delete, save and update actions only accept POST requests
+ static allowedMethods = [delete:'POST', save:'POST', update:'POST']
+
+ def list = {
+ params.max = Math.min( params.max ? params.max.toInteger() : 10, 100)
+ [ ${propertyName}List: ${className}.list( params ), ${propertyName}Total: ${className}.count() ]
+ }
+
+ def show = {
+ def ${propertyName} = ${className}.get( params.id )
+
+ if(!${propertyName}) {
+ flash.message = "${className} not found with id \${params.id}"
+ redirect(action:list)
+ }
+ else { return [ ${propertyName} : ${propertyName} ] }
+ }
+
+ def delete = {
+ def ${propertyName} = ${className}.get( params.id )
+ if(${propertyName}) {
+ try {
+ ${propertyName}.delete(flush:true)
+ flash.message = "${className} \${params.id} deleted"
+ redirect(action:list)
+ }
+ catch(org.springframework.dao.DataIntegrityViolationException e) {
+ flash.message = "${className} \${params.id} could not be deleted"
+ redirect(action:show,id:params.id)
+ }
+ }
+ else {
+ flash.message = "${className} not found with id \${params.id}"
+ redirect(action:list)
+ }
+ }
+
+ def edit = {
+ def ${propertyName} = ${className}.get( params.id )
+
+ if(!${propertyName}) {
+ flash.message = "${className} not found with id \${params.id}"
+ redirect(action:list)
+ }
+ else {
+ return [ ${propertyName} : ${propertyName} ]
+ }
+ }
+
+ def update = {
+ def ${propertyName} = ${className}.get( params.id )
+ if(${propertyName}) {
+ if(params.version) {
+ def version = params.version.toLong()
+ if(${propertyName}.version > version) {
+ <%def lowerCaseName = grails.util.GrailsNameUtils.getPropertyName(className)%>
+ ${propertyName}.errors.rejectValue("version", "${lowerCaseName}.optimistic.locking.failure", "Another user has updated this ${className} while you were editing.")
+ render(view:'edit',model:[${propertyName}:${propertyName}])
+ return
+ }
+ }
+ ${propertyName}.properties = params
+ if(!${propertyName}.hasErrors() && ${propertyName}.save()) {
+ flash.message = "${className} \${params.id} updated"
+ redirect(action:show,id:${propertyName}.id)
+ }
+ else {
+ render(view:'edit',model:[${propertyName}:${propertyName}])
+ }
+ }
+ else {
+ flash.message = "${className} not found with id \${params.id}"
+ redirect(action:list)
+ }
+ }
+
+ def create = {
+ def ${propertyName} = new ${className}()
+ ${propertyName}.properties = params
+ return ['${propertyName}':${propertyName}]
+ }
+
+ def save = {
+ def ${propertyName} = new ${className}(params)
+ if(!${propertyName}.hasErrors() && ${propertyName}.save()) {
+ flash.message = "${className} \${${propertyName}.id} created"
+ redirect(action:show,id:${propertyName}.id)
+ }
+ else {
+ render(view:'create',model:[${propertyName}:${propertyName}])
+ }
+ }
+}
@@ -0,0 +1,62 @@
+<% import org.codehaus.groovy.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor as Events %>
+<%=packageName%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta name="layout" content="main" />
+ <title>Create ${className}</title>
+ </head>
+ <body>
+ <div class="nav">
+ <span class="menuButton"><a class="home" href="\${resource(dir:'')}">Home</a></span>
+ <span class="menuButton"><g:link class="list" action="list">${className} List</g:link></span>
+ </div>
+ <div class="body">
+ <h1>Create ${className}</h1>
+ <g:if test="\${flash.message}">
+ <div class="message">\${flash.message}</div>
+ </g:if>
+ <g:hasErrors bean="\${${propertyName}}">
+ <div class="errors">
+ <g:renderErrors bean="\${${propertyName}}" as="list" />
+ </div>
+ </g:hasErrors>
+ <g:form action="save" method="post" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
+ <div class="dialog">
+ <table>
+ <tbody>
+ <%
+
+ excludedProps = ['version',
+ 'id',
+ Events.ONLOAD_EVENT,
+ Events.BEFORE_DELETE_EVENT,
+ Events.BEFORE_INSERT_EVENT,
+ Events.BEFORE_UPDATE_EVENT]
+ props = domainClass.properties.findAll { !excludedProps.contains(it.name) }
+
+ Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
+ props.each { p ->
+ if(!Collection.class.isAssignableFrom(p.type)) {
+ cp = domainClass.constrainedProperties[p.name]
+ display = (cp ? cp.display : true)
+ if(display) { %>
+ <tr class="prop">
+ <td valign="top" class="name">
+ <label for="${p.name}">${p.naturalName}:</label>
+ </td>
+ <td valign="top" class="value \${hasErrors(bean:${propertyName},field:'${p.name}','errors')}">
+ ${renderEditor(p)}
+ </td>
+ </tr>
+ <% } } } %>
+ </tbody>
+ </table>
+ </div>
+ <div class="buttons">
+ <span class="button"><input class="save" type="submit" value="Create" /></span>
+ </div>
+ </g:form>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,64 @@
+<% import org.codehaus.groovy.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor as Events %>
+<%=packageName%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta name="layout" content="main" />
+ <title>Edit ${className}</title>
+ </head>
+ <body>
+ <div class="nav">
+ <span class="menuButton"><a class="home" href="\${resource(dir:'')}">Home</a></span>
+ <span class="menuButton"><g:link class="list" action="list">${className} List</g:link></span>
+ <span class="menuButton"><g:link class="create" action="create">New ${className}</g:link></span>
+ </div>
+ <div class="body">
+ <h1>Edit ${className}</h1>
+ <g:if test="\${flash.message}">
+ <div class="message">\${flash.message}</div>
+ </g:if>
+ <g:hasErrors bean="\${${propertyName}}">
+ <div class="errors">
+ <g:renderErrors bean="\${${propertyName}}" as="list" />
+ </div>
+ </g:hasErrors>
+ <g:form method="post" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
+ <input type="hidden" name="id" value="\${${propertyName}?.id}" />
+ <input type="hidden" name="version" value="\${${propertyName}?.version}" />
+ <div class="dialog">
+ <table>
+ <tbody>
+ <%
+ excludedProps = ['version',
+ 'id',
+ Events.ONLOAD_EVENT,
+ Events.BEFORE_DELETE_EVENT,
+ Events.BEFORE_INSERT_EVENT,
+ Events.BEFORE_UPDATE_EVENT]
+ props = domainClass.properties.findAll { !excludedProps.contains(it.name) }
+
+ Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
+ props.each { p ->
+ cp = domainClass.constrainedProperties[p.name]
+ display = (cp ? cp.display : true)
+ if(display) { %>
+ <tr class="prop">
+ <td valign="top" class="name">
+ <label for="${p.name}">${p.naturalName}:</label>
+ </td>
+ <td valign="top" class="value \${hasErrors(bean:${propertyName},field:'${p.name}','errors')}">
+ ${renderEditor(p)}
+ </td>
+ </tr>
+ <% } } %>
+ </tbody>
+ </table>
+ </div>
+ <div class="buttons">
+ <span class="button"><g:actionSubmit class="save" value="Update" /></span>
+ <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
+ </div>
+ </g:form>
+ </div>
+ </body>
+</html>
Oops, something went wrong.

0 comments on commit 55e5798

Please sign in to comment.