我为我的输入做了一个ComponentFeedbackPanel,在其中显示表单组件的消息。我有通行证的变化,你在那里输入您的旧密码,新通和重复新通输入:检票1.5找不到错误信息
final PasswordTextField oldPass = createOldPassField();
final PasswordTextField newPass = createNewPassField();
final PasswordTextField newPassRepeat = createNewPassRepeatField();
add(oldPass);
add(newPass);
add(newPassRepeat);
final ComponentFeedbackPanel oldPassFeedbackPanel = new ComponentFeedbackPanel(OLD_PASS_ERROR, oldPass);
oldPassFeedbackPanel.setOutputMarkupPlaceholderTag(true);
final ComponentFeedbackPanel newPassFeedbackPanel = new ComponentFeedbackPanel(NEW_PASS_ERROR, newPass);
newPassFeedbackPanel.setOutputMarkupPlaceholderTag(true);
final ComponentFeedbackPanel newPassRepeatFeedbackPanel = new ComponentFeedbackPanel(NEW_PASS_REPEAT_ERROR, newPassRepeat);
newPassRepeatFeedbackPanel.setOutputMarkupPlaceholderTag(true);
add(oldPassFeedbackPanel);
add(newPassFeedbackPanel);
add(newPassRepeatFeedbackPanel);
它的伟大工程,当我使用例如积聚检票验证方法:EqualPasswordInputValidation返回好的消息输入不匹配其中一个组件。然而,当我创建自己的类,它扩展AbstractValidator并实现IValidator:
/**
* Error msgs
*/
private static final String ERROR_WRONG_PASS = "wrong_pass";
(...)
private class UserPassValidator extends AbstractValidator<String> implements IValidator<String>
{
private static final long serialVersionUID = 1L;
@Override
protected void onValidate(IValidatable<String> arg0)
{
final String oldPass = arg0.getValue();
if (!user.getCryptedPassword().equals(CypherUtil.encodeMd5(oldPass)))
{
error(arg0, ERROR_WRONG_PASS);
}
}
}
我得到警告,错误信息无法找到:
Could not locate error message for component: [email protected]:mp-oldpass and error: [ValidationError message=[null], keys=[wrong_pass, EditPassForm$UserPassValidator], variables=[]]. Tried keys: mp-oldpass.wrong_pass, wrong_pass, mp-oldpass.EditPassForm$UserPassValidator, EditPassForm$UserPassValidator.
我试图把每一个的.properties单页面可能与此表单连接,页面结构如下所示:
MainPage
|
|---AjaxTabbedPanels (it basically works like from wicket example http://www.wicket-library.com/wicket-examples/ajax/tabbed-panel?1)
|
|---ProfilePanel (extends Panel)
|
|---editProfileWindow (a Modal Window, opened on button click)
|
|---ProfileEditPass (extends WebPage, pageCreator for modalWindow)
|
|---EditPassForm (extends Form<Void>, class for form)
|
|--oldPass (PasswordTextField)
|--newPass (PasswordTextField)
|--newPassRepeat(PasswordTextField)
|--oldPassFeedbackPanel (ComponentFeedbackPanel)
|--...and so on for the rest
组合的属性文件我想:
mp-oldpass.wrong_pass = "Wprowadzono błędne hasło"
UserPassValidator = "Wprowadzono błędne hasło"
和属性文件我想:
EditPassForm.properties
ProfileEditPass.properties
ProfilePanel.properties
AjaxTabbedPanels.properties
MemberTemplatePage.properties (its basically a template, extended by AjaxTabbedPanels)
'mp-oldpass'是'IValidatable'的WicketId吗?如果没有,您是否在属性中尝试过'wrong_pass'或' .wrong_pass'?将这个资源放在使用Validator的面板中应该是有效的。 –