找不到StringValidator.maximumLength的资源键(int length)

时间:2012-10-12 18:55:51

标签: wicket

我正在将我的Wicket Web应用程序从1.5.8迁移到6.1.1。作为此过程的一部分,我正在更新文本字段的验证器。我的TextArea验证程序的资源键不再被识别,我得到了标准

'sComments' is longer than the maximum of 250 characters.

flash消息而不是我期望使用我认为的资源键:

Your comments have a length of 255, which is longer than the maximum of
250 characters that we allow. Please would you amend your comments and try again.

是否有其他人遇到此问题或者可以帮助我命名我的资源密钥以使其在Wicket 6.1.1中运行?

我的旧1.5.8资源键

sComments.StringValidator.maximum

在Wicket 6.1.1中工作(该文档指出,为了向后兼容性原因,仍然会检查表单StringValidator。*的资源键),但是我想在未来失败之前采用“现代”方式做事Wicket的版本。

HTML CODE

<textarea wicket:id="sComments" cols="50" rows="5"
 tabindex="5"
></textarea>

JAVA CODE

private static final int M_N_MAX_LEN_MESSAGE = 250;

// The matching HTML "textarea" component has no maximum length attribute
TextArea<String> taComments = new TextArea<String>("sComments");
// taComments.add(new MaximumLengthValidator(M_N_MAX_LEN_MESSAGE));    1.5.8 code
taComments.add(StringValidator.maximumLength(M_N_MAX_LEN_MESSAGE));
frmForm.add(taComments);

物业文件提取

# The resource key that worked in Wicket 1.5.8
# sComments.StringValidator.maximum = Your comments have a length of \
# ${length}, which is longer than the maximum of ${maximum} characters \
# that we allow. Please would you amend your comments and try again.

# Wicket 6.1.1 resource key that does not work
sComments.RangeValidator.maximum = Your comments have a length of \
${length}, which is longer than the maximum of ${maximum} characters \
that we allow. Please would you amend your comments and try again.

(我也尝试过:

sComments.RangeValidator.Maximum
sComments.RangeValidator.MaximumValidator
sComments.MaximumValidator
sComments.RangeValidator.minimum
sComments.RangeValidator.range
sComments.RangeValidator.exact

没有成功。)

1 个答案:

答案 0 :(得分:1)

在我看来,Wicket 6.1.1对此验证器的正确资源键的格式为sComments.StringValidator.maximum,尽管StringValidator的javadoc建议使用sComments.RangeValidator.maximum形式的资源键。