Rick Rothenberg
Rick Rothenberg

Reputation: 11

Is there a practical way to render modified scaffolding templates without restarting in Grails 3?

I added code which I thought would do the job, but it looks like GrailsLayoutView is somehow interfering with it.

I have a plugin with the following code:

def watchedResources = "file:./src/main/templates/scaffolding/*.gsp"

void onChange(Map<String, Object> event) {
    applicationContext.getBean("jspViewResolver").innerViewResolver.generatedViewCache.clear()
}

This seems to do what I expect and the ScaffoldingViewResolver regenerates the view rather than pulling it from its cache. The correctly rendered view then is passed up, but it looks like GrailsLayoutView.renderTemplate calls obtainContent which returns the original content of the scaffolded view rather than the updated content. It then uses the wrong content in the call to decorator.render and all hope of seeing the updated template is lost.

For anyone familiar with this code, am I correctly interpreting the problem and do you know of some way I can get past this? I have some complex scaffolding templates that I would like to work on, but I'm going to give it up if I have to shutdown grails every time I make a change.

Thank you.

Upvotes: 1

Views: 59

Answers (0)

Related Questions