Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:42:01+00:00 2026-06-07T01:42:01+00:00

I would like my templates to be smarter about generating controllers. In my domain

  • 0

I would like my templates to be smarter about generating controllers. In my domain classes I have specified an enum with the properties that should be added to the security annotation in the controller.

static enum SecurityProperties {
    ROLE_SUPER_USER( "ROLE_SUPER_USER" ),
    IS_AUTHENTICATED_FULLY( "IS_AUTHENTICATED_FULLY" )

    SecurityProperties( String s ) {
        this.s = s
    }

    @Override
    public String toString() {
        return s;
    }        
}

I would like the template to look at this enum and create the security annotation in a controller when the controller is generated. I use the templates a lot and it is a major annoyance to run generate-all then have to add the security annotations back in for all of my controllers.

My problem is that I am having issues accessing the enum from the template because I cannot get the domain class.

I usually get a domain class like this:

grailsApplication.getArtefact( "Domain", "myDomainClass" )?.getClazz()

But grailsApplication is not available in the template.

What other Grails / Groovy way is there to get the class or make grailsApplication available?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:42:03+00:00Added an answer on June 7, 2026 at 1:42 am

    Within the scaffolding templates you have a domainClass variable available to you which contains the GrailsDomainClass, so domainClass.clazz should give you what you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several PDF templates that I would like to load and modify and
I have about 50 templates, and I would like to standardize whitespace on variables
I have a question about templates. I would like to have a templated class
I would like to edit the ASP.NET MVC templates for Visual Studio so that
I would like to have alternative templates for each section of my website. How
I store my templates as files, and would like to have the opportunity to
Template methods as in NOT C++ templates . So, say that you would like
I have a question regarding django templates and html frameset's. I would like to
For debugging purposes, I would like to have a variable in all my templates
I would like to place some WPF Data Templates in a loose file that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.