How to Create Controller and Views with diffrent name Grails scaffolding

856 views Asked by At

How to change the grails template file to add Prefix to the name of the controller and view package. suppose i have User Domain, while using command create-scaffold-controller User should create AdminUserController.groovy and similarly create adminUser package for views instead of default UserCOntroller and respective views

2

There are 2 answers

0
Vitor Hugo On

Install the templates on the project with grails install-templates and change the name on src/templates/scaffolding/Controller.groovy:

Example:
class Admin${className}Controller {

and the package name you can control on the create-scaffold-controller:

From the docs:
grails create-scaffold-controller org.bookstore.Book

or change directly in the template with variables:

<%=package org.admin.${className}%>

instead of:

<%=packageName ? "package ${packageName}\n\n" : ''%>
0
Carlos Alberto On

You can use the command 'grails install-templates' and after, change the controller template in /src/template.