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 7518715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:47:21+00:00 2026-05-30T01:47:21+00:00

My grails app has to define some additional behaviour for many of the standard

  • 0

My grails app has to define some additional behaviour for many of the standard dynamic scaffolding methods for each domain class.

I know I can duplicate the methods I need to add to for each controller, and indeed that is what I currently do. This does mean that my custom code is obscured by the boilerplate scaffolding.

I have tried importing and modifying the templates as well but they only seem to get involved if I generate static scaffolding in my controllers. Needless to say this doesn’t help much.

Interceptors don’t seem to be what I want either as they enclose the action rather than being inserted into it. I thought about intercepting the GORM call in some fashion but that isn’t really what I want either.

What I really want to do is replace the base dynamic scaffolding methods with ones that have a hook in the places I want to be able to modify.

The following shows an example of what I am trying to achieve

    // standard "save" dynamic scaffold method decorated with hooks for custom code
    def save() {
        def ${propertyName} = new ${className}(params)

        saveBeforeSave(${propertyName})

        if (!${propertyName}.save(flush: true)) {
            render(view: "create", model: [${propertyName}: ${propertyName}])
            return
        }

        saveAfterSave(${propertyName})

        flash.message = message(code: 'default.created.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), ${propertyName}.id])
        redirect(action: "show", id: ${propertyName}.id)
    }

    // Placeholders hooks to be overridden in controller as necessary
    def saveBeforeSave(${propertyName}) {
    }
    def saveAfterSave(${propertyName}) {
    }
  • 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-05-30T01:47:21+00:00Added an answer on May 30, 2026 at 1:47 am

    Can’t you simple use the command:

    grails install-templates
    

    Then modify the controller ?
    Guide and Reference.

    Just configure your controller with

    static scaffold = *MODEL*
    

    and apply your modifications to /src/templates/scaffolding/Controller.groovy

    There is no need to generate to use generate-controller

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

Sidebar

Related Questions

My Grails app has the following domain objects class ProductType { String name static
My Grails 2.0 app has a User domain object defined: class User { static
I have a grails app with a domain Restaurant and a domain Person. class
I have a grails app that has some run-scripts that I want to run
I have a page X in my grails app which has a button to
I have noticed that after my Grails app has been deployed for about 2
My grails web app has two parts: one for desktop / laptop browsers, one
I'm playing with a grails app that has a contextmenu (on right-click). The context
Hey all- I'm working on some web flows for a Grails app we're building.
In my Grails app, I'm trying to define a Spring bean in resources.groovy 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.