listview中的wicket validate文本字段可以';看不到错误消息
我在listview中有一个listview。我在嵌套的listview中有一个textfieldlistview中的wicket validate文本字段可以';看不到错误消息,wicket,Wicket,我在listview中有一个listview。我在嵌套的listview中有一个textfield new ListView<ConfigStructure>("subListView", propertyList) { @Override protected void populateItem(ListItem<ConfigStructure> item) { Con
new ListView<ConfigStructure>("subListView", propertyList) {
@Override
protected void populateItem(ListItem<ConfigStructure> item) {
ConfigStructure config = item.getModelObject();
final TextField<String> configValue = new TextField<>("configValue",new PropertyModel(config, "value"));
configValue.setRequired(true);
configValue.add(new CustomConfigValidator(config));
item.add(configValue);
}
});
但我没有看到任何错误出现。如果输入的值未通过验证,则不会提交这些值。但是我也没有看到错误消息
在CustomConfigValidator中,我有以下内容
@Override
public void validate(IValidatable<String> validatable) {
//get input from attached component
final String field = validatable.getValue();
if(!checkIfValid){
error(validatable, "Validation failed for " + config.getLabel() + " with value " + field + ",value should satisfy " + validateString);
}
@覆盖
公共void validate(IValidatable validable){
//从附加组件获取输入
最后一个字符串字段=validable.getValue();
如果(!checkIfValid){
错误(可验证,“+config.getLabel()+”的值为“+field+”,验证失败,值应满足“+validateString”);
}
阅读器ListView的javadoc:
<strong>WARNING:</strong> though you can nest ListViews within Forms, you HAVE to set the setReuseItems property to true in order to have validation work properly. By default, ...
警告:虽然您可以在表单中嵌套ListView,但必须将setReuseItems属性设置为true才能使验证正常工作。默认情况下。。。
如何填写“checkIfValid”以及提交方法的内容是什么?
<strong>WARNING:</strong> though you can nest ListViews within Forms, you HAVE to set the setReuseItems property to true in order to have validation work properly. By default, ...