grails templates - scaffolding controller

丶灬走出姿态 提交于 2019-12-02 09:38:48

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}"
    }
%>

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!