grails templates - scaffolding controller

后端 未结 2 1994
遇见更好的自我
遇见更好的自我 2021-01-28 00:37

I\'m a newbie on grails. I am now currently working on my scaffolding templates especially on my controllers. I wanted a customized controller everytime I generate it so I used

相关标签:
2条回答
  • 2021-01-28 01:06

    Interesting question - why do you think you need the command object? This way, you are violating the dry principle.

    As you are just starting with grails, you should just try to use grails as it is inteded to be used and not try to enhance it.

    As soon as you've created your first fully featured grails project, you'll see the beauty of the grails design - without the need of implicit command objects :-) - or chose another framework

    0 讨论(0)
  • 2021-01-28 01:09

    edit.gsp, show.gsp and list.gsp templates all have logic for creating fields basing on domain class, you can see there how it's done.

    Basically, when you include groovy code in your template, you can access domain class by using domainClass variable, and then you can print properties declarations by iterating over array returned by getProperties(), like this:

    <%
        domainClass.properties.each {
            println "    ${it.type} ${it.name}"
        }
    %>
    
    0 讨论(0)
提交回复
热议问题