1

使用 Grails Fields 插件,您可以编写更短、更干净、更干的代码:

<bean:withBean beanName="person">
    <bean:field property="username" label="Login Name:"/>
    <bean:field property="userRealName" label="Full Name:"/>    >
</bean:withBean>

上面的代码将与以下代码相同:

<tr class="prop">
  <td valign="top" class="name"><label for="username">Login Name:</label></td>
  <td valign="top" class="value ${hasErrors(bean: person, field: 'username', 'errors')}">
    <input type="text" id="username" name="username" value="${person.username?.encodeAsHTML()}"/>
  </td>
</tr>

<tr class="prop">
  <td valign="top" class="name"><label for="userRealName">Full Name:</label></td>
  <td valign="top" class="value ${hasErrors(bean: person, field: 'userRealName', 'errors')}">
    <input type="text" id="userRealName" name="userRealName" value="${person.userRealName?.encodeAsHTML()}"/>
  </td>
</tr>

但是,我必须手动更改所有已经编写的代码吗?

4

2 回答 2

1

If I were you, I would have stuck to one word

CONSISTENCY

I would rather convert all of them using the plugin or do not use the plugin and convert none. So that in future, I would not have to deal with two types of handling. On the other hand, if you have a lot of views to be converted and you have a short deadline, then I would add this task to my backlog.

But again, it differs from person to person. This was my opinion. I hope this could be useful.

于 2013-05-26T01:06:09.127 回答
0

Grails fields 插件有一个脚手架选项,所以至少你可以重新生成你的脚手架代码。

我同意@dmahapatro 关于代码一致性的观点,如果您选择使用该插件,则必须付出努力,以使您的所有视图都具有相同的模式。

于 2013-05-26T01:44:14.287 回答