2012-03-26 54 views
2

的第一篇文章的这个论坛...Grails <field type =“number”...>不工作......?

Grails的2.0.1 <字段类型=“数字”>似乎并不奏效开箱,但也许我的使用是不正确的,所以我在这里寻找健康检查。

下面是我的域实体领域:

Long locationId 
static constraints = { 
    locationId(blank: false) 
} 

这里的产生_form.gsp在脚手架模板合成场:

<g:field type="number" name="locationId" required="" value="${fieldValue(bean: myEntityInstance, field: 'locationId')}"/> 

但这里的结果在html,按“查看源代码”:

<input type="number" name="locationId" required="" value="" id="locationId" /> 

而我的问题是,窗体空白现有的价值根据:value =“”。 其他字段(所有字符串)正确填充。 Grails 2.0.1的“数字”gsp字段是否可以为其他人正常工作?

问候 罗布

回答

0

检查$的实际值{fieldValue方法(豆:myEntityInstance,场: 'locationId')}

打印出来

<% 
System.out.println fieldValue(bean: myEntityInstance, field: 'locationId') 
%> 

我已经没有“数字”类型的问题,它对我来说完全符合您的要求

1

尝试:

<g:field type="number" name="locationId" required="" value="${myEntityInstance.locationId}"/> 

如果您有任何值为4或1000以上的数字,fieldValue会尝试显示它1000

相关问题