Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.3.5
-
Fix Version/s: None
-
Component/s: Scaffolding
-
Labels:None
-
Patch Submitted:Yes
Description
I like grails' dynamic scaffolding option for explicitly specifying a domain class name, i.e.
def scaffold = Author
It allows me to move scaffolding in an independent controller, say AuthorScaffoldController, and to place my custom logic in a controller named after domain class, say AuthorController. Later if I need to generate scaffolded code, I will like to have it in specialized controller (AuthorScaffoldController for this example) and specialized views. Unfortunately, current grails' scripting doesn't support this option.
Here is a patch (I will try to add pull request later) which proposes a solution for this. It brings new optional parameter for specifying a controller name in generate-* scripts, allowing scripts to be used as follows:
generate-all mypackage.Person PersonScaffold generate-controller mypackage.Person PersonScaffold generate-views mypackage.Person PersonScaffold
Here, second parameter specifies controller name for which scaffolds should be generated. In above example, generate-all script will produce these files:
grails-app/controllers/mypackage/PersonScaffoldController.groovy grails-app/views/personScaffold/create.gsp grails-app/views/personScaffold/edit.gsp grails-app/views/personScaffold/list.gsp grails-app/views/personScaffold/show.gsp test/unit/mypackage/PersonScaffoldControllerTests.groovy
I think this option can be useful, especially for beginners.
Implementation note: It should be mentioned that I didn't want to change GrailsTemplateGenerator interface to minimize possible braking changes for others. However, there are few new methods in DefaultGrailsTemplateGenerator.
Pull request added: https://github.com/grails/grails-core/pull/23