Enums in grails

classic Classic list List threaded Threaded
5 messages Options
gtg
Reply | Threaded
Open this post in threaded view
|

Enums in grails

gtg
I'm desperately trying to get Enums & Grails working, and failing :-(

In src/java/myenum.java I have:

enum myenum
{
        ROD,
        JANE,
        FREDDY;
}

In grails/domain/Dom1.groovy I have:

class Dom1 {
    myenum e = myenum.ROD;

    static constraints = {
    }
}

If I do a "grails compile" I get an error:

[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, [....]/grails-app/domain/Dom1.groovy: 2: unexpected token: myenum @ line 2, column 2.
  [groovyc]     myenum e = myenum.ROD;

This is with both grails 1.1.1 & 1.1.2, on MacOS 10.5 with Java 1.5.0_22

Can anyone tell me what I'm doing wrong ?

GTG
Reply | Threaded
Open this post in threaded view
|

Re: Enums in grails

Robert Fletcher
Try adding a "public" declaration to the enum - I know it's the same
package but...

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Enums in grails

Ian Roberts
In reply to this post by gtg
gtg wrote:
> Can anyone tell me what I'm doing wrong ?

Grails may be getting confused by your use of a lowercase initial letter
for the myeunm type - Grails expects all class names to be camel case
starting with an upper case letter, so try calling it MyEnum or similar
instead.

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Enums in grails

Nicolás Dijkstra
In reply to this post by gtg
I am using Enums in my Grails 1.1.2 installation without problems. My groovy enum classes are in src/groovy instead of using java enums. You can try that approach and see if it works

On Tue, Dec 15, 2009 at 10:43 AM, gtg <[hidden email]> wrote:

I'm desperately trying to get Enums & Grails working, and failing :-(

In src/java/myenum.java I have:

enum myenum
{
       ROD,
       JANE,
       FREDDY;
}

In grails/domain/Dom1.groovy I have:

class Dom1 {
   myenum e = myenum.ROD;

   static constraints = {
   }
}

If I do a "grails compile" I get an error:

[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed, [....]/grails-app/domain/Dom1.groovy: 2: unexpected token:
myenum @ line 2, column 2.
 [groovyc]     myenum e = myenum.ROD;

This is with both grails 1.1.1 & 1.1.2, on MacOS 10.5 with Java 1.5.0_22

Can anyone tell me what I'm doing wrong ?

GTG
--
View this message in context: http://old.nabble.com/Enums-in-grails-tp26794985p26794985.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



gtg
Reply | Threaded
Open this post in threaded view
|

Re: Enums in grails

gtg
In reply to this post by Ian Roberts
ianroberts wrote
Grails may be getting confused by your use of a lowercase initial letter
for the myeunm type - Grails expects all class names to be camel case
starting with an upper case letter, so try calling it MyEnum or similar
instead.
Yeah ! That worked.

Thank you !

GTG