我嘗試本地化來自域類的錯誤消息。這是可能與默認的錯誤消息,例如:在Grails中本地化驗證(錯誤)消息
default.blank.message =屬性[{0}]不能爲空
和局部屬性的名稱,例如:
customer.address.label =客戶地址
其中「客戶」是我的域類,地址是它的屬性。
我的問題是我無法本地化一些屬性,因爲我需要特定的錯誤消息。 E.g:
has.to.be.a.number =屬性[{0}]必須是一個數
contingent.size.label =未定尺寸。
但我得到的消息是「物權【尺寸】必須是一個數字」,而不是「物權[附帶大小]必須是一個數字」。
我不能定位的消息被以下:
- 屬性[{0}]必須是一個數
- 屬性[{0}]必須是一個有效的日期//我不能使用G:日期選擇在此背景下
我添加了一些其他領域類的一些其他的例子也不起作用
package cz.quanti.spaportal.touristOffice
import ...
class TouristOffice {
String customerNumber
int minimalContingent
Address address
User user
ContactPerson contactPerson
static hasMany = [contingents: Contingent]
static constraints = {
customerNumber(unique:true, nullable: true, blank: true)
user(nullable: true, blank: true)
contactPerson(nullable: false)
minimalContingent(min: 0)
address(nullable: false)
}
只有「minimalContingent」未本地化:(消息已本地化且最小屬性未定義) 屬性[minimalContingent]必須是一個數字。
你正在使用什麼驗證器?請添加您的域類代碼約束。 – mfloryan 2011-01-12 16:05:57
您的域類是否在包中,或者它們是否使用默認包? – 2011-01-12 16:10:38
此外,您是否遇到了使標籤正常工作或使自定義驗證消息起作用的問題?我假設前者,但是在重新閱讀你的問題之後,我現在對你遇到的問題更加模糊。 – 2011-01-12 16:18:32