error appears when i add anything in my controller

42 views
Skip to first unread message

Sherif Shehab

unread,
Sep 28, 2015, 9:13:46 AM9/28/15
to Grails Dev Discuss

Hi all , 

i'm using Grails 2.5.1 on Windows 7 64 bit , After generating the controllers and the views using Grails command

generate-all "*"

When i add any new lines in my controllers i get the below error : 


Compilation error: startup failed:



E:\Development\eclipse\TekDays\grails-app\controllers\com\tekdays\TekEventController.groovy:
47: Ambiguous expression could be a parameterless closure expression, an
isolated open code block
, or it may continue
a previous
statement
;



   solution:
Add an explicit parameter list, e.g. {it -> ...}, or force it to be treated
as an open block by giving it a label, e.g. L:{...}, and also either remove the
previous newline
, or add an explicit semicolon ';'
@ line 47,
column
4.


           {



      ^

1
error


here is my controller : 



package com.tekdays
 
import static org.springframework.http.HttpStatus.*
 
@Transactional(readOnly = true)
class TekEventController
{
    def taskService // this what i added
    static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
 
    def index(Integer max)
    {
        params.max = Math.min(max ?: 10, 100)
        respond TekEvent.list(params), model:[tekEventInstanceCount: TekEvent.count()]
    }
 
    def show(TekEvent tekEventInstance)
    {
        respond tekEventInstance
    }
 
    def create()
    {
        respond new TekEvent(params)
    }
 
    @Transactional
    def save(TekEvent tekEventInstance)
    {
        if (tekEventInstance == null)
        {
            notFound()
            return
        }
 
        if (tekEventInstance.hasErrors())
        {
            respond tekEventInstance.errors, view:'create'
            return
        }
 
        tekEventInstance.save flush:true
        taskService.addDefaultTasks(tekEventInstance) // this what i added
        request.withFormat
        {
            form multipartForm
            {
                flash.message = message(code: 'default.created.message', args: [message(code: 'tekEvent.label', default: 'TekEvent'), tekEventInstance.id])
                redirect tekEventInstance
            }
            '*' { respond tekEventInstance, [status: CREATED] }
        }
    }
 
    def edit(TekEvent tekEventInstance)
    {
        respond tekEventInstance
    }
 
    @Transactional
    def update(TekEvent tekEventInstance)
    {
        if (tekEventInstance == null)
        {
            notFound()
            return
        }
 
        if (tekEventInstance.hasErrors())
        {
            respond tekEventInstance.errors, view:'edit'
            return
        }
 
        tekEventInstance.save flush:true
 
        request.withFormat
        {
            form multipartForm
            {
                flash.message = message(code: 'default.updated.message', args: [message(code: 'TekEvent.label', default: 'TekEvent'), tekEventInstance.id])
                redirect tekEventInstance
            }
            '*'
            {
                respond tekEventInstance, [status: OK]
            }
        }
    }
 
    @Transactional
    def delete(TekEvent tekEventInstance)
    {
 
        if (tekEventInstance == null)
        {
            notFound()
            return
        }
 
        tekEventInstance.delete flush:true
 
        request.withFormat
        {
            form multipartForm
            {
                flash.message = message(code: 'default.deleted.message', args: [message(code: 'TekEvent.label', default: 'TekEvent'), tekEventInstance.id])
                redirect action:"index", method:"GET"
            }
            '*'
            {
                render status: NO_CONTENT
            }
        }
    }
 
    protected void notFound()
    {
        request.withFormat
        {
            form multipartForm
            {
                flash.message = message(code: 'default.not.found.message', args: [message(code: 'tekEvent.label', default: 'TekEvent'), params.id])
                redirect action: "index", method: "GET"
            }
            '*'
            {
                render status: NOT_FOUND
            }
        }
    }
}


Søren Berg Glasius

unread,
Sep 28, 2015, 10:27:54 AM9/28/15
to grails-de...@googlegroups.com
Try and move the block to the same line as withFormat:

 request.withFormat {
            form multipartForm
            {
                flash.message = message(code: 'default.created.message', args: [message(code: 'tekEvent.label', default: 'TekEvent'), tekEventInstance.id])
                redirect tekEventInstance
            }
            '*' { respond tekEventInstance, [status: CREATED] }
        }

I think this will help.


Best regards / Med venlig hilsen,
Søren Berg Glasius

Hedevej 1, Gl. Rye, 8680 Ry, Denmark
Mobile: +45 40 44 91 88, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/3c531b41-2f2f-48bc-a794-44b6f872a758%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sherif Shehab

unread,
Sep 28, 2015, 10:46:23 AM9/28/15
to Grails Dev Discuss
Hi , 
i tried , but unfortunately i'm still having the error

Thanks
Sherif
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

Christian Knoblauch

unread,
Sep 29, 2015, 9:26:17 AM9/29/15
to grails-de...@googlegroups.com
The error message says there's an error on line 47. In the controller you included, that's the brace after form.multipartform:

form multipartForm
{    // <-- line 47

Try putting that brace right after form.multipartForm instead of in a line of its own, see if that works.

    Christian

To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.

To post to this group, send email to grails-de...@googlegroups.com.

Sherif Shehab

unread,
Sep 29, 2015, 10:26:58 AM9/29/15
to Grails Dev Discuss
Hi , Wow it fixed the issue , it never crossed my mind that this may be the problem , does it make any difference in the syntax , in my thought both are same !!!

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

To post to this group, send email to grails-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages