wicket验证listview里面的textfield看不到错误信息

时间:2013-06-05 03:20:16

标签: wicket

我在listview中有一个listview。我在嵌套列表视图中有一个文本字段。

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);
                }
            });

我在页面上有一个反馈面板

add(new FeedbackPanel("feedback"));

但我没有看到任何错误出现。如果输入的值未通过验证,则不会提交值。但我也没有看到错误消息。

在我的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);
    }

1 个答案:

答案 0 :(得分:2)

Reader 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, ...