我正在将我的 Wicket Web 应用程序从 1.5.8 迁移到 6.1.1。作为此过程的一部分,我正在更新我的文本字段的验证器。我的验证器的资源密钥TextArea
不再被识别,我得到了一个标准
'sComments' is longer than the maximum of 250 characters.
使用我认为是它的资源密钥的闪存消息而不是我所期望的:
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 的未来版本失败之前转向“现代”的做事方式.
代码
<textarea wicket:id="sComments" cols="50" rows="5"
tabindex="5"
></textarea>
JAVA代码
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
没有成功。)