When using Grails, the GSP code to render each form field looks something like this:
-
Using the bean-field plugin.
Your code will become:
<bean:withBean beanName="person">
<bean:field property="username" label="Login Name:"/>
<bean:field property="userRealName" label="Full Name:"/>
<bean:field property="passwd" label="Password:"/>
</bean:withBean>
Can you find a DRYer solution?
讨论(0)
-
Yes, bean-fields plugin is very DRY… your 20 lines can be replaced with one line:
<bean:form beanName="person" properties="username, userRealName, passwd”/>
(Assuming you have i18n properties set)
讨论(0)
-
For those who read this thread in future - For grails 2.x branch Grails fields plugin is recommended over bean fields, its actually successor of bean-fields and provides flexibility to override default templates
讨论(0)
- 热议问题