<%@ page import="fully.qualified.path.MyEnum" %>
Try this at the top of your GSP (of course, with the full path adjusted for your packages).
Edit (this should work (your enum syntax is also incorrect)):
<%@ page import="ENUM.MyEnum" %> <html> <head> </head> <body> <g:select from="${MyEnum.getAllEnumList()}" optionValue="displayName" name="duration"/> </body> </html>
And then the revised class:
package ENUM public enum MyEnum { MIN15('15 Minutes'), MIN30('30 Minutes'), HOUR1('1 Hour'), HOUR2('2 Hours'), HOUR5('5 Hours'), HOUR8('8 Hours'), HALFDAY('half day'), FULLDAY('full day') private final String displayName public static final List<MyEnum> getAllEnumList() { [MIN15,MIN30,HOUR1,HOUR2,HOUR5,HOUR8,HALFDAY,FULLDAY] } public String toString() { return displayName } MyEnum(String displayName) { this.displayName = displayName; } }
Edit2:
The easiest way to avoid all this (both the second answer here, and my solution) is to simply transfer the list of values ββto gsp from the controller. Just add
[duration:MyEnum.values()]
or something similar to returning your controller.
Oliver tynes
source share